1 package org.junitdoclet; 2 3 import junit.framework.TestCase; 4 import org.junitdoclet.PackageLister; 6 8 15 16 17 public class PackageListerTest 18 extends TestCase 20 { 22 PackageLister packagelister = null; 24 26 public PackageListerTest(String name) { 27 super(name); 29 } 31 32 public org.junitdoclet.PackageLister createInstance() { 33 return new PackageLister(); 35 } 37 38 protected void setUp() throws Exception { 39 super.setUp(); 41 packagelister = createInstance(); 42 } 44 45 protected void tearDown() throws Exception { 46 packagelister = null; 48 super.tearDown(); 49 } 51 52 public void testInit() throws Exception { 53 packagelister.init(); 55 assertEquals(null, packagelister.getOutput()); 56 assertEquals(null, packagelister.getPath()); 57 assertEquals(null, packagelister.getTopPackage()); 58 } 60 61 public void testSetGetOutput() throws Exception { 62 String [] tests = {"", " ", "a", "A", "ä", "ß", "0123456789", "012345678901234567890", "\n", null}; 64 65 for (int i = 0; i < tests.length; i++) { 66 packagelister.setOutput(tests[i]); 67 assertEquals(tests[i], packagelister.getOutput()); 68 } 69 } 71 72 public void testSetGetTopPackage() throws Exception { 73 String [] tests = {"", " ", "a", "A", "ä", "ß", "0123456789", "012345678901234567890", "\n", null}; 75 76 for (int i = 0; i < tests.length; i++) { 77 packagelister.setTopPackage(tests[i]); 78 assertEquals(tests[i], packagelister.getTopPackage()); 79 } 80 } 82 83 public void testSetGetPath() throws Exception { 84 String [] tests = {"", " ", "a", "A", "ä", "ß", "0123456789", "012345678901234567890", "\n", null}; 86 87 for (int i = 0; i < tests.length; i++) { 88 packagelister.setPath(tests[i]); 89 assertEquals(tests[i], packagelister.getPath()); 90 } 91 } 93 94 public void testProcessArgs() throws Exception { 95 String [] ARGS_MIN = {"."}; 97 String [] ARGS_WITH_OUTPUT_1 = {"-o", "package.txt", "."}; 98 String [] ARGS_WITH_OUTPUT_2 = {".", "-o", "package.txt"}; 99 String [] ARGS_WITH_OUTPUT_3 = {"-o", "."}; 100 String [] ARGS_WITH_OUTPUT_4 = {".", "-o"}; 101 String [] ARGS_WITH_OUTPUT_5 = {"-o"}; 102 String [] ARGS_WITH_TOP_1 = {".", "-top", "*"}; 103 String [] ARGS_WITH_TOP_2 = {".", "-top", "com"}; 104 String [] ARGS_WITH_TOP_3 = {".", "-top", "com.objectfab"}; 105 String [] ARGS_WITH_TOP_4 = {"-top", "*", "."}; 106 String [] ARGS_WITH_TOP_5 = {".", "-top"}; 107 String [] ARGS_WITH_TOP_6 = {"-top"}; 108 String [] ARGS_WITH_ALL_1 = {"-top", "*", ".", "-o", "packages.txt"}; 109 String [] ARGS_WITH_ALL_2 = {".", "-top", "*", "-o", "packages.txt"}; 110 String [] ARGS_WITH_ALL_3 = {".", "-o", "packages.txt", "-top", "*"}; 111 112 assertEquals(true, packagelister.processArgs(ARGS_MIN)); 113 assertEquals(true, packagelister.processArgs(ARGS_WITH_OUTPUT_1)); 114 assertEquals(true, packagelister.processArgs(ARGS_WITH_OUTPUT_2)); 115 assertEquals(false, packagelister.processArgs(ARGS_WITH_OUTPUT_3)); 116 assertEquals(false, packagelister.processArgs(ARGS_WITH_OUTPUT_4)); 117 assertEquals(false, packagelister.processArgs(ARGS_WITH_OUTPUT_5)); 118 assertEquals(true, packagelister.processArgs(ARGS_WITH_TOP_1)); 119 assertEquals(true, packagelister.processArgs(ARGS_WITH_TOP_2)); 120 assertEquals(true, packagelister.processArgs(ARGS_WITH_TOP_3)); 121 assertEquals(true, packagelister.processArgs(ARGS_WITH_TOP_4)); 122 assertEquals(false, packagelister.processArgs(ARGS_WITH_TOP_5)); 123 assertEquals(false, packagelister.processArgs(ARGS_WITH_TOP_6)); 124 assertEquals(true, packagelister.processArgs(ARGS_WITH_ALL_1)); 125 assertEquals(true, packagelister.processArgs(ARGS_WITH_ALL_2)); 126 packagelister.init(); 127 assertEquals(true, packagelister.processArgs(ARGS_WITH_ALL_3)); 128 assertEquals("*", packagelister.getTopPackage()); 129 assertEquals("packages.txt", packagelister.getOutput()); 130 assertEquals(".", packagelister.getPath()); 131 } 133 134 public void testExecute() throws Exception { 135 } 138 139 public void testMain() throws Exception { 140 } 143 144 public void testPrintUsage() throws Exception { 145 } 148 149 public void testCollectPackages() throws Exception { 150 } 153 154 public void testWritePackages() throws Exception { 155 } 158 159 160 161 167 public void testVault() throws Exception { 168 } 171 172 public static void main(String [] args) { 173 junit.textui.TestRunner.run(PackageListerTest.class); 175 } 177 } 178 | Popular Tags |