summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-10-03 16:17:15 +0000
committeracolyer <acolyer>2005-10-03 16:17:15 +0000
commit0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade (patch)
tree85dda17da70b10b31b422853d1323421a82b3a21 /tests
parentc86fa6de889e521ebe8224d1a7579269c53ac357 (diff)
downloadaspectj-0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade.tar.gz
aspectj-0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade.zip
completes all of the MAP bar ITDs
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs150/pr101047.aj30
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclareAnnotationTest.aj77
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclareParentsTest.aj56
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclareParentsTestAdvanced.aj39
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj35
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclareSoftTest.aj22
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java20
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml29
9 files changed, 309 insertions, 1 deletions
diff --git a/tests/bugs150/pr101047.aj b/tests/bugs150/pr101047.aj
new file mode 100644
index 000000000..f64bd6ebc
--- /dev/null
+++ b/tests/bugs150/pr101047.aj
@@ -0,0 +1,30 @@
+aspect Test {
+ before() : ( execution(* Foo.foo(..) ) ) {
+ System.out.println("before");
+
+ }
+}
+
+class Foo {
+ private String myString = "A String";
+
+ public static void main(String[] args) {
+ new Foo().foo();
+ }
+
+ private void foo() {
+ String myLocal = myString;
+
+ if (myLocal.endsWith("X")) {
+ String local1 = "local1";
+ System.out.println(local1);
+ } else if (myLocal.endsWith("Y")) {
+ String local2 = "local2";
+ System.out.println(local2);
+ } else {
+ String local1 = "local3";
+ System.out.println(local1);
+ }
+ }
+}
+
diff --git a/tests/java5/ataspectj/annotationGen/DeclareAnnotationTest.aj b/tests/java5/ataspectj/annotationGen/DeclareAnnotationTest.aj
new file mode 100644
index 000000000..0c3e4608d
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclareAnnotationTest.aj
@@ -0,0 +1,77 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+public aspect DeclareAnnotationTest {
+
+ declare @type : a.b.c..* : @MyAnnotation("ady 1");
+
+ declare @method : * *(String) : @MyAnnotation("ady 2");
+
+ declare @field : java.io.Serializable+ * : @MyClassRetentionAnnotation("ady 3");
+
+ declare @constructor : new(String,..) : @MyAnnotation;
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<DeclareAnnotationTest> myType = AjTypeSystem.getAjType(DeclareAnnotationTest.class);
+ DeclareAnnotation[] decAs = myType.getDeclareAnnotations();
+ if (decAs.length != 4) throw new RuntimeException("Expecting 4 members, got " + decAs.length);
+ // should be in declaration order...
+ checkAtType(decAs[0]);
+ checkAtMethod(decAs[1]);
+ checkAtField(decAs[2]);
+ checkAtConstructor(decAs[3]);
+ }
+
+
+ private static void checkAtType(DeclareAnnotation da) {
+ if (da.getKind() != DeclareAnnotation.Kind.Type) throw new RuntimeException("expecting @type");
+ if (da.getSignaturePattern() != null) throw new RuntimeException("not expecting a signature pattern");
+ if (!da.getTypePattern().asString().equals("a.b.c..*")) throw new RuntimeException("expecting 'a.b.c..*' but got '" + da.getTypePattern().asString() + "'");
+ if (da.getDeclaringType().getJavaClass() != DeclareAnnotationTest.class) throw new RuntimeException("bad declaring type: " + da.getDeclaringType());
+ MyAnnotation ma = (MyAnnotation) da.getAnnotation();
+ if (!ma.value().equals("ady 1")) throw new RuntimeException("bad value: " + ma.value());
+ if (!da.getAnnotationAsText().equals("@MyAnnotation(\"ady 1\")")) throw new RuntimeException("bad annotation text: " + da.getAnnotationAsText());
+ }
+
+ private static void checkAtMethod(DeclareAnnotation da) {
+ if (da.getKind() != DeclareAnnotation.Kind.Method) throw new RuntimeException("expecting @method");
+ if (da.getTypePattern() != null) throw new RuntimeException("not expecting a type pattern");
+ if (!da.getSignaturePattern().asString().equals("* *(java.lang.String)")) throw new RuntimeException("expecting '* *(java.lang.String)' but got '" + da.getSignaturePattern().asString() + "'");
+ if (da.getDeclaringType().getJavaClass() != DeclareAnnotationTest.class) throw new RuntimeException("bad declaring type: " + da.getDeclaringType());
+ MyAnnotation ma = (MyAnnotation) da.getAnnotation();
+ if (!ma.value().equals("ady 2")) throw new RuntimeException("bad value: " + ma.value());
+ if (!da.getAnnotationAsText().equals("@MyAnnotation(\"ady 2\")")) throw new RuntimeException("bad annotation text: " + da.getAnnotationAsText());
+ }
+
+ private static void checkAtField(DeclareAnnotation da) {
+ if (da.getKind() != DeclareAnnotation.Kind.Field) throw new RuntimeException("expecting @field");
+ if (da.getTypePattern() != null) throw new RuntimeException("not expecting a type pattern");
+ if (!da.getSignaturePattern().asString().equals("java.io.Serializable+ *")) throw new RuntimeException("expecting 'java.io.Serializable+ *' but got '" + da.getSignaturePattern().asString() + "'");
+ if (da.getDeclaringType().getJavaClass() != DeclareAnnotationTest.class) throw new RuntimeException("bad declaring type: " + da.getDeclaringType());
+ if (da.getAnnotation() != null) throw new RuntimeException("expecting null annotation, but got " + da.getAnnotation());
+ if (!da.getAnnotationAsText().equals("@MyClassRetentionAnnotation(\"ady 3\")")) throw new RuntimeException("bad annotation text: " + da.getAnnotationAsText());
+ }
+
+ private static void checkAtConstructor(DeclareAnnotation da) {
+ if (da.getKind() != DeclareAnnotation.Kind.Constructor) throw new RuntimeException("expecting @constructor");
+ if (da.getTypePattern() != null) throw new RuntimeException("not expecting a type pattern");
+ if (!da.getSignaturePattern().asString().equals("new(java.lang.String, ..)")) throw new RuntimeException("expecting 'new(java.lang.String,..)' but got '" + da.getSignaturePattern().asString() + "'");
+ if (da.getDeclaringType().getJavaClass() != DeclareAnnotationTest.class) throw new RuntimeException("bad declaring type: " + da.getDeclaringType());
+ MyAnnotation ma = (MyAnnotation) da.getAnnotation();
+ if (!ma.value().equals("some value")) throw new RuntimeException("bad value: " + ma.value());
+ if (!da.getAnnotationAsText().equals("@MyAnnotation")) throw new RuntimeException("bad annotation text: " + da.getAnnotationAsText());
+ }
+
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface MyAnnotation {
+
+ String value() default "some value";
+
+}
+
+@interface MyClassRetentionAnnotation {
+ String value();
+}
diff --git a/tests/java5/ataspectj/annotationGen/DeclareParentsTest.aj b/tests/java5/ataspectj/annotationGen/DeclareParentsTest.aj
new file mode 100644
index 000000000..0a0da6769
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclareParentsTest.aj
@@ -0,0 +1,56 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+public aspect DeclareParentsTest {
+
+ declare parents : B || C extends A;
+
+ declare parents : A implements I,J;
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<DeclareParentsTest> myType = AjTypeSystem.getAjType(DeclareParentsTest.class);
+ DeclareParents[] decPs = myType.getDeclareParents();
+ if (decPs.length != 2) throw new RuntimeException("Expecting 2 members, got " + decPs.length);
+ if (decPs[0].isExtends()) {
+ checkExtends(decPs[0]);
+ checkImplements(decPs[1]);
+ } else {
+ checkExtends(decPs[1]);
+ checkImplements(decPs[0]);
+ }
+ }
+
+ private static void checkExtends(DeclareParents extendsDecP) throws ClassNotFoundException {
+ if (!extendsDecP.isExtends()) throw new RuntimeException("Should be extends");
+ AjType declaring = extendsDecP.getDeclaringType();
+ if (declaring.getJavaClass() != DeclareParentsTest.class) throw new RuntimeException("wrong declaring type");
+ TypePattern tp = extendsDecP.getTargetTypesPattern();
+ if (!tp.asString().equals("(B || C)")) throw new RuntimeException("expecting (B || C) but got '" + tp.asString() + "'");
+ Type[] parentTypes = extendsDecP.getParentTypes();
+ if (parentTypes.length != 1) throw new RuntimeException("expecting 1 parent type");
+ if (((AjType<?>)parentTypes[0]).getJavaClass() != A.class) throw new RuntimeException("expecting parent to be A but was '" + ((AjType<?>)parentTypes[0]).getName() + "'");
+ }
+
+ private static void checkImplements(DeclareParents implementsDecP) throws ClassNotFoundException {
+ if (!implementsDecP.isImplements()) throw new RuntimeException("Should be implements");
+ AjType declaring = implementsDecP.getDeclaringType();
+ if (declaring.getJavaClass() != DeclareParentsTest.class) throw new RuntimeException("wrong declaring type");
+ TypePattern tp = implementsDecP.getTargetTypesPattern();
+ if (!tp.asString().equals("A")) throw new RuntimeException("expecting A but got '" + tp.asString() + "'");
+ Type[] parentTypes = implementsDecP.getParentTypes();
+ if (parentTypes.length != 2) throw new RuntimeException("expecting 2 parent types");
+ if (((AjType<?>)parentTypes[0]).getJavaClass() != I.class) throw new RuntimeException("expecting parent to be I but was '" + ((AjType<?>)parentTypes[0]).getName() + "'");
+ if (((AjType<?>)parentTypes[1]).getJavaClass() != J.class) throw new RuntimeException("expecting parent to be J but was '" + ((AjType<?>)parentTypes[0]).getName() + "'");
+ }
+}
+
+
+class A {}
+
+class B {}
+
+class C {}
+
+interface I {}
+
+interface J {} \ No newline at end of file
diff --git a/tests/java5/ataspectj/annotationGen/DeclareParentsTestAdvanced.aj b/tests/java5/ataspectj/annotationGen/DeclareParentsTestAdvanced.aj
new file mode 100644
index 000000000..12d516e94
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclareParentsTestAdvanced.aj
@@ -0,0 +1,39 @@
+package a.b.c;
+
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+public class DeclareParentsTestAdvanced {
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<ConcreteAspect> aType = AjTypeSystem.getAjType(ConcreteAspect.class);
+ DeclareParents[] decPs = aType.getDeclareParents();
+ if (decPs.length != 1) throw new RuntimeException("should see decp from super");
+ DeclareParents dp = decPs[0];
+ if (!dp.isImplements()) throw new RuntimeException("Expecting implements");
+ if (dp.getDeclaringType().getJavaClass() != AbstractAspect.class) {
+ throw new RuntimeException("Expecting declaring class to be AbstractAspect");
+ }
+ TypePattern tp = dp.getTargetTypesPattern();
+ if (!tp.asString().equals("a.b.c.A")) {
+ throw new RuntimeException("expecting 'a.b.c.A' but was '" + tp.asString() + "'");
+ }
+ Type[] parents = dp.getParentTypes();
+ if (parents.length != 1) throw new RuntimeException("expecting 1 parent");
+ if (((AjType)parents[0]).getJavaClass() != B.class) {
+ throw new RuntimeException("expecting 'B' but was '" + parents[0].toString() + "'");
+ }
+ }
+}
+
+abstract aspect AbstractAspect {
+
+ declare parents : A implements B;
+
+}
+
+aspect ConcreteAspect extends AbstractAspect {}
+
+class A {}
+
+class B {} \ No newline at end of file
diff --git a/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj b/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj
new file mode 100644
index 000000000..d8cda81a1
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj
@@ -0,0 +1,35 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+@org.aspectj.lang.annotation.DeclarePrecedence("DeclarePrecedenceTest,*")
+public aspect DeclarePrecedenceTest {
+
+ declare precedence : org.xyz..*, org.abc..*;
+
+ declare precedence : org.abc..*, org.def..*;
+
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<DeclarePrecedenceTest> myType = AjTypeSystem.getAjType(DeclarePrecedenceTest.class);
+ DeclarePrecedence[] decPs = myType.getDeclarePrecedence();
+ if (decPs.length != 3) throw new RuntimeException("Expecting 3 members, got " + decPs.length);
+ for(int i = 0; i < decPs.length; i++) {
+ validateDecP(decPs[i]);
+ }
+ }
+
+ private static void validateDecP(DeclarePrecedence dp) {
+ TypePattern[] tps = dp.getPrecedenceOrder();
+ if (tps.length != 2) throw new RuntimeException("Expecting 2 type patterns, got " + tps.length);
+ if (tps[0].asString().equals("DeclarePrecedenceTest")) {
+ if (!tps[1].asString().equals("*")) throw new RuntimeException("Excepting '*', got '" + tps[1].asString() + "'");
+ } else if (tps[0].asString().equals("org.xyz..*")) {
+ if (!tps[1].asString().equals("org.abc..*")) throw new RuntimeException("Excepting 'org.abc..*', got '" + tps[1].asString() + "'");
+ } else if (tps[0].asString().equals("org.abc..*")) {
+ if (!tps[1].asString().equals("org.def..*")) throw new RuntimeException("Excepting 'org.def..*', got '" + tps[1].asString() + "'");
+ } else {
+ throw new RuntimeException("Unexpected type pattern: " + tps[0].asString());
+ }
+ }
+
+}
diff --git a/tests/java5/ataspectj/annotationGen/DeclareSoftTest.aj b/tests/java5/ataspectj/annotationGen/DeclareSoftTest.aj
new file mode 100644
index 000000000..0dd4c1f6f
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclareSoftTest.aj
@@ -0,0 +1,22 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+public aspect DeclareSoftTest {
+
+ declare soft : ClassNotFoundException : call(* Class.forName(..));
+
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<DeclareSoftTest> myType = AjTypeSystem.getAjType(DeclareSoftTest.class);
+ DeclareSoft[] decSs = myType.getDeclareSofts();
+ if (decSs.length != 1) throw new RuntimeException("Expecting 1 members, got " + decSs.length);
+ if (decSs[0].getDeclaringType() != myType) throw new RuntimeException("Bad declaring type: " + decSs[0].getDeclaringType());
+ String pc = decSs[0].getPointcutExpression().asString();
+ if (!pc.equals("call(* java.lang.Class.forName(..))")) throw new RuntimeException("Bad pcut: " + pc);
+ AjType exType = decSs[0].getSoftenedExceptionType();
+ if (exType != AjTypeSystem.getAjType(ClassNotFoundException.class)) {
+ throw new RuntimeException("Bad ex type: " + exType);
+ }
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index c909bb204..b91a3714d 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -2408,7 +2408,7 @@
</ajc-test>
<ajc-test dir="java5/annotations/declare" title="declare @type - covering enum and class element values - binary weaving">
- <weave aspectsFiles="EnumAndClassValues.aj" classesFiles="FunkyAnnotations.java" options="-1.5" xlintfile="ignoreTypeNotExposed.properties"/>
+ <weave aspectsFiles="EnumAndClassValues.aj" classesFiles="FunkyAnnotations.java" options="-1.5 -Xdev:Pinpoint" xlintfile="ignoreTypeNotExposed.properties"/>
<run class="FunkyAnnotations">
<stderr>
<line text="advice running: Red"/>
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
index ba6717b95..c3711841f 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java
@@ -130,5 +130,25 @@ public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase {
public void testRuntimePointcutsReferencingCompiledPointcuts() {
runTest("runtime pointcut resolution referencing compiled pointcuts");
}
+
+ public void testDecP() {
+ runTest("ann gen for decp");
+ }
+
+ public void testDecPAdvanced() {
+ runTest("ann gen for decp 2");
+ }
+
+ public void testDecS() {
+ runTest("ann gen for decs");
+ }
+
+ public void testDecPrecedence() {
+ runTest("ann gen for dec precedence");
+ }
+
+ public void testDecAnnotation() {
+ runTest("ann gen for dec annotation");
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
index aa87be080..3e74a541a 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml
@@ -148,5 +148,34 @@
</compile>
<run class="RuntimePointcuts" classpath="../lib/bcel/bcel.jar"/>
</ajc-test>
+
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for decp">
+ <compile files="DeclareParentsTest.aj" options="-1.5">
+ </compile>
+ <run class="DeclareParentsTest"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for decp 2">
+ <compile files="DeclareParentsTestAdvanced.aj" options="-1.5">
+ </compile>
+ <run class="a.b.c.DeclareParentsTestAdvanced"/>
+ </ajc-test>
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for decs">
+ <compile files="DeclareSoftTest.aj" options="-1.5">
+ </compile>
+ <run class="DeclareSoftTest"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for dec precedence">
+ <compile files="DeclarePrecedenceTest.aj" options="-1.5">
+ </compile>
+ <run class="DeclarePrecedenceTest"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/ataspectj/annotationGen" title="ann gen for dec annotation">
+ <compile files="DeclareAnnotationTest.aj" options="-1.5">
+ </compile>
+ <run class="DeclareAnnotationTest"/>
+ </ajc-test>
</suite> \ No newline at end of file