blob: 325167f3083afa758b0884d0c6f1a730279fbf9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import org.aspectj.testing.Tester;
import org.aspectj.lang.JoinPoint;
import library1.Library1;
import library2.Library2;
/** extend abstract, and implement needed */
aspect AnotherAspect extends Library2 {
public pointcut targetJoinPoints() :
execution(public static void Main.main(..));
protected String renderId(JoinPoint jp) {
String result = super.renderId(jp);
return result + " - ok";
}
}
class Testing {
static aspect Init {
declare precedence : Init, Library1, AnotherAspect;
before() : AnotherAspect.targetJoinPoints() {
Main.i = 1;
Tester.expectEvent("before main");
Tester.expectEvent("after main");
Tester.expectEvent("after 2 main - ok");
Tester.expectEvent("before 2 main - ok");
Tester.expectEvent("before run");
}
after () returning : AnotherAspect.targetJoinPoints() {
Tester.checkAllEvents();
}
before() : call(void run()) {
Tester.event("before run");
}
}
}
|