KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > bindingsyntax > AdviceBindingTest


1 /***************************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- * The software
5  * in this package is published under the terms of the LGPL license * a copy of which has been
6  * included with this distribution in the license.txt file. *
7  **************************************************************************************************/

8 package test.bindingsyntax;
9
10 import junit.framework.TestCase;
11
12 public class AdviceBindingTest extends TestCase {
13     public static transient String JavaDoc flow = "";
14
15     public AdviceBindingTest(String JavaDoc s) {
16         super(s);
17     }
18
19     public String JavaDoc doA(String JavaDoc s) {
20         return 'A' + s;
21     }
22
23     public String JavaDoc doRA(String JavaDoc s) {
24         return 'A' + s;
25     }
26
27     public String JavaDoc doB(String JavaDoc s) {
28         return 'B' + s;
29     }
30
31     public String JavaDoc doRB(String JavaDoc s) {
32         return 'B' + s;
33     }
34
35     public String JavaDoc doC(String JavaDoc s) {
36         return 'C' + s;
37     }
38
39     public String JavaDoc doRC(String JavaDoc s) {
40         return 'C' + s;
41     }
42
43     public String JavaDoc doD(String JavaDoc s) {
44         return 'D' + s;
45     }
46
47     public String JavaDoc doRD(String JavaDoc s) {
48         return 'D' + s;
49     }
50
51     public static String JavaDoc doAA(String JavaDoc s) {
52         return "AA" + s;
53     }
54
55     public static String JavaDoc doBB(String JavaDoc s) {
56         return "BB" + s;
57     }
58
59     public static String JavaDoc doCC(String JavaDoc s) {
60         return "CC" + s;
61     }
62
63     public String JavaDoc doDD(String JavaDoc s) {
64         return "DD" + s;
65     }
66
67     public void testAdviceStack() {
68         assertEquals("12Atest", doA("test"));
69         assertEquals("12AAtest", doAA("test"));
70         assertEquals("21Atest", doRA("test"));
71     }
72
73     public void testTwoAdice() {
74         assertEquals("12Ctest", doC("test"));
75         assertEquals("12CCtest", doCC("test"));
76         assertEquals("21Ctest", doRC("test"));
77     }
78
79     /**
80      * Note: precedence is not the same due to aspect precedence
81      */

82     public void testTwoAspect() {
83         assertEquals("12Dtest", doD("test"));
84         assertEquals("12DDtest", doDD("test"));
85         assertEquals("21Dtest", doRD("test"));
86     }
87
88     public static void main(String JavaDoc[] args) {
89         junit.textui.TestRunner.run(suite());
90     }
91
92     public static junit.framework.Test suite() {
93         return new junit.framework.TestSuite(AdviceBindingTest.class);
94     }
95 }
Popular Tags