1 package org.hanseltest; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 6 import org.hansel.CoverageDecorator; 7 8 14 public class TestBug584900 extends TestCase { 15 16 20 public TestBug584900(String name) { 21 super(name); 22 } 23 24 29 public static Test suite() { 30 return new CoverageDecorator(TestBug584900.class, 31 new Class [] {Example.class}); 32 } 33 34 37 public void testClass() { 38 Example example = new Example(); 39 assertEquals(2, example.testMethod("java.lang.String")); 40 assertEquals(3, example.testMethod("no.known.class")); 41 } 42 43 44 public static class Example { 45 51 public int testMethod(String classname) { 52 int i = 0; 53 try { 54 Class.forName(classname); 55 } catch (ClassNotFoundException cnfe) { 56 i += 1; 57 } finally { 58 i += 2; 59 } 60 61 return i; 62 } 63 64 } 65 } 66 | Popular Tags |