01: /***************************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- * The software
05: * in this package is published under the terms of the LGPL license * a copy of which has been
06: * included with this distribution in the license.txt file. *
07: **************************************************************************************************/package test.bindingsyntax;
08:
09: import junit.framework.TestCase;
10:
11: public class AdviceBindingTest extends TestCase {
12: public static transient String flow = "";
13:
14: public AdviceBindingTest(String s) {
15: super (s);
16: }
17:
18: public String doA(String s) {
19: return 'A' + s;
20: }
21:
22: public String doRA(String s) {
23: return 'A' + s;
24: }
25:
26: public String doB(String s) {
27: return 'B' + s;
28: }
29:
30: public String doRB(String s) {
31: return 'B' + s;
32: }
33:
34: public String doC(String s) {
35: return 'C' + s;
36: }
37:
38: public String doRC(String s) {
39: return 'C' + s;
40: }
41:
42: public String doD(String s) {
43: return 'D' + s;
44: }
45:
46: public String doRD(String s) {
47: return 'D' + s;
48: }
49:
50: public static String doAA(String s) {
51: return "AA" + s;
52: }
53:
54: public static String doBB(String s) {
55: return "BB" + s;
56: }
57:
58: public static String doCC(String s) {
59: return "CC" + s;
60: }
61:
62: public String doDD(String s) {
63: return "DD" + s;
64: }
65:
66: public void testAdviceStack() {
67: assertEquals("12Atest", doA("test"));
68: assertEquals("12AAtest", doAA("test"));
69: assertEquals("21Atest", doRA("test"));
70: }
71:
72: public void testTwoAdice() {
73: assertEquals("12Ctest", doC("test"));
74: assertEquals("12CCtest", doCC("test"));
75: assertEquals("21Ctest", doRC("test"));
76: }
77:
78: /**
79: * Note: precedence is not the same due to aspect precedence
80: */
81: public void testTwoAspect() {
82: assertEquals("12Dtest", doD("test"));
83: assertEquals("12DDtest", doDD("test"));
84: assertEquals("21Dtest", doRD("test"));
85: }
86:
87: public static void main(String[] args) {
88: junit.textui.TestRunner.run(suite());
89: }
90:
91: public static junit.framework.Test suite() {
92: return new junit.framework.TestSuite(AdviceBindingTest.class);
93: }
94: }
|