1 26 27 package net.sourceforge.groboutils.codecoverage.v2.datastore; 28 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import junit.framework.TestSuite; 32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 33 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil; 34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule; 35 36 37 44 public class AnalysisModuleSetUTest extends TestCase 45 { 46 49 private static final Class THIS_CLASS = AnalysisModuleSetUTest.class; 50 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 51 52 public AnalysisModuleSetUTest( String name ) 53 { 54 super( name ); 55 } 56 57 58 61 62 public void testConstructor1() 63 { 64 try 65 { 66 new AnalysisModuleSet( (IAnalysisModule[])null ); 67 fail( "Did not throw IllegalArgumentException." ); 68 } 69 catch (IllegalArgumentException ex) 70 { 71 } 73 } 74 75 76 public void testConstructor2() 77 { 78 try 79 { 80 new AnalysisModuleSet( (AnalysisModuleSet)null ); 81 fail( "Did not throw IllegalArgumentException." ); 82 } 83 catch (IllegalArgumentException ex) 84 { 85 } 87 } 88 89 90 public void testConstructor3() 91 { 92 try 93 { 94 new AnalysisModuleSet( new IAnalysisModule[1] ); 95 fail( "Did not throw IllegalArgumentException." ); 96 } 97 catch (IllegalArgumentException ex) 98 { 99 } 101 } 102 103 104 public void testConstructor4() 105 { 106 try 107 { 108 new AnalysisModuleSet( new IAnalysisModule[] { 109 createIAnalysisModule( "0" ), null } ); 110 fail( "Did not throw IllegalArgumentException." ); 111 } 112 catch (IllegalArgumentException ex) 113 { 114 } 116 } 117 118 119 public void testConstructor5() 120 { 121 new AnalysisModuleSet( new AnalysisModuleSet() ); 122 } 123 124 125 public void testAddAnalysisModule1() 126 { 127 AnalysisModuleSet ams = new AnalysisModuleSet(); 128 IAnalysisModule a1 = createIAnalysisModule( "a" ); 129 IAnalysisModule a2 = createIAnalysisModule( "a" ); 130 assertEquals( a1.getMeasureName(), a2.getMeasureName() ); 131 ams.addAnalysisModule( a1 ); 132 try 133 { 134 ams.addAnalysisModule( a2 ); 135 fail( "Did not throw IllegalStateException." ); 136 } 137 catch (IllegalStateException ex) 138 { 139 } 141 } 142 143 144 public void testAddAnalysisModule2() 145 { 146 AnalysisModuleSet ams = new AnalysisModuleSet(); 147 try 148 { 149 ams.addAnalysisModule( null ); 150 fail( "Did not throw IllegalStateException." ); 151 } 152 catch (IllegalArgumentException iae) 153 { 154 } 156 } 157 158 159 public void testJoinAnalysisModuleSet1() 160 { 161 AnalysisModuleSet ams = new AnalysisModuleSet(); 162 try 163 { 164 ams.joinAnalysisModuleSet( null ); 165 fail( "Did not throw IllegalStateException." ); 166 } 167 catch (IllegalArgumentException iae) 168 { 169 } 171 } 172 173 174 public void testJoinAnalysisModuleSet2() 175 { 176 IAnalysisModule a1 = createIAnalysisModule( "a" ); 177 AnalysisModuleSet ams = new AnalysisModuleSet( 178 new IAnalysisModule[] { a1 } ); 179 ams.joinAnalysisModuleSet( ams ); 180 } 181 182 183 public void testJoinAnalysisModuleSet3() 184 { 185 IAnalysisModule a1 = createIAnalysisModule( "a" ); 186 IAnalysisModule a2 = createIAnalysisModule( "b" ); 187 AnalysisModuleSet ams = new AnalysisModuleSet( 188 new IAnalysisModule[] { a1 } ); 189 ams.joinAnalysisModuleSet( new AnalysisModuleSet( 190 new IAnalysisModule[] { a2 } ) ); 191 assertEquals( 192 "Did not store correct number of modules.", 193 2, 194 ams.getAnalysisModuleCount() ); 195 } 196 197 198 223 224 225 public void testGetAnalysisModules1() 226 { 227 AnalysisModuleSet ams = new AnalysisModuleSet(); 228 IAnalysisModule[] amL = ams.getAnalysisModules(); 229 assertNotNull( 230 "Returned null module list.", 231 amL ); 232 assertEquals( 233 "Returned invalid module array length.", 234 0, 235 amL.length ); 236 } 237 238 239 public void testGetAnalysisModules2() 240 { 241 IAnalysisModule orig = createIAnalysisModule( "a" ); 242 AnalysisModuleSet ams = new AnalysisModuleSet( 243 new IAnalysisModule[] { orig } ); 244 IAnalysisModule[] amL = ams.getAnalysisModules(); 245 assertNotNull( 246 "Returned null module list.", 247 amL ); 248 assertEquals( 249 "Returned invalid module array length.", 250 1, 251 amL.length ); 252 assertSame( 253 "Returned invalid module.", 254 orig, 255 amL[0] ); 256 } 257 258 259 public void testGetMeasureIndex1() 260 { 261 AnalysisModuleSet ams = new AnalysisModuleSet(); 262 short i = ams.getMeasureIndex( "b" ); 263 assertEquals( 264 "Returned invalid index.", 265 -1, 266 i ); 267 } 268 269 270 public void testGetMeasureIndex2() 271 { 272 IAnalysisModule orig = createIAnalysisModule( "b" ); 273 AnalysisModuleSet ams = new AnalysisModuleSet( 274 new IAnalysisModule[] { orig } ); 275 short i = ams.getMeasureIndex( "b" ); 276 assertEquals( 277 "Returned invalid index.", 278 0, 279 i ); 280 } 281 282 283 public void testGetMeasureIndex3() 284 { 285 AnalysisModuleSet ams = new AnalysisModuleSet(); 286 try 287 { 288 ams.getMeasureIndex( null ); 289 fail( "Did not throw IllegalArgumentException." ); 290 } 291 catch (IllegalArgumentException ex) 292 { 293 } 295 } 296 297 298 public void testGetAnalysisModuleIndex1() 299 { 300 AnalysisModuleSet ams = new AnalysisModuleSet(); 301 try 302 { 303 ams.getAnalysisModuleIndex( null ); 304 fail( "Did not throw IllegalArgumentException." ); 305 } 306 catch (IllegalArgumentException ex) 307 { 308 } 310 } 311 312 313 public void testGetAnalysisModuleIndex2() 314 { 315 IAnalysisModule orig = createIAnalysisModule( "b" ); 316 AnalysisModuleSet ams = new AnalysisModuleSet(); 317 short i = ams.getAnalysisModuleIndex( orig ); 318 assertEquals( 319 "Did not return correct index.", 320 -1, 321 i ); 322 } 323 324 325 public void testGetAnalysisModuleIndex3() 326 { 327 IAnalysisModule orig = createIAnalysisModule( "b" ); 328 IAnalysisModule a = createIAnalysisModule( "a" ); 329 AnalysisModuleSet ams = new AnalysisModuleSet( 330 new IAnalysisModule[] { a } ); 331 short i = ams.getAnalysisModuleIndex( orig ); 332 assertEquals( 333 "Did not return correct index.", 334 -1, 335 i ); 336 } 337 338 339 public void testGetAnalysisModuleIndex4() 340 { 341 IAnalysisModule orig1 = createIAnalysisModule( "b" ); 342 AnalysisModuleSet ams = new AnalysisModuleSet( 343 new IAnalysisModule[] { orig1 } ); 344 short i = ams.getAnalysisModuleIndex( orig1 ); 345 assertEquals( 346 "Did not return correct index.", 347 0, 348 i ); 349 } 350 351 352 public void testGetAnalysisModuleCount1() 353 { 354 AnalysisModuleSet ams = new AnalysisModuleSet(); 355 assertEquals( 356 "Did not return correct count.", 357 0, 358 ams.getAnalysisModuleCount() ); 359 } 360 361 362 public void testGetAnalysisModuleCount2() 363 { 364 AnalysisModuleSet ams = new AnalysisModuleSet( 365 CCCreatorUtil.createAnalysisModules( 15 ) ); 366 assertEquals( 367 "Did not return correct count.", 368 15, 369 ams.getAnalysisModuleCount() ); 370 } 371 372 373 374 375 376 377 380 381 protected IAnalysisModule createIAnalysisModule( String name ) 382 { 383 return CCCreatorUtil.createIAnalysisModule( name, "u", "m" ); 384 } 385 386 387 388 391 392 public static Test suite() 393 { 394 TestSuite suite = new TestSuite( THIS_CLASS ); 395 396 return suite; 397 } 398 399 public static void main( String [] args ) 400 { 401 String [] name = { THIS_CLASS.getName() }; 402 403 406 junit.textui.TestRunner.main( name ); 407 } 408 409 410 414 protected void setUp() throws Exception 415 { 416 super.setUp(); 417 418 419 } 421 422 423 427 protected void tearDown() throws Exception 428 { 429 431 432 super.tearDown(); 433 } 434 } 435 436 | Popular Tags |