1 8 package test; 9 10 import junit.framework.TestCase; 11 import org.codehaus.aspectwerkz.exception.DefinitionException; 12 import org.codehaus.aspectwerkz.exception.WrappedRuntimeException; 13 14 17 public class ExceptionTest extends TestCase { 18 public void testWrappedRuntimeException() { 19 DefinitionException exception = new DefinitionException("definition not found"); 20 try { 21 try { 22 throw exception; 23 } catch (DefinitionException e) { 24 throw new WrappedRuntimeException(e); 25 } 26 } catch (WrappedRuntimeException e) { 27 assertEquals(exception.getMessage(), e.getMessage()); 28 assertEquals(exception.getLocalizedMessage(), e.getLocalizedMessage()); 29 assertEquals(exception.toString(), e.toString()); 30 assertTrue(e.getCause() instanceof DefinitionException); 31 } 32 } 33 34 public static void main(String [] args) { 35 junit.textui.TestRunner.run(suite()); 36 } 37 38 public static junit.framework.Test suite() { 39 return new junit.framework.TestSuite(ExceptionTest.class); 40 } 41 } | Popular Tags |