01: //$Id$
02: //=====================================================================
03: //
04: //(history at end)
05: //
06:
07: package ch.ethz.prose.crosscut;
08:
09: import junit.framework.TestCase;
10: import ch.ethz.prose.*;
11: import ch.ethz.prose.filter.*;
12:
13: /**
14: * Cross-cut an invokeinterface method call.
15: *
16: * @version $Revision$
17: * @author Johann Gyger
18: */
19: public class InterfaceMethodTest extends TestCase {
20:
21: protected static boolean crosscutted;
22:
23: public InterfaceMethodTest(String name) {
24: super (name);
25: }
26:
27: protected void setUp() throws SystemStartupException {
28: ProseSystem.startup();
29: }
30:
31: protected void tearDown() throws SystemTeardownException {
32: ProseSystem.teardown();
33: }
34:
35: public void myMethod() {
36: }
37:
38: public void test_010_static_getcut() {
39: ProseSystem.getAspectManager().insert(new MethodAspect());
40: MyInterface mi = new MyClass();
41: mi.myMethod();
42: assertTrue("Interface invocation is cross-cutted", crosscutted);
43: }
44:
45: public interface MyInterface {
46: public void myMethod();
47: }
48:
49: public class MyClass implements MyInterface {
50: public void myMethod() {
51: };
52: }
53:
54: public class MethodAspect extends DefaultAspect {
55: public Crosscut c = new MethodCut() {
56: public void METHOD_ARGS(MyClass c) {
57: crosscutted = true;
58: }
59:
60: protected PointCutter pointCutter() {
61: return Within.method("myMethod").AND(
62: Executions.before());
63: }
64:
65: protected Class[] potentialCrosscutClasses() {
66: return new Class[] { MyClass.class };
67: }
68: };
69: };
70:
71: }
72:
73: //======================================================================
74: //
75: // $Log$
76: //
|