diff options
author | acolyer <acolyer> | 2005-02-17 12:58:24 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-02-17 12:58:24 +0000 |
commit | b4574b90b2db6cdae830e702825d86957447c3b9 (patch) | |
tree | d93001dbf1804933f64350dbd52bc1ced5402e7c /tests | |
parent | db5e1868bb553bad01441e70db166ac4429de2f2 (diff) | |
download | aspectj-b4574b90b2db6cdae830e702825d86957447c3b9.tar.gz aspectj-b4574b90b2db6cdae830e702825d86957447c3b9.zip |
support for annotations on ITDs, and declare annotation
Diffstat (limited to 'tests')
12 files changed, 294 insertions, 1 deletions
diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj new file mode 100644 index 000000000..03165b105 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj @@ -0,0 +1,23 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect { + + @FieldAnnotation int foo = 5; + + @MethodAnnotation int getFoo() { return foo; } + + @ConstructorAnnotation + public AnnotatedAspect() {} + +} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +}
\ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj new file mode 100644 index 000000000..d92dc33b1 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj @@ -0,0 +1,22 @@ +package a; + +@MethodAnnotation +public aspect AnnotatedAspect02 { + + @TypeAnnotation int goo; + + @FieldAnnotation int getGoo() { return goo; } + + @AnnotationAnnotation AnnotatedAspect02() { goo = 5; } + +} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +}
\ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj new file mode 100644 index 000000000..939285816 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj @@ -0,0 +1,26 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect03 { + + @FieldAnnotation int foo = 5; + + @FieldAnnotation private int ITDMe.goo = 3; + + @MethodAnnotation private int ITDMe.getGoo() { return goo; } + + @ConstructorAnnotation public ITDMe.new(int x) { goo = x; } + +} + +class ITDMe {} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +}
\ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj new file mode 100644 index 000000000..c19b057a3 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj @@ -0,0 +1,15 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect04 { + + @ConstructorAnnotation private int ITDMe.goo = 3; + + @FieldAnnotation private int ITDMe.getGoo() { return goo; } + + @TypeAnnotation public ITDMe.new(int x) { goo = x; } + + @MethodAnnotation int ITDMe.foo = 2; // known limitation - no warning +} + +class ITDMe {} diff --git a/tests/java5/annotations/aspectMembers/a/Annotations.java b/tests/java5/annotations/aspectMembers/a/Annotations.java new file mode 100644 index 000000000..21a0bb1a7 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/Annotations.java @@ -0,0 +1,29 @@ +package a; + +import java.lang.annotation.*; + +@Target(ElementType.ANNOTATION_TYPE) +@interface AnnotationAnnotation {} + +@Target(ElementType.CONSTRUCTOR) +@interface ConstructorAnnotation {} + +@Target(ElementType.FIELD) +@interface FieldAnnotation {} + +@Target(ElementType.LOCAL_VARIABLE) +@interface LocalVarAnnotation {} + +@Target(ElementType.METHOD) +@interface MethodAnnotation {} + +@Target(ElementType.PACKAGE) +@interface PackageAnnotation {} + +@Target(ElementType.PARAMETER) +@interface ParameterAnnotation {} + +@Target(ElementType.TYPE) +@interface TypeAnnotation {} + +@interface AnyAnnotation {}
\ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/Foo.java b/tests/java5/annotations/aspectMembers/a/Foo.java new file mode 100644 index 000000000..3fd621e26 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/Foo.java @@ -0,0 +1,17 @@ +package a; + +/** + * @author colyer + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +@TypeAnnotation +public class Foo { + + @FieldAnnotation int foo; + + @MethodAnnotation int getFoo() { return foo; } + + @MethodAnnotation int goo; +} diff --git a/tests/java5/annotations/declare/BasicParseTest.aj b/tests/java5/annotations/declare/BasicParseTest.aj new file mode 100644 index 000000000..5c3eca249 --- /dev/null +++ b/tests/java5/annotations/declare/BasicParseTest.aj @@ -0,0 +1,15 @@ +public aspect BasicParseTest { + + declare warning : set(* *) : "setting"; + + declare @field: * foo : @MyAnnotation; + + declare @method: * foo() : @MyAnnotation; + + declare @constructor: Foo*.new(..) : @MyAnnotation; + + declare @type: org.xyz..* : @MyAnnotation; + +} + +@interface MyAnnotation {}
\ No newline at end of file diff --git a/tests/java5/pseudoKeywords/MethodCalledAround.java b/tests/java5/pseudoKeywords/MethodCalledAround.java new file mode 100644 index 000000000..799b5b197 --- /dev/null +++ b/tests/java5/pseudoKeywords/MethodCalledAround.java @@ -0,0 +1,3 @@ +public class MethodCalledAround { + void around() { ; } +}
\ No newline at end of file diff --git a/tests/java5/pseudoKeywords/MethodCalledAroundAspect.java b/tests/java5/pseudoKeywords/MethodCalledAroundAspect.java new file mode 100644 index 000000000..d20bc7bce --- /dev/null +++ b/tests/java5/pseudoKeywords/MethodCalledAroundAspect.java @@ -0,0 +1,3 @@ +public aspect MethodCalledAroundAspect { + void around() { ; } +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 4d9aaba79..9f83d703f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -45,6 +45,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } } + public void test_aroundMethod() { + runTest("method called around in class"); + } + + public void test_aroundMethodAspect() { + runTest("method called around in aspect"); + } + public void test_ambiguousBindingsDetection() { runTest("Various kinds of ambiguous bindings"); } diff --git a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java index 1ac7ef36e..d242697bf 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java @@ -60,6 +60,48 @@ public class Annotations extends XMLBasedAjcTestCase { } } + public void testAnnotatedAnnotations() { + runTest("annotated annotations (@Target)"); + } + + public void testSimpleAnnotatedAspectMembers() { + runTest("simple annotated aspect members"); + } + + public void testAnnotatedAspectMembersWithWrongAnnotationType() { + runTest("simple annotated aspect members with bad target"); + } + + // more implementation work needed before this test passes +// public void testAnnotatedITDs() { +// runTest("annotated itds"); +// } + + public void testAnnotatedITDsWithWrongAnnotationType() { + runTest("annotated itds with bad target"); + } + +// these tests to be completed +// public void testAnnotatedAdvice() { +// runTest("annotated advice"); +// } +// +// public void testAnnotatedAdviceWithWrongAnnotationType() { +// runTest("annotated advice with bad target"); +// } +// +// public void testAnnotatedPointcut() { +// runTest("annotated pointcut"); +// } +// +// public void testAnnotatedDeclareStatements() { +// runTest("annotated declare statements"); +// } + + public void testBasicDeclareAnnotation() { + runTest("basic declare annotation parse test"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 22be0285e..9c787d7b4 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -26,6 +26,19 @@ </compile> <run class="C"/> </ajc-test> + + <ajc-test dir="java5/pseudoKeywords" + title="method called around in class"> + <compile files="MethodCalledAround.java"> + </compile> + </ajc-test> + + <ajc-test dir="java5/pseudoKeywords" + title="method called around in aspect"> + <compile files="MethodCalledAroundAspect.java"> + <message kind="error" line="2"/> + </compile> + </ajc-test> <ajc-test dir="decp" pr="80249" title="Order of types passed to compiler determines weaving behavior"> <compile files="A.java,B.java,AspectX.java"/> @@ -912,7 +925,84 @@ <message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:27) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)"/> </compile> </ajc-test> - + + <!-- ======================================================================================= --> + <!-- annotated aspect members --> + <!-- ======================================================================================= --> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated annotations (@Target)"> + <compile files="a/Annotations.java,a/Foo.java" options="-1.5"> + <message kind="error" line="16" text="The annotation @MethodAnnotation is disallowed for this location"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="simple annotated aspect members"> + <compile files="a/Annotations.java,a/AnnotatedAspect.aj" options="-1.5"> + <message kind="warning" line="4" text="annotated type"/> + <message kind="warning" line="6" text="annotated field"/> + <message kind="warning" line="8" text="annotated method"/> + <message kind="warning" line="11" text="annotated constructor"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="simple annotated aspect members with bad target"> + <compile files="a/Annotations.java,a/AnnotatedAspect02.aj" options="-1.5"> + <message kind="error" line="3" text="The annotation @MethodAnnotation is disallowed for this location"/> + <message kind="error" line="6" text="The annotation @TypeAnnotation is disallowed for this location"/> + <message kind="error" line="8" text="The annotation @FieldAnnotation is disallowed for this location"/> + <message kind="error" line="10" text="The annotation @AnnotationAnnotation is disallowed for this location"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated itds"> + <compile files="a/Annotations.java,a/AnnotatedAspect03.aj" options="-1.5"> + <message kind="warning" line="4" text="annotated type"/> + <message kind="warning" line="6" text="annotated field"/> + <message kind="warning" line="8" text="annotated field"/> + <message kind="warning" line="10" text="annotated method"/> + <message kind="warning" line="12" text="annotated constructor"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated itds with bad target"> + <compile files="a/Annotations.java,a/AnnotatedAspect04.aj" options="-1.5"> + <message kind="error" line="6" text="The annotation @ConstructorAnnotation is disallowed for this location"/> + <message kind="error" line="8" text="The annotation @FieldAnnotation is disallowed for this location"/> + <message kind="error" line="10" text="The annotation @TypeAnnotation is disallowed for this location"/> + <!-- known limitation... + <message kind="error" line="12" text="The annotation @MethodAnnotation is disallowed for this location"/> + --> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated advice"> + <compile files="a/Annotations.java,a/AnnotatedAspect05.aj" options="-1.5"> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated advice with bad target"> + <compile files="a/Annotations.java,a/AnnotatedAspect06.aj" options="-1.5"> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated pointcut"> + <compile files="a/Annotations.java,a/AnnotatedAspect07.aj" options="-1.5"> + </compile> + </ajc-test> + + <ajc-test dir="java5/annotations/aspectMembers" title="annotated declare statements"> + <compile files="a/Annotations.java,a/AnnotatedAspect08.aj" options="-1.5"> + </compile> + </ajc-test> + + <!-- ======================================================================================= --> + <!-- declare annotation --> + <!-- ======================================================================================= --> + + <ajc-test dir="java5/annotations/declare" title="basic declare annotation parse test"> + <compile files="BasicParseTest.aj" options="-1.5"> + </compile> + </ajc-test> </suite> |