From eabf8a19cab6071dedbdcf86747123126349f401 Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 10 Dec 2004 13:21:26 +0000 Subject: [PATCH] @within, @withincode tests --- .../annotations/thisOrtarget/DeclareEoW.java | 7 +++ .../within_code/TestingAnnotations.jar | Bin 0 -> 3486 bytes .../within_code/TestingAnnotations.java | 54 ++++++++++++++++++ .../within_code/WithinAndWithinCodeTests.java | 14 +++++ .../ajc150/AnnotationRuntimeTests.java | 26 ++++++++- 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 tests/java5/annotations/thisOrtarget/DeclareEoW.java create mode 100644 tests/java5/annotations/within_code/TestingAnnotations.jar create mode 100644 tests/java5/annotations/within_code/TestingAnnotations.java create mode 100644 tests/java5/annotations/within_code/WithinAndWithinCodeTests.java diff --git a/tests/java5/annotations/thisOrtarget/DeclareEoW.java b/tests/java5/annotations/thisOrtarget/DeclareEoW.java new file mode 100644 index 000000000..491e5400d --- /dev/null +++ b/tests/java5/annotations/thisOrtarget/DeclareEoW.java @@ -0,0 +1,7 @@ +public aspect DeclareEoW { + + declare warning : @this(@MyAnnotation) : "should give compilation error"; + + declare error : @target(@MyAnnotation) : "should give compilation error"; + +} \ No newline at end of file diff --git a/tests/java5/annotations/within_code/TestingAnnotations.jar b/tests/java5/annotations/within_code/TestingAnnotations.jar new file mode 100644 index 0000000000000000000000000000000000000000..769d7ec71c78f0d628233b0b97f1fa9fb9f7329d GIT binary patch literal 3486 zcma)92{@E%8y;h3>}xWz4@EOVN;x7L%-D@I#-F8g?AwIH*wQw(sH}yAvbBgvQnDS( zq_We5%ARGyDY8VQ^L>s#!}Xue|9sbXUEj?2-tWBk^Stl<++%Lc3KN2`16PK_MHL8B za6n)XQydYiXlRC4UTuUxSRv-dZ0z6&==w18e*_BwBYuEQv1W#N+%ck(DSp zQK^H+SP|3O+*V?-m%e{+)K|&KbdRBFhyOho$F+$a4B=f0Zm^Uw^rDL#aujJLoRT{x ztPnJ|YtsF*?~E_Y+Cre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ingAnnotations.java b/tests/java5/annotations/within_code/TestingAnnotations.java new file mode 100644 index 000000000..35eb49e12 --- /dev/null +++ b/tests/java5/annotations/within_code/TestingAnnotations.java @@ -0,0 +1,54 @@ +public class TestingAnnotations { + + public static void main(String[] args) { + + A a = new A(); + B b = new B(); + C c = new C(); + D d = new D(); + A reallyB = new B(); + C reallyD = new D(); + + a.doSomething(); + b.doSomething(); + c.doSomething(); + d.doSomething(); + reallyB.doSomething(); + reallyD.doSomething(); + } + +} + +@MyClassRetentionAnnotation +class A { + public void doSomething() {} +} + + +@MyAnnotation +class B extends A { + + @MyClassRetentionAnnotation public void doSomething(C c) { + c.doSomething(); + } +} + +@MyInheritableAnnotation +@MyAnnotation +class C { + public void doSomething() {} +} + +class D extends C { + 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 diff --git a/tests/java5/annotations/within_code/WithinAndWithinCodeTests.java b/tests/java5/annotations/within_code/WithinAndWithinCodeTests.java new file mode 100644 index 000000000..96ed0188d --- /dev/null +++ b/tests/java5/annotations/within_code/WithinAndWithinCodeTests.java @@ -0,0 +1,14 @@ +public aspect WithinAndWithinCodeTests { + + // should be two matches, L32 and L39 + declare warning : execution(* doSomething(..)) && @within(@MyAnnotation) + : "@within match on non-inherited annotation"; + + // one match on L39 + declare warning : execution(* doSomething(..)) && @within(@MyInheritableAnnotation) + : "@within match on inheritable annotation"; + + // one match on L32 + declare warning : call(* doSomething(..)) && @withincode(@MyClassRetentionAnnotation) + : "@withincode match"; +} \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java index 966bf884a..0d607b905 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationRuntimeTests.java @@ -45,15 +45,37 @@ public class AnnotationRuntimeTests extends TestUtils { public void test003_InheritableOrNot() { CompilationResult cR = binaryWeave("TestingAnnotations.jar","ThisOrTargetTests.aj",0,0); } - + + public void test004_CantUseinDecEoW() { + CompilationResult cR = binaryWeave("TestingAnnotations.jar","DeclareEoW.java",4,0); + List errors = new ArrayList(); + errors.add(new Message(3,"this() pointcut designator cannot be used in declare statement")); + errors.add(new Message(5,"target() pointcut designator cannot be used in declare statement")); + MessageSpec messageSpec = new MessageSpec(new ArrayList(), errors); + assertMessages(cR, messageSpec); + } + // TODO extra tests // run the result of test003 and validate matches (needs 1.5 runtime) // test inheritable annotation not present on type [should generate runtime test] - public void test004_ArgsSuite() { + public void test005_ArgsSuite() { baseDir = new File("../tests/java5/annotations/args"); CompilationResult cR = binaryWeave("TestingArgsAnnotations.jar","AtArgsAspect.java",0,0); // TODO need to RUN the result of these tests... System.out.println(cR); } + + public void test006_Within_Code() { + baseDir = new File("../tests/java5/annotations/within_code"); + CompilationResult cR = binaryWeave("TestingAnnotations.jar","WithinAndWithinCodeTests.java",0,5); + List warnings = new ArrayList(); + warnings.add(new Message(32,"@within match on non-inherited annotation")); + warnings.add(new Message(39,"@within match on non-inherited annotation")); + warnings.add(new Message(39,"@within match on inheritable annotation")); + warnings.add(new Message(43,"@within match on inheritable annotation")); + warnings.add(new Message(32,"@withincode match")); + MessageSpec mSpec = new MessageSpec(warnings,new ArrayList()); + assertMessages(cR,mSpec); + } } -- 2.39.5