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 flow = "";
14  
15      public AdviceBindingTest(String s) {
16          super(s);
17      }
18  
19      public String doA(String s) {
20          return 'A' + s;
21      }
22  
23      public String doRA(String s) {
24          return 'A' + s;
25      }
26  
27      public String doB(String s) {
28          return 'B' + s;
29      }
30  
31      public String doRB(String s) {
32          return 'B' + s;
33      }
34  
35      public String doC(String s) {
36          return 'C' + s;
37      }
38  
39      public String doRC(String s) {
40          return 'C' + s;
41      }
42  
43      public String doD(String s) {
44          return 'D' + s;
45      }
46  
47      public String doRD(String s) {
48          return 'D' + s;
49      }
50  
51      public static String doAA(String s) {
52          return "AA" + s;
53      }
54  
55      public static String doBB(String s) {
56          return "BB" + s;
57      }
58  
59      public static String doCC(String s) {
60          return "CC" + s;
61      }
62  
63      public String doDD(String 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[] 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  }