Hello!
Thanks for
very fast response.
Alexander,
I'm
currently trying to generate an aspect based from annotation information
in java source code. The generated aspect is what I wanted to test. I
use it in my personal project for
android
A/B Test. The aspect class is really simple in general. What I
wanted to test are:
- the aspect compiles correctly
- the pointcut really
cut the method
Lets use this for sample:
Class Hello {
void String hello() {
return "hello";
}
void String aloha() {
return "aloha";
}
}
aspect
privileged HelloAspect {
around(Hello h): target(h),
execution(void Hello.hello()) {
if (SomeOtherClassSingleton.use()) {
proceed(h);
} else {
h.aloha();
}
}
}
I
want to check the aspect compiles correctly, and the method hello
return "aloha" if SomeOtherClassSingleton.use() returns true.
Sean,
That looks really
promising! Thank you, I was also searching in SO, but maybe my query
isn't good enough or the question still not popular enough and beaten by
Spring question.
I have tried your class, but I got this error when
running the test (I modified the class so the info can be accessed when
calling compile method):
directory classpath entry does not exist:
C:\Program Files\Java\jdk1.6.0_38\jre\lib\sunrsasign.jar
directory classpath entry does
not exist: C:\Program
Files\Java\jdk1.6.0_38\jre\lib\modules\jdk.boot.jar
zipfile classpath entry does not exist:
C:\Program Files\Java\jdk1.6.0_38\jre\classes
Pipelining compilation
compiling /path/to/aspect.aj
compiling /path/to/Hello.java
Compiler took 507ms
and then the result return Result.ERROR. Do
you have any idea?
Thanks!