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.afterxxx;
9
10 import junit.framework.TestCase;
11
12 public class Test extends TestCase {
13 private static String s_log;
14
15 public static void log(String msg) {
16 s_log += msg;
17 }
18
19 public void testall() {
20 s_log = "";
21 all();
22 assertEquals("logAround ", s_log);
23 }
24
25 public void testaroundFinally() {
26 s_log = "";
27 aroundFinally();
28 assertEquals("logAround logAfterFinally ", s_log);
29 }
30
31 public void testaroundFinallyReturning() {
32 s_log = "";
33 aroundFinallyReturning();
34 assertEquals("logAround logAfterFinally ", s_log);
35 }
36
37 public void testaroundReturning() {
38 s_log = "";
39 aroundReturning();
40 assertEquals("logAround logAfterReturning ", s_log);
41 }
42
43 public void testaroundFinallyReturningThrowing() {
44 s_log = "";
45 try {
46 aroundFinallyReturningThrowing();
47 } catch (UnsupportedOperationException e) {
48 }
49 assertEquals("logAround logAfterThrowing logAfterFinally ", s_log);
50 }
51
52 public void testaroundReturningThrowing() {
53 s_log = "";
54 try {
55 aroundReturningThrowing();
56 } catch (UnsupportedOperationException e) {
57 }
58 assertEquals("logAround logAfterThrowing ", s_log);
59 }
60
61 public void test_finally() {
62 s_log = "";
63 _finally();
64 assertEquals("logAfterFinally ", s_log);
65 }
66
67 public void testfinallyReturning() {
68 s_log = "";
69 finallyReturning();
70 assertEquals("logAfterReturning logAfterFinally ", s_log);
71 }
72
73 public void testfinallyReturningThrowing() {
74 s_log = "";
75 try {
76 finallyReturningThrowing();
77 } catch (UnsupportedOperationException e) {
78 }
79 assertEquals("logAfterThrowing logAfterFinally ", s_log);
80 }
81
82 public void testreturning() {
83 s_log = "";
84 returning();
85 assertEquals("logAfterReturning ", s_log);
86 }
87
88 public void testreturningThrowing() {
89 s_log = "";
90 try {
91 returningThrowing();
92 } catch (Exception e) {
93 }
94 assertEquals("", s_log);
95 }
96
97 public Test(String name) {
98 super(name);
99 }
100
101 public static void main(String[] args) {
102 junit.textui.TestRunner.run(suite());
103 }
104
105 public static junit.framework.Test suite() {
106 return new junit.framework.TestSuite(Test.class);
107 }
108
109 void all() {
110 }
111
112 void aroundFinally() {
113 }
114
115 Object aroundFinallyReturning() {
116 return null;
117 }
118
119 Object aroundReturning() {
120 return "aroundReturning";
121 }
122
123 Object aroundFinallyReturningThrowing() {
124 throw new UnsupportedOperationException();
125 }
126
127 Object aroundReturningThrowing() {
128 throw new UnsupportedOperationException();
129 }
130
131 void _finally() {
132 }
133
134 Object finallyReturning() {
135 return "finallyReturning";
136 }
137
138 Object finallyReturningThrowing() {
139 throw new UnsupportedOperationException();
140 }
141
142 Object returningThrowing() throws Exception {
143 throw new Exception();
144 }
145
146 Object returning() {
147 return "returning";
148 }
149 }