1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 38 import junit.framework.*; 39 40 public class TestDirectoryExplorer extends TestCase { 41 public static final String TEST_FILENAME = "classes" + File.separator + "test.class"; 42 public static final String OTHER_FILENAME = "tests" + File.separator + "JarJarDiff" + File.separator + "build.xml"; 43 public static final String MISSING_FILENAME = "tests" + File.separator + "JarJarDiff" + File.separator + "missing"; 44 public static final String TEST_DIRNAME = "tests" + File.separator + "JarJarDiff" + File.separator + "old"; 45 public static final String OTHER_DIRNAME = "tests" + File.separator + "JarJarDiff" + File.separator + "new"; 46 47 public void testExploreFilename() throws IOException { 48 DirectoryExplorer explorer = new DirectoryExplorer(TEST_FILENAME); 49 50 List list = new ArrayList(explorer.getCollection()); 51 52 assertEquals("size", 1, list.size()); 53 assertEquals(TEST_FILENAME, ((File) list.get(0)).getPath()); 54 } 55 56 public void testExploreOtherFilename() throws IOException { 57 DirectoryExplorer explorer = new DirectoryExplorer(OTHER_FILENAME); 58 59 List list = new ArrayList(explorer.getCollection()); 60 61 assertEquals("size", 1, list.size()); 62 assertEquals(OTHER_FILENAME, ((File) list.get(0)).getPath()); 63 } 64 65 public void testExploreMissingFilename() throws IOException { 66 DirectoryExplorer explorer = new DirectoryExplorer(MISSING_FILENAME); 67 68 assertEquals("size", 0, explorer.getCollection().size()); 69 } 70 71 public void testExploreDirectory() throws IOException { 72 DirectoryExplorer explorer = new DirectoryExplorer(TEST_DIRNAME); 73 74 List list = new ArrayList(explorer.getCollection()); 75 76 assertEquals("size", 59, list.size()); 77 assertEquals(TEST_DIRNAME, ((File) list.get(0)).getPath()); 78 } 79 80 public void testExploreMultipleDirectories() throws IOException { 81 Collection directories = new ArrayList(); 82 directories.add(TEST_DIRNAME); 83 directories.add(OTHER_DIRNAME); 84 85 DirectoryExplorer explorer = new DirectoryExplorer(directories); 86 87 List list = new ArrayList(explorer.getCollection()); 88 89 assertEquals("size", 118, list.size()); 90 assertEquals(TEST_DIRNAME, ((File) list.get(0)).getPath()); 91 } 92 93 public void testExploreSingletonFile() throws IOException { 94 Collection files = new ArrayList(); 95 files.add(TEST_FILENAME); 96 97 DirectoryExplorer explorer = new DirectoryExplorer(files); 98 99 List list = new ArrayList(explorer.getCollection()); 100 101 assertEquals("size", 1, list.size()); 102 assertEquals(TEST_FILENAME, ((File) list.get(0)).getPath()); 103 } 104 } 105 | Popular Tags |