1 /***************************************************************************************
2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
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 /***
15 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16 */
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 }