diff options
Diffstat (limited to 'tests/java5/ataspectj/coverage')
44 files changed, 498 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/coverage/Test001.java b/tests/java5/ataspectj/coverage/Test001.java new file mode 100644 index 000000000..f5f43f54d --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test001.java @@ -0,0 +1,23 @@ +//"@Aspect extending Aspect" + +// This ought to be possible, need to see where the 'can not extend' message +// is coming from and see if you can check for attributes at that point. +// not sure what would happen if these pieces were compiled separately - +// suspect it would be OK if javac is used for class C but not if ajc is used. + +import org.aspectj.lang.annotation.*; + +abstract aspect B{ + abstract void say(); +} + +@Aspect +class C extends B{ + + void say(){ } + + public static void Main(String[] args){ + C thing = new C(); + thing.say(); + } +} diff --git a/tests/java5/ataspectj/coverage/Test002.java b/tests/java5/ataspectj/coverage/Test002.java new file mode 100644 index 000000000..59228a700 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test002.java @@ -0,0 +1,15 @@ +//"@Aspect with codestyle pointcut" + +// 1. test name needs changing to @Aspect with codestyle advice declaration +// Probably nothing can be done here because it is at parse time that we +// decide this is a class so can't contain advice - at parse time we probably +// can't go digging round for annotations on the type decl. +// Documented limitation? + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + before(): call(* *(..)) { + } +} diff --git a/tests/java5/ataspectj/coverage/Test003.java b/tests/java5/ataspectj/coverage/Test003.java new file mode 100644 index 000000000..12a526046 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test003.java @@ -0,0 +1,9 @@ +// "Codestyle Aspect with @Pointcut" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Pointcut("call(* *.*(..))") + void someCall(int aNumber){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test004.java b/tests/java5/ataspectj/coverage/Test004.java new file mode 100644 index 000000000..b156139ba --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test004.java @@ -0,0 +1,11 @@ +// "@Pointcut declared on codestyle advice" + +// Should have got a message about not allowing @Pointcut on advice + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Pointcut("call(* *.*(..))") + before(): call(* *(..)) { + } +} diff --git a/tests/java5/ataspectj/coverage/Test005.java b/tests/java5/ataspectj/coverage/Test005.java new file mode 100644 index 000000000..7671e5db1 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test005.java @@ -0,0 +1,10 @@ +// "@Aspect class extending @Aspect class" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ +} +@Aspect +class B extends A{ +} diff --git a/tests/java5/ataspectj/coverage/Test006.java b/tests/java5/ataspectj/coverage/Test006.java new file mode 100644 index 000000000..4e0ad77a6 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test006.java @@ -0,0 +1,14 @@ +// "class with @Before extending @Aspect class" + +// shouldn't allow advice in a non-aspect type + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ +} +class B extends A{ + @Before("call(* org..*(..))") + public void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test007.java b/tests/java5/ataspectj/coverage/Test007.java new file mode 100644 index 000000000..9e68c2f0e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test007.java @@ -0,0 +1,11 @@ +// "@Before declared on advice" + +// should be an error, check attr is on an ajc$ method and barf + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("call(* org..*(..))") + before(): call(* *(..)) { + } +} diff --git a/tests/java5/ataspectj/coverage/Test008.java b/tests/java5/ataspectj/coverage/Test008.java new file mode 100644 index 000000000..54c3c5f14 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test008.java @@ -0,0 +1,13 @@ +// "@Pointcut not returning void" + + +import org.aspectj.lang.annotation.*; + + +@Aspect +class A{ + @Pointcut("call(* *.*(..))") + int someCall(){ + return 42; + } +} diff --git a/tests/java5/ataspectj/coverage/Test009.java b/tests/java5/ataspectj/coverage/Test009.java new file mode 100644 index 000000000..837560e7f --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test009.java @@ -0,0 +1,10 @@ +// "@Pointcut on @Aspect class constructor" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Pointcut("call(* *.*(..))") + A(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test010.java b/tests/java5/ataspectj/coverage/Test010.java new file mode 100644 index 000000000..182c2f1fe --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test010.java @@ -0,0 +1,7 @@ +// "@Aspect on interface" + +import org.aspectj.lang.annotation.*; + +@Aspect +interface A{ +} diff --git a/tests/java5/ataspectj/coverage/Test011.java b/tests/java5/ataspectj/coverage/Test011.java new file mode 100644 index 000000000..ab4c427e3 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test011.java @@ -0,0 +1,11 @@ +// "@Pointcut on non-aspect class method" + +// I dont think this test is valid, you can have pointcuts in classes + +import org.aspectj.lang.annotation.*; + +class A{ + @Pointcut("call(* *.*(..))") + void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test012.java b/tests/java5/ataspectj/coverage/Test012.java new file mode 100644 index 000000000..786015b32 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test012.java @@ -0,0 +1,9 @@ +// "@Before on non-aspect class method" + +import org.aspectj.lang.annotation.*; + +class A{ + @Before("") + public void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test013.java b/tests/java5/ataspectj/coverage/Test013.java new file mode 100644 index 000000000..d56c6e0bb --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test013.java @@ -0,0 +1,9 @@ +// "@Pointcut on Interface method" + + +import org.aspectj.lang.annotation.*; + +interface A{ + @Pointcut("call(* *.*(..))") + void someCall(); +} diff --git a/tests/java5/ataspectj/coverage/Test014.java b/tests/java5/ataspectj/coverage/Test014.java new file mode 100644 index 000000000..99e39e475 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test014.java @@ -0,0 +1,11 @@ +// "@Pointcut with garbage string" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Pointcut("call\n\n\n\n\n\n\n\n\n\n\n%dwdwudwdwbuill817pe;][{ +grgrgnjk78877&&<:{{{+=``\") + void somecall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test015.java b/tests/java5/ataspectj/coverage/Test015.java new file mode 100644 index 000000000..b59c62bdd --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test015.java @@ -0,0 +1,11 @@ +// "@Pointcut with non-empty method body" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Pointcut("call(* *.*(..))") + void someCall(){ + System.out.println("whoops"); + } +} diff --git a/tests/java5/ataspectj/coverage/Test016.java b/tests/java5/ataspectj/coverage/Test016.java new file mode 100644 index 000000000..eccddda1a --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test016.java @@ -0,0 +1,9 @@ +// "@Pointcut with throws clause" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Pointcut("call(* *.*(..))") + void someCall() throws Exception {} +} diff --git a/tests/java5/ataspectj/coverage/Test017.java b/tests/java5/ataspectj/coverage/Test017.java new file mode 100644 index 000000000..6cb088849 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test017.java @@ -0,0 +1,7 @@ +// "@Aspect used badly" + +import org.aspectj.lang.annotation.*; + +@Aspect{ + void a(){} +} diff --git a/tests/java5/ataspectj/coverage/Test018.java b/tests/java5/ataspectj/coverage/Test018.java new file mode 100644 index 000000000..f9994fec9 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test018.java @@ -0,0 +1,10 @@ +// "@Before declared on @Aspect class constructor" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Before("call(* org..*(..))") + A(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test019.java b/tests/java5/ataspectj/coverage/Test019.java new file mode 100644 index 000000000..b236cde6a --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test019.java @@ -0,0 +1,9 @@ +// "@AfterReturning with wrong number of args" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @AfterReturning(value="call(* *..*(..))",returning="f") + public void itsAFoo(Object f, int x) { + } +} diff --git a/tests/java5/ataspectj/coverage/Test020.java b/tests/java5/ataspectj/coverage/Test020.java new file mode 100644 index 000000000..1f08e61f0 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test020.java @@ -0,0 +1,9 @@ +// "@Before on non-public method" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("call(* org..*(..))") + private void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test021.java b/tests/java5/ataspectj/coverage/Test021.java new file mode 100644 index 000000000..63bf82e10 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test021.java @@ -0,0 +1,10 @@ +// "@Before on method not returning void" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("call(* org..*(..))") + public int someCall(){ + return 42; + } +} diff --git a/tests/java5/ataspectj/coverage/Test022.java b/tests/java5/ataspectj/coverage/Test022.java new file mode 100644 index 000000000..ab71677ad --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test022.java @@ -0,0 +1,9 @@ +// "@Pointcut with wrong number of args" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Pointcut("call(* *.*(..))") + void someCall(int x) {} +} diff --git a/tests/java5/ataspectj/coverage/Test023.java b/tests/java5/ataspectj/coverage/Test023.java new file mode 100644 index 000000000..bec82690a --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test023.java @@ -0,0 +1,13 @@ +// "@DeclareParents with interface extending interface" + +import org.aspectj.lang.annotation.*; + +class A{ +} +interface D{ +} +aspect B{ + @DeclareParents("A") + interface C extends D{ + } +} diff --git a/tests/java5/ataspectj/coverage/Test024.java b/tests/java5/ataspectj/coverage/Test024.java new file mode 100644 index 000000000..c011bee8e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test024.java @@ -0,0 +1,15 @@ +// "@DeclareParents implementing more than one interface" + +import org.aspectj.lang.annotation.*; + +class A{ +} +interface D{ +} +interface E{ +} +Aspect B{ + @DeclareParents("A") + class C implements D, E{ + } +} diff --git a/tests/java5/ataspectj/coverage/Test025.java b/tests/java5/ataspectj/coverage/Test025.java new file mode 100644 index 000000000..0967b4f9e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test025.java @@ -0,0 +1,11 @@ +// "@DeclareParents used outside of an Aspect" + +import org.aspectj.lang.annotation.*; + +class A{ +} +interface D{ +} +@DeclareParents("A") +class C implements D{ +} diff --git a/tests/java5/ataspectj/coverage/Test026.java b/tests/java5/ataspectj/coverage/Test026.java new file mode 100644 index 000000000..69fc3ebd7 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test026.java @@ -0,0 +1,14 @@ +// "@DeclareParents on an @Aspect" + +import org.aspectj.lang.annotation.*; + +class A{ +} +interface D{ +} +aspect B{ + @Aspect + @DeclareParents("A") + class C implements D{ + } +} diff --git a/tests/java5/ataspectj/coverage/Test027.java b/tests/java5/ataspectj/coverage/Test027.java new file mode 100644 index 000000000..c867711f5 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test027.java @@ -0,0 +1,15 @@ +// "@DeclareParents on an @Aspect with @DeclarePrecidence" + +import org.aspectj.lang.annotation.*; + +class A{ +} +interface D{ +} +aspect B{ + @DeclareParents("A") + @Aspect + @DeclarePrecidence("") + class C implements D{ + } +} diff --git a/tests/java5/ataspectj/coverage/Test028.java b/tests/java5/ataspectj/coverage/Test028.java new file mode 100644 index 000000000..94c06766c --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test028.java @@ -0,0 +1,8 @@ +// "@DeclareWarning with a non-final String" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @DeclareWarning("within(org..*)") + static String msg = "Let this be a warning to you"; +} diff --git a/tests/java5/ataspectj/coverage/Test029.java b/tests/java5/ataspectj/coverage/Test029.java new file mode 100644 index 000000000..35d22937e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test029.java @@ -0,0 +1,8 @@ +// "@DeclareWarning with a static final Object (that is a String)" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @DeclareWarning("within(org..*)") + static final Object msg = new String("woo"); +} diff --git a/tests/java5/ataspectj/coverage/Test030.java b/tests/java5/ataspectj/coverage/Test030.java new file mode 100644 index 000000000..92bfe7da7 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test030.java @@ -0,0 +1,8 @@ +// "@DeclareWarning with a static final Integer" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @DeclareWarning("within(org..*)") + static final Integer msg = new Integer(22378008); +} diff --git a/tests/java5/ataspectj/coverage/Test031.java b/tests/java5/ataspectj/coverage/Test031.java new file mode 100644 index 000000000..c598c406e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test031.java @@ -0,0 +1,14 @@ +// "@Around given an extension of ProceedingJoinPoint" + +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.ProceedingJoinPoint; + + +interface B extends ProceedingJoinPoint{ +} +aspect A{ + @Around("call(* *.*(..))") + public Object doNothing(B thisJoinPoint) { + return thisJoinPoint.proceed(); + } +} diff --git a/tests/java5/ataspectj/coverage/Test032.java b/tests/java5/ataspectj/coverage/Test032.java new file mode 100644 index 000000000..09a45a205 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test032.java @@ -0,0 +1,16 @@ +// "calling @Before advice explicitly as a method" + +import org.aspectj.lang.annotation.*; + +@Aspect +class A{ + @Before("call(* *.*(..))") + public void someCall(){ + } +} +class B{ + public static void main(String[] args){ + A a = new A(); + a.someCall(); + } +} diff --git a/tests/java5/ataspectj/coverage/Test033.java b/tests/java5/ataspectj/coverage/Test033.java new file mode 100644 index 000000000..5beab81f6 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test033.java @@ -0,0 +1,8 @@ +// "@Before on Interface method" + +import org.aspectj.lang.annotation.*; + +interface A{ + @Before("call(* *.*(..))") + void someCall(); +} diff --git a/tests/java5/ataspectj/coverage/Test034.java b/tests/java5/ataspectj/coverage/Test034.java new file mode 100644 index 000000000..bf0103713 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test034.java @@ -0,0 +1,7 @@ +// "@Aspect Aspect double declaration" + +import org.aspectj.lang.annotation.*; + +@Aspect +aspect A { +} diff --git a/tests/java5/ataspectj/coverage/Test035.java b/tests/java5/ataspectj/coverage/Test035.java new file mode 100644 index 000000000..8d5e3fa47 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test035.java @@ -0,0 +1,10 @@ +// "@Before and @After on one method" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("call(* *.*(..))") + @After("call(* *.*(..))") + public void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test036.java b/tests/java5/ataspectj/coverage/Test036.java new file mode 100644 index 000000000..a6ce067a0 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test036.java @@ -0,0 +1,10 @@ +//"@Before twice on one method" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("call(* *.*(..))") + @Before("call(* *.*(..))") + public void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test037.java b/tests/java5/ataspectj/coverage/Test037.java new file mode 100644 index 000000000..cfce50288 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test037.java @@ -0,0 +1,9 @@ +//"@Before advice with empty string" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @Before("") // this should compile I think, it's just Before advice for no pointcut + public void someCall(){ + } +} diff --git a/tests/java5/ataspectj/coverage/Test038.java b/tests/java5/ataspectj/coverage/Test038.java new file mode 100644 index 000000000..441788c9c --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test038.java @@ -0,0 +1,6 @@ +// "isPrivileged=truu misspelling" + +import org.aspectj.lang.annotation.*; + +@Aspect(isPrivileged=truu) +class Foo {} diff --git a/tests/java5/ataspectj/coverage/Test039.java b/tests/java5/ataspectj/coverage/Test039.java new file mode 100644 index 000000000..0c20c9116 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test039.java @@ -0,0 +1,14 @@ +// "@Pointcut with an empty string" + +import org.aspectj.lang.annotation.*; + +@Aspect +class Foo { + + @Pointcut("call(* java.util.List.*(..))") // must qualify + void listOperation() {} + + @Pointcut("") // should compile, I think - just matches no joinPoints + void anyUtilityCall() {} + +} diff --git a/tests/java5/ataspectj/coverage/Test040.java b/tests/java5/ataspectj/coverage/Test040.java new file mode 100644 index 000000000..038ebff1e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test040.java @@ -0,0 +1,12 @@ +// "@Before with && in string" + +import org.aspectj.lang.annotation.*; + +class Foo{ +} +aspect A{ + @Before("call(* org.aspectprogrammer..*(..)) && this(Foo)") + public void callFromFoo() { + System.out.println("Call from Foo"); + } +} diff --git a/tests/java5/ataspectj/coverage/Test041.java b/tests/java5/ataspectj/coverage/Test041.java new file mode 100644 index 000000000..28b1562d4 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test041.java @@ -0,0 +1,10 @@ +// "@AdviceName given an empty string" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @AdviceName("") + before() : call(* org.aspectprogrammer..*(..)) { + System.out.println("Call from Foo"); + } +} diff --git a/tests/java5/ataspectj/coverage/Test042.java b/tests/java5/ataspectj/coverage/Test042.java new file mode 100644 index 000000000..fd19f3e3e --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test042.java @@ -0,0 +1,11 @@ +//"@AdviceName used on @Before advice" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @AdviceName("callFromFoo") + @Before("call(* org.aspectprogrammer..*(..))") + public void callFromFoo() { + System.out.println("Call from Foo"); + } +} diff --git a/tests/java5/ataspectj/coverage/Test043.java b/tests/java5/ataspectj/coverage/Test043.java new file mode 100644 index 000000000..f6abcc242 --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test043.java @@ -0,0 +1,27 @@ +//"The Moody example" + +import org.aspectj.lang.annotation.*; + +class Mood{ +} +@Aspect +class MoodIndicator { + + public interface Moody { + Mood getMood(); + }; + + @DeclareParents("org.xzy..*") + class MoodyImpl implements Moody { + private Mood mood = new Mood(); + + public Mood getMood() { + return mood; + } + } + + @Before("execution(* *.*(..)) && this(m)") + void feelingMoody(Moody m) { + System.out.println("I'm feeling " + m.getMood()); + } +} diff --git a/tests/java5/ataspectj/coverage/Test044.java b/tests/java5/ataspectj/coverage/Test044.java new file mode 100644 index 000000000..16fceb21c --- /dev/null +++ b/tests/java5/ataspectj/coverage/Test044.java @@ -0,0 +1,15 @@ +// "@DeclareWarning" + +import org.aspectj.lang.annotation.*; + +aspect A{ + @DeclareWarning("call(* *..warnedCall())") + static final String aMessage = "This call is warned"; + + void warnedCall(){ + } + + public static void main(String [] args){ + warnedCall(); + } +} |