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.handler;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13: */
14: public class HandlerTest extends TestCase {
15: private static String s_log = "";
16:
17: public HandlerTest() {
18: }
19:
20: public HandlerTest(String name) {
21: super (name);
22: }
23:
24: public void testBeforeAdvice() {
25: s_log = "";
26: try {
27: throw new HandlerTestBeforeException();
28: } catch (HandlerTestBeforeException e) {
29: log("catch ");
30: }
31: assertEquals("before catch ", s_log);
32: }
33:
34: public void testBeforeAdvice2() {
35: s_log = "";
36: try {
37: try {
38: throw new HandlerTestBeforeException();
39: } catch (HandlerTestBeforeException e) {
40: log("catch ");
41: } finally {
42: log("finally ");
43: }
44: } finally {
45: log("finally2 ");
46: }
47: assertEquals("before before2 catch finally finally2 ", s_log);
48: }
49:
50: public void testBeforeAdvice3() {
51: s_log = "";
52: try {
53: throw new HandlerTestBeforeException();
54: } catch (HandlerTestBeforeException e) {
55: log("catch ");
56: } finally {
57: log("finally ");
58: }
59: assertEquals("before before3 catch finally ", s_log);
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(HandlerTest.class);
68: }
69:
70: public static void log(final String wasHere) {
71: s_log += wasHere;
72: }
73: }
|