org.aspectj/tests/new/options11/Aspect.java

43 lines
1.1 KiB
Java
Raw Normal View History

2002-12-16 19:51:06 +01:00
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 {
2003-01-15 03:03:25 +01:00
public pointcut targetJoinPoints() :
2002-12-16 19:51:06 +01:00
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;
2002-12-16 19:51:06 +01:00
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");
}
}
}