diff options
author | acolyer <acolyer> | 2004-12-10 11:26:37 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-12-10 11:26:37 +0000 |
commit | 9380b983d27b392777788c754cfdc27691d52032 (patch) | |
tree | 91e7d28c30f01320a53a76ecfa4331a77f7a03eb /tests/java5/annotations | |
parent | af27e608a6638052271a7014c02c60b0c837d43b (diff) | |
download | aspectj-9380b983d27b392777788c754cfdc27691d52032.tar.gz aspectj-9380b983d27b392777788c754cfdc27691d52032.zip |
testing for @args
Diffstat (limited to 'tests/java5/annotations')
-rw-r--r-- | tests/java5/annotations/args/AtArgsAspect.java | 125 | ||||
-rw-r--r-- | tests/java5/annotations/args/TestingArgsAnnotations.jar | bin | 0 -> 4228 bytes | |||
-rw-r--r-- | tests/java5/annotations/args/TestingArgsAnnotations.java | 84 |
3 files changed, 209 insertions, 0 deletions
diff --git a/tests/java5/annotations/args/AtArgsAspect.java b/tests/java5/annotations/args/AtArgsAspect.java new file mode 100644 index 000000000..5a5c8a4f7 --- /dev/null +++ b/tests/java5/annotations/args/AtArgsAspect.java @@ -0,0 +1,125 @@ +public aspect AtArgsAspect { + + + pointcut myMethod() : execution(* myMethod(..)); + + // Exact number of args + // test 0 + before() : myMethod() && @args(*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // One too few + // test 1 + before() : myMethod() && @args(*,*,*,*) { + System.out.print("@args(*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*) { + System.out.print("@args(*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // One too many + // test 2 + before() : myMethod() && @args(*,*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Exact number of args + ellipsis + // test 3 + before() : myMethod() && @args(*,*,..,*,*,*) { + System.out.print("@args(*,*,..,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,..,*,*,*) { + System.out.print("@args(*,*,..,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Too few + ellipsis + // test 4 + before() : myMethod() && @args(*,*,*,..) { + System.out.print("@args(*,*,*,..): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,..) { + System.out.print("@args(*,*,*,..): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Now we get to test some annotations! + + // Non-inherited + // test 5 + before() : myMethod() && @args(@MyAnnotation,..) { + System.out.print("@args(@MyAnnotation,..): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,..) { + System.out.print("@args(@MyAnnotation,..): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 6 + before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,*) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,*) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 7 + before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Inherited + // test 8 + before() : myMethod() && @args(..,@MyInheritableAnnotation,*) { + System.out.print("@args(..,@MyInheritableAnnotation,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,*) { + System.out.print("@args(..,@MyInheritableAnnotation,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 9 + before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 10 + before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + +}
\ No newline at end of file diff --git a/tests/java5/annotations/args/TestingArgsAnnotations.jar b/tests/java5/annotations/args/TestingArgsAnnotations.jar Binary files differnew file mode 100644 index 000000000..8068f1f45 --- /dev/null +++ b/tests/java5/annotations/args/TestingArgsAnnotations.jar diff --git a/tests/java5/annotations/args/TestingArgsAnnotations.java b/tests/java5/annotations/args/TestingArgsAnnotations.java new file mode 100644 index 000000000..a6cb252ce --- /dev/null +++ b/tests/java5/annotations/args/TestingArgsAnnotations.java @@ -0,0 +1,84 @@ +public class TestingArgsAnnotations { + + private static boolean[] expected; + private static int index = 0; + + private static void setExpectedMatches(boolean[] matches) { + System.out.println(); + System.out.println("New Test Run"); + System.out.println("==============================="); + expected = matches; + index = 0; + } + + public static boolean expected() { + System.out.print("Test " + index + ": "); + return expected[index++]; + } + + public static void main(String[] args) { + A a = new A(); + B b = new B(); + C c = new C(); + D d = new D(); + E e = new E(); + + A reallyB = new B(); + C reallyD = new D(); + D reallyE = new E(); + + // now make some calls... + setExpectedMatches(new boolean[] {true,false,false,true,true,false,false,false,true,true,false}); + myMethod(a,b,c,d,e); + + setExpectedMatches(new boolean[] {true,false,false,true,true,true,true,false,true,true,false}); + myMethod(b,b,c,d,e); + + setExpectedMatches(new boolean[] {true,false,false,true,true,true,true,false,true,true,false}); + myMethod(reallyB,b,c,d,e); + + setExpectedMatches(new boolean[] {true,false,false,true,true,false,false,false,true,true,true}); + myMethod(a,b,reallyD,d,e); + + setExpectedMatches(new boolean[] {true,false,false,true,true,false,false,false,true,true,true}); + myMethod(a,b,reallyD,reallyE,e); + } + + public static void myMethod(A a, B b, C c, D d, E e) { + return; + } + +} + +@MyClassRetentionAnnotation +class A { + public void doSomething() {} +} + + +@MyAnnotation +class B extends A { + public void doSomething() {} +} + +class C {} + +@MyInheritableAnnotation +@MyAnnotation +class D extends C { + public void doSomething() {} +} + +class E extends D { + public void doSomething() {} +} + + +@interface MyClassRetentionAnnotation {} + +@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME) +@interface MyAnnotation {} + +@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME) +@java.lang.annotation.Inherited +@interface MyInheritableAnnotation {}
\ No newline at end of file |