From: Bryan T. <tho...@us...> - 2007-10-18 16:54:11
|
Update of /cvsroot/cweb/junit-ext/src/test/junit/framework In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5364/src/test/junit/framework Modified Files: TestCase2TestCase.java Log Message: Added getInnerCause and isInnerCause. Index: TestCase2TestCase.java =================================================================== RCS file: /cvsroot/cweb/junit-ext/src/test/junit/framework/TestCase2TestCase.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestCase2TestCase.java 23 May 2006 16:06:05 -0000 1.8 --- TestCase2TestCase.java 18 Oct 2007 16:53:59 -0000 1.9 *************** *** 364,370 **** } /** ! * Test helper generates the binary entity read by one of the ! * test cases above. * * @param args --- 364,494 ---- } + public void test_getInnerCause_correctRejection() { + + try { + getInnerCause(null, null); + fail("Expecting: "+IllegalArgumentException.class); + } catch(IllegalArgumentException ex) { + System.err.println("Ignoring expected exception: "+ex); + } + + try { + getInnerCause(null, RuntimeException.class); + fail("Expecting: "+IllegalArgumentException.class); + } catch(IllegalArgumentException ex) { + System.err.println("Ignoring expected exception: "+ex); + } + + try { + getInnerCause(new RuntimeException(), null); + fail("Expecting: "+IllegalArgumentException.class); + } catch(IllegalArgumentException ex) { + System.err.println("Ignoring expected exception: "+ex); + } + + } + /** ! * Finds cause when it is on top of the stack trace and the right type. ! */ ! public void test_getInnerCause01_find_exact() { ! ! Throwable t = new RuntimeException(); ! ! assertTrue(t == getInnerCause(t, RuntimeException.class)); ! ! } ! ! /** ! * Find cause when it is on top of the stack trace and a subclass of the ! * desired type. ! */ ! public void test_getInnerCause01_find_subclass() { ! ! Throwable t = new IOException(); ! ! assertTrue(t == getInnerCause(t, Exception.class)); ! ! } ! ! /** ! * Does not find cause that is a super class of the desired type. ! */ ! public void test_getInnerCause01_reject_superclass() { ! ! Throwable t = new Exception(); ! ! assertNull(getInnerCause(t, IOException.class)); ! ! } ! ! /** ! * Does not find cause when it is on top of the stack trace and not either ! * the desired type or a subclass of the desired type. ! */ ! public void test_getInnerCause01_reject_otherType() { ! ! Throwable t = new Throwable(); ! ! assertNull(getInnerCause(t, Exception.class)); ! ! } ! ! /** ! * Finds inner cause that is the exact type. ! */ ! public void test_getInnerCause02_find_exact() { ! ! Throwable cause = new Exception(); ! ! Throwable t = new Throwable(cause); ! ! assertTrue(cause == getInnerCause(t, Exception.class)); ! ! } ! ! /** ! * Finds inner cause that is a derived type (subclass). ! */ ! public void test_getInnerCause02_find_subclass() { ! ! Throwable cause = new IOException(); ! ! Throwable t = new Throwable(cause); ! ! assertTrue(cause == getInnerCause(t, Exception.class)); ! ! } ! ! /** ! * Does not find inner cause that is a super class of the desired type. ! */ ! public void test_getInnerCause02_reject_superclass() { ! ! Throwable cause = new Exception(); ! ! Throwable t = new RuntimeException(cause); ! ! assertNull( getInnerCause(t, IOException.class)); ! ! } ! ! /** ! * Does not find an inner cause that is neither the specified type nor a ! * subtype of the specified type. ! */ ! public void test_getInnerCause03_reject_otherType() { ! ! Throwable cause = new RuntimeException(); ! ! Throwable t = new Exception(cause); ! ! assertNull( getInnerCause(t, IOException.class) ); ! ! } ! ! /** ! * Test helper generates the binary entity read by one of the test cases ! * above. * * @param args |