01: /**************************************************************************************
02: * Copyright (c) Jonas Bon?r, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test;
08:
09: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
10: import junit.framework.TestCase;
11:
12: /**
13: * Test for complex CFLOW
14: * See AW-226
15: *
16: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
17: */
18: public class ComplexCFlowTest extends TestCase {
19:
20: private static String s_logString = "";
21:
22: // //FIXME: see the aspect, pc is deactivated - see AW-251
23: // public void testComplexNotCFlow_1() {
24: // s_logString = "";
25: // method1();
26: // assertEquals(s_logString, " method1 4-!2-!3-Advice method4");
27: // }
28:
29: public void testComplexNotCFlow_2() {
30: s_logString = "";
31: method2();
32: assertEquals(s_logString, " method2 method4");
33: }
34:
35: public void testComplexNotCFlow_3() {
36: s_logString = "";
37: method3();
38: assertEquals(s_logString, " method3 method4");
39: }
40:
41: //--- Aspect
42:
43: public static class Aspect {
44:
45: /**
46: * FIXME: this expression leads to match all at cflow early filtering.
47: * <p/>
48: * XXBefore execution(* test.ComplexCFlowTest.method4(..)) AND within(test.ComplexCFlowTest)
49: * AND !cflow(call(* test.ComplexCFlowTest.method2(..)) AND within(test.ComplexCFlowTest))
50: * AND !cflow(call(* test.ComplexCFlowTest.method3(..)) AND within(test.ComplexCFlowTest))
51: */
52: public void method4NotIn2Or3Advice(JoinPoint joinPoint) {
53: s_logString += " 4-!2-!3-Advice";
54: }
55: }
56:
57: //--- JUnit
58:
59: public static void main(String[] args) {
60: junit.textui.TestRunner.run(suite());
61: }
62:
63: public static junit.framework.Test suite() {
64: return new junit.framework.TestSuite(ComplexCFlowTest.class);
65: }
66:
67: //--- Method to test
68:
69: public static void method1() {
70: s_logString += " method1";
71: method4();
72: }
73:
74: public static void method2() {
75: s_logString += " method2";
76: method4();
77: }
78:
79: public static void method3() {
80: s_logString += " method3";
81: method4();
82: }
83:
84: public static void method4() {
85: s_logString += " method4";
86: }
87:
88: }
|