EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.classreader]

COVERAGE SUMMARY FOR SOURCE FILE [TestDirectoryExplorer.java]

nameclass, %method, %block, %line, %
TestDirectoryExplorer.java100% (1/1)100% (9/9)100% (299/299)100% (59/59)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestDirectoryExplorer100% (1/1)100% (9/9)100% (299/299)100% (59/59)
TestDirectoryExplorer (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (74/74)100% (15/15)
tearDown (): void 100% (1/1)100% (61/61)100% (10/10)
testExploreDirectory (): void 100% (1/1)100% (25/25)100% (5/5)
testExploreFilename (): void 100% (1/1)100% (25/25)100% (5/5)
testExploreMissingFilename (): void 100% (1/1)100% (14/14)100% (3/3)
testExploreMultipleDirectories (): void 100% (1/1)100% (39/39)100% (8/8)
testExploreOtherFilename (): void 100% (1/1)100% (25/25)100% (5/5)
testExploreSingletonFile (): void 100% (1/1)100% (33/33)100% (7/7)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.classreader;
34 
35import java.io.*;
36import java.util.*;
37 
38import junit.framework.*;
39 
40public class TestDirectoryExplorer extends TestCase {
41    private File testFile;
42    private File otherFile;
43    private File missingFile;
44    private File testDir;
45    private File otherDir;
46 
47    protected void setUp() throws Exception {
48        super.setUp();
49 
50        testFile = File.createTempFile(getName(), null);
51 
52        otherFile = File.createTempFile(getName(), null);
53 
54        missingFile = File.createTempFile(getName(), null);
55        missingFile.delete();
56 
57        testDir = File.createTempFile(getName(), null);
58        testDir.delete();
59        testDir.mkdir();
60        File.createTempFile(getName(), null, testDir);
61        File.createTempFile(getName(), null, testDir);
62 
63        otherDir = File.createTempFile(getName(), null);
64        otherDir.delete();
65        otherDir.mkdir();
66        File.createTempFile(getName(), null, otherDir);
67    }
68 
69    protected void tearDown() throws Exception {
70        testFile.delete();
71 
72        otherFile.delete();
73 
74        for (File file : testDir.listFiles()) {
75            file.delete();
76        }
77        testDir.delete();
78 
79        for (File file : otherDir.listFiles()) {
80            file.delete();
81        }
82        otherDir.delete();
83 
84        super.tearDown();
85    }
86 
87    public void testExploreFilename() throws IOException {
88        DirectoryExplorer explorer = new DirectoryExplorer(testFile.getPath());
89 
90        List<File> list = new ArrayList<File>(explorer.getFiles());
91        
92        assertEquals("size", 1, list.size());
93        assertEquals(testFile, list.get(0));
94    }
95 
96    public void testExploreOtherFilename() throws IOException {
97        DirectoryExplorer explorer = new DirectoryExplorer(otherFile.getPath());
98 
99        List<File> list = new ArrayList<File>(explorer.getFiles());
100        
101        assertEquals("size", 1, list.size());
102        assertEquals(otherFile, list.get(0));
103    }
104 
105    public void testExploreMissingFilename() throws IOException {
106        DirectoryExplorer explorer = new DirectoryExplorer(missingFile.getPath());
107        
108        assertEquals("size", 0, explorer.getFiles().size());
109    }
110 
111    public void testExploreDirectory() throws IOException {
112        DirectoryExplorer explorer = new DirectoryExplorer(testDir.getPath());
113 
114        List<File> list = new ArrayList<File>(explorer.getFiles());
115        
116        assertEquals("size", 3, list.size());
117        assertEquals(testDir, list.get(0));
118    }
119    
120    public void testExploreMultipleDirectories() throws IOException {
121        Collection<String> directories = new ArrayList<String>();
122        directories.add(testDir.getPath());
123        directories.add(otherDir.getPath());
124        
125        DirectoryExplorer explorer = new DirectoryExplorer(directories);
126 
127        List<File> list = new ArrayList<File>(explorer.getFiles());
128        
129        assertEquals("size", 5, list.size());
130        assertEquals(testDir, list.get(0));
131    }
132    
133    public void testExploreSingletonFile() throws IOException {
134        Collection<String> files = new ArrayList<String>();
135        files.add(testFile.getPath());
136        
137        DirectoryExplorer explorer = new DirectoryExplorer(files);
138 
139        List<File> list = new ArrayList<File>(explorer.getFiles());
140        
141        assertEquals("size", 1, list.size());
142        assertEquals(testFile, list.get(0));
143    }
144}

[all classes][com.jeantessier.classreader]
EMMA 2.0.5312 (C) Vladimir Roubtsov