1 26 27 package net.sourceforge.groboutils.junit.v1.parser; 28 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import junit.framework.TestSuite; 32 import junit.framework.AssertionFailedError; 33 34 import java.io.IOException ; 35 import java.lang.reflect.Method ; 36 37 38 45 public class TestClassCreatorUTest extends TestCase 46 { 47 50 private static final Class THIS_CLASS = TestClassCreatorUTest.class; 51 52 public TestClassCreatorUTest( String name ) 53 { 54 super( name ); 55 } 56 57 58 59 60 63 64 public void testConstructor1() 65 { 66 try 67 { 68 new TestClassCreator( null ); 69 } 70 catch (IllegalArgumentException e) 71 { 72 } 74 } 75 76 77 public void testConstructor2() 78 { 79 new TestClassCreator( new JUnitOrigCreator() ); 80 } 81 82 83 public void testWarnings1() 84 { 85 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 86 87 String s[] = tcc.getWarnings(); 88 89 assertNotNull( "Returned null warnings array.", 90 s ); 91 assertEquals( "Returned warnings array with elements.", 92 0, 93 s.length ); 94 } 95 96 97 public void testWarnings2() 98 { 99 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 100 101 tcc.warning( "a" ); 102 String s[] = tcc.getWarnings(); 103 104 assertNotNull( "Returned null warnings array.", 105 s ); 106 assertEquals( "Returned warnings array with incorrect element count.", 107 1, 108 s.length ); 109 assertEquals( "Did not return warnings array with correct entry.", 110 "a", 111 s[0] ); 112 } 113 114 115 public void testWarnings3() 116 { 117 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 118 119 tcc.warning( "a" ); 120 tcc.warning( "b" ); 121 String s[] = tcc.getWarnings(); 122 123 assertNotNull( "Returned null warnings array.", 124 s ); 125 assertEquals( "Returned warnings array with incorrect element count.", 126 2, 127 s.length ); 128 assertEquals( "Did not return warnings array with correct entry.", 129 "a", 130 s[0] ); 131 assertEquals( "Did not return warnings array with correct entry.", 132 "b", 133 s[1] ); 134 } 135 136 137 public void testClearWarnings1() 138 { 139 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 140 141 tcc.clearWarnings(); 142 String s[] = tcc.getWarnings(); 143 144 assertNotNull( "Returned null warnings array.", 145 s ); 146 assertEquals( "Returned warnings array with elements.", 147 0, 148 s.length ); 149 } 150 151 152 public void testClearWarnings2() 153 { 154 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 155 156 tcc.warning( "a" ); 157 tcc.clearWarnings(); 158 String s[] = tcc.getWarnings(); 159 160 assertNotNull( "Returned null warnings array.", 161 s ); 162 assertEquals( "Returned warnings array with elements.", 163 0, 164 s.length ); 165 } 166 167 168 public void testClearWarnings3() 169 { 170 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 171 172 tcc.warning( "a" ); 173 tcc.warning( "b" ); 174 tcc.clearWarnings(); 175 String s[] = tcc.getWarnings(); 176 177 assertNotNull( "Returned null warnings array.", 178 s ); 179 assertEquals( "Returned warnings array with elements.", 180 0, 181 s.length ); 182 } 183 184 185 public void testCreateWarningTests1() 186 { 187 TestClassCreator tcc = new TestClassCreator( new JUnitOrigCreator() ); 188 189 tcc.warning( "a" ); 190 tcc.warning( "b" ); 191 Test t[] = tcc.createWarningTests( new TestClassParser( THIS_CLASS ) ); 192 193 assertNotNull( "Returned null warning test list.", 194 t ); 195 assertEquals( 196 "Returned warnings test list with incorrect element count.", 197 2, 198 t.length ); 199 201 202 203 String s[] = tcc.getWarnings(); 205 206 assertNotNull( "Returned null warnings array.", 207 s ); 208 assertEquals( "Returned warnings array with incorrect element count.", 209 2, 210 s.length ); 211 assertEquals( "Did not return warnings array with correct entry.", 212 "a", 213 s[0] ); 214 assertEquals( "Did not return warnings array with correct entry.", 215 "b", 216 s[1] ); 217 } 218 219 220 221 341 342 343 344 347 348 public static Test suite() 349 { 350 TestSuite suite = new TestSuite( THIS_CLASS ); 351 352 return suite; 353 } 354 355 public static void main( String [] args ) 356 { 357 String [] name = { THIS_CLASS.getName() }; 358 359 362 junit.textui.TestRunner.main( name ); 363 } 364 365 366 370 protected void setUp() throws Exception 371 { 372 super.setUp(); 373 374 } 376 377 378 382 protected void tearDown() throws Exception 383 { 384 386 387 super.tearDown(); 388 } 389 } 390 391 | Popular Tags |