KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ComplexCFlowTest


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;
9
10 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
11 import junit.framework.TestCase;
12
13 /**
14  * Test for complex CFLOW
15  * See AW-226
16  *
17  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur</a>
18  */

19 public class ComplexCFlowTest extends TestCase {
20
21     private static String JavaDoc s_logString = "";
22
23 // //FIXME: see the aspect, pc is deactivated - see AW-251
24
// public void testComplexNotCFlow_1() {
25
// s_logString = "";
26
// method1();
27
// assertEquals(s_logString, " method1 4-!2-!3-Advice method4");
28
// }
29

30     public void testComplexNotCFlow_2() {
31         s_logString = "";
32         method2();
33         assertEquals(s_logString, " method2 method4");
34     }
35
36     public void testComplexNotCFlow_3() {
37         s_logString = "";
38         method3();
39         assertEquals(s_logString, " method3 method4");
40     }
41
42     //--- Aspect
43

44     public static class Aspect {
45
46         /**
47          * FIXME: this expression leads to match all at cflow early filtering.
48          * <p/>
49          * XXBefore execution(* test.ComplexCFlowTest.method4(..)) AND within(test.ComplexCFlowTest)
50          * AND !cflow(call(* test.ComplexCFlowTest.method2(..)) AND within(test.ComplexCFlowTest))
51          * AND !cflow(call(* test.ComplexCFlowTest.method3(..)) AND within(test.ComplexCFlowTest))
52          */

53         public void method4NotIn2Or3Advice(JoinPoint joinPoint) {
54             s_logString += " 4-!2-!3-Advice";
55         }
56     }
57
58     //--- JUnit
59

60     public static void main(String JavaDoc[] args) {
61         junit.textui.TestRunner.run(suite());
62     }
63
64     public static junit.framework.Test suite() {
65         return new junit.framework.TestSuite(ComplexCFlowTest.class);
66     }
67
68     //--- Method to test
69

70     public static void method1() {
71         s_logString += " method1";
72         method4();
73     }
74
75     public static void method2() {
76         s_logString += " method2";
77         method4();
78     }
79
80     public static void method3() {
81         s_logString += " method3";
82         method4();
83     }
84
85     public static void method4() {
86         s_logString += " method4";
87     }
88
89
90 }
91
Popular Tags