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.afterxxx;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
13: */
14: public class TestBinding extends TestCase {
15:
16: private static String s_log;
17:
18: public void testReturnInt() {
19: s_log = "";
20: returnInt(1);
21: assertEquals("afterReturningInt 2", s_log);
22: }
23:
24: public void testReturnString() {
25: s_log = "";
26: returnString("hello");
27: assertEquals("afterReturningString hellohello", s_log);
28: }
29:
30: public void testThrowing() {
31: s_log = "";
32: try {
33: throwChecked();
34: } catch (Throwable t) {
35: //System.out.println(s_log);
36: assertEquals(
37: "afterThrowingExact java.lang.ClassNotFoundException afterThrowingParentClass java.lang.ClassNotFoundException",
38: s_log);
39: return;
40: }
41: fail("should have encounter an exception");
42: }
43:
44: //-- Test methods
45: public int returnInt(int i) {
46: return 2 * i;
47: }
48:
49: public String returnString(String s) {
50: return s + s;
51: }
52:
53: public void throwChecked() throws ClassNotFoundException {
54: throw new ClassNotFoundException("checked exception");
55: }
56:
57: //-- JUnit
58: public static void log(String msg) {
59: s_log += msg;
60: }
61:
62: public static void main(String[] args) {
63: junit.textui.TestRunner.run(suite());
64: }
65:
66: public static junit.framework.Test suite() {
67: return new junit.framework.TestSuite(TestBinding.class);
68: }
69: }
|