01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test;
08:
09: import junit.framework.TestCase;
10: import org.codehaus.aspectwerkz.exception.DefinitionException;
11: import org.codehaus.aspectwerkz.exception.WrappedRuntimeException;
12:
13: /**
14: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15: */
16: public class ExceptionTest extends TestCase {
17: public void testWrappedRuntimeException() {
18: DefinitionException exception = new DefinitionException(
19: "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
29: .getLocalizedMessage());
30: assertEquals(exception.toString(), e.toString());
31: assertTrue(e.getCause() instanceof DefinitionException);
32: }
33: }
34:
35: public static void main(String[] args) {
36: junit.textui.TestRunner.run(suite());
37: }
38:
39: public static junit.framework.Test suite() {
40: return new junit.framework.TestSuite(ExceptionTest.class);
41: }
42: }
|