aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2006-10-18 14:46:29 +0000
committeraclement <aclement>2006-10-18 14:46:29 +0000
commitdb68044fe8ea0f43a5e090a67b9410f4c334bff6 (patch)
tree02010767f1a7500610a58abfe41e71c6539ea6f5 /tests
parent1a2eef067f87e9037bd39f20d4c682c642689de8 (diff)
downloadaspectj-db68044fe8ea0f43a5e090a67b9410f4c334bff6.tar.gz
aspectj-db68044fe8ea0f43a5e090a67b9410f4c334bff6.zip
test and fix for 123423: getWithinTypeName() for ptw aspects
Diffstat (limited to 'tests')
-rw-r--r--tests/features152/synthetic/TheWholeShow.aj2
-rw-r--r--tests/features153/ptw/CaseFive.java27
-rw-r--r--tests/features153/ptw/CaseFour.java28
-rw-r--r--tests/features153/ptw/CaseOne.java22
-rw-r--r--tests/features153/ptw/CaseThree.java26
-rw-r--r--tests/features153/ptw/CaseTwo.java26
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java5
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/ajc153.xml53
8 files changed, 188 insertions, 1 deletions
diff --git a/tests/features152/synthetic/TheWholeShow.aj b/tests/features152/synthetic/TheWholeShow.aj
index 7045c8192..0fa1c6642 100644
--- a/tests/features152/synthetic/TheWholeShow.aj
+++ b/tests/features152/synthetic/TheWholeShow.aj
@@ -58,7 +58,7 @@ public class TheWholeShow {
for (Method m : ms) {
if (!m.isSynthetic()) {
String name = m.getName();
- if (name.equals("aspectOf") || name.equals("hasAspect")) continue;
+ if (name.equals("aspectOf") || name.equals("hasAspect") || name.equals("getWithinTypeName")) continue;
if ( ! (name.startsWith("ajc$before") || name.startsWith("ajc$after") || name.startsWith("ajc$around") ||
name.startsWith("ajc$interMethod$"))) {
System.err.println("Found non-synthetic method: " + m.getName() + " in " + c.getName());
diff --git a/tests/features153/ptw/CaseFive.java b/tests/features153/ptw/CaseFive.java
new file mode 100644
index 000000000..e95edddd8
--- /dev/null
+++ b/tests/features153/ptw/CaseFive.java
@@ -0,0 +1,27 @@
+import java.lang.reflect.Method;
+
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.*;
+
+class AClass {}
+class BClass {}
+class CClass {}
+
+@Aspect("pertypewithin(*Class)")
+public class CaseFive {
+ public static void main(String []argv) throws Exception {
+ new Runner().run();
+ }
+}
+
+class Runner {
+ public void run() throws Exception {
+ if (Aspects14.hasAspect(CaseFive.class,AClass.class)) {
+ System.out.println("AClass has an aspect instance");
+ CaseFive instance = (CaseFive)Aspects14.aspectOf(CaseFive.class,AClass.class);
+ Method m = CaseFive.class.getDeclaredMethod("getWithinTypeName",null);
+ String s = (String)m.invoke(instance,null);
+ System.out.println("The aspect instance thinks it is for type name "+s);
+ }
+ }
+}
diff --git a/tests/features153/ptw/CaseFour.java b/tests/features153/ptw/CaseFour.java
new file mode 100644
index 000000000..735bbd4e0
--- /dev/null
+++ b/tests/features153/ptw/CaseFour.java
@@ -0,0 +1,28 @@
+// Types in packages
+
+package a.b;
+
+class AClass {}
+class BClass {}
+class CClass {}
+
+public aspect CaseFour pertypewithin(*Class) {
+ public static void main(String []argv) {
+ new Runner().run();
+ }
+}
+
+class Runner {
+ public void run() {
+ CaseFour aInstance = (CaseFour.hasAspect(AClass.class)?CaseFour.aspectOf(AClass.class):null);
+ CaseFour bInstance = (CaseFour.hasAspect(BClass.class)?CaseFour.aspectOf(BClass.class):null);
+ CaseFour cInstance = (CaseFour.hasAspect(CClass.class)?CaseFour.aspectOf(CClass.class):null);
+
+ System.out.println("BClass aspect instance gives a within type name of "+
+ (bInstance==null?"<null>":bInstance.getWithinTypeName()));
+ System.out.println("CClass aspect instance gives a within type name of "+
+ (cInstance==null?"<null>":cInstance.getWithinTypeName()));
+ System.out.println("AClass aspect instance gives a within type name of "+
+ (aInstance==null?"<null>":aInstance.getWithinTypeName()));
+ }
+}
diff --git a/tests/features153/ptw/CaseOne.java b/tests/features153/ptw/CaseOne.java
new file mode 100644
index 000000000..ea310ae70
--- /dev/null
+++ b/tests/features153/ptw/CaseOne.java
@@ -0,0 +1,22 @@
+// Types not in packages
+
+class AClass {}
+class BClass {}
+class CClass {}
+
+public aspect CaseOne pertypewithin(*Class) {
+ public static void main(String []argv) {
+ new Runner().run();
+ }
+}
+
+class Runner {
+ public void run() {
+ if (CaseOne.hasAspect(AClass.class)) {
+ System.out.println("AClass has an aspect instance");
+ CaseOne instance = CaseOne.aspectOf(AClass.class);
+ String name = instance.getWithinTypeName();
+ System.out.println("The aspect instance thinks it is for type name "+name);
+ }
+ }
+}
diff --git a/tests/features153/ptw/CaseThree.java b/tests/features153/ptw/CaseThree.java
new file mode 100644
index 000000000..1a808f662
--- /dev/null
+++ b/tests/features153/ptw/CaseThree.java
@@ -0,0 +1,26 @@
+// Types not in packages - BClass won't get an aspect
+
+class AClass {}
+class BClass {}
+class CClass {}
+
+public aspect CaseThree pertypewithin(*Class && !BClass) {
+ public static void main(String []argv) {
+ new Runner().run();
+ }
+}
+
+class Runner {
+ public void run() {
+ CaseThree aInstance = (CaseThree.hasAspect(AClass.class)?CaseThree.aspectOf(AClass.class):null);
+ CaseThree bInstance = (CaseThree.hasAspect(BClass.class)?CaseThree.aspectOf(BClass.class):null);
+ CaseThree cInstance = (CaseThree.hasAspect(CClass.class)?CaseThree.aspectOf(CClass.class):null);
+
+ System.out.println("BClass aspect instance gives a within type name of "+
+ (bInstance==null?"<null>":bInstance.getWithinTypeName()));
+ System.out.println("CClass aspect instance gives a within type name of "+
+ (cInstance==null?"<null>":cInstance.getWithinTypeName()));
+ System.out.println("AClass aspect instance gives a within type name of "+
+ (aInstance==null?"<null>":aInstance.getWithinTypeName()));
+ }
+}
diff --git a/tests/features153/ptw/CaseTwo.java b/tests/features153/ptw/CaseTwo.java
new file mode 100644
index 000000000..08bd0ed46
--- /dev/null
+++ b/tests/features153/ptw/CaseTwo.java
@@ -0,0 +1,26 @@
+// Types not in packages, and multiple mixed up instances
+
+class AClass {}
+class BClass {}
+class CClass {}
+
+public aspect CaseTwo pertypewithin(*Class) {
+ public static void main(String []argv) {
+ new Runner().run();
+ }
+}
+
+class Runner {
+ public void run() {
+ CaseTwo aInstance = (CaseTwo.hasAspect(AClass.class)?CaseTwo.aspectOf(AClass.class):null);
+ CaseTwo bInstance = (CaseTwo.hasAspect(BClass.class)?CaseTwo.aspectOf(BClass.class):null);
+ CaseTwo cInstance = (CaseTwo.hasAspect(CClass.class)?CaseTwo.aspectOf(CClass.class):null);
+
+ System.out.println("BClass aspect instance gives a within type name of "+
+ (bInstance==null?"<null>":bInstance.getWithinTypeName()));
+ System.out.println("CClass aspect instance gives a within type name of "+
+ (cInstance==null?"<null>":cInstance.getWithinTypeName()));
+ System.out.println("AClass aspect instance gives a within type name of "+
+ (aInstance==null?"<null>":aInstance.getWithinTypeName()));
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
index 88435cf39..0f1f79025 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
@@ -28,6 +28,11 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
// public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
// public void testNegatedAnnotationMatchingProblem_pr153464() { runTest("negated annotation matching problem");}
+ public void testPTWgetWithinTypeName_pr123423_1() { runTest("basic usage of getWithinTypeName");}
+ public void testPTWgetWithinTypeName_pr123423_2() { runTest("basic usage of getWithinTypeName - multiple types");}
+ public void testPTWgetWithinTypeName_pr123423_3() { runTest("basic usage of getWithinTypeName - non matching types");}
+ public void testPTWgetWithinTypeName_pr123423_4() { runTest("basic usage of getWithinTypeName - types in packages");}
+ public void testPTWgetWithinTypeName_pr123423_5() { runTest("basic usage of getWithinTypeName - annotation style");}
public void testTurningOffBcelCaching_pr160674() { runTest("turning off bcel caching");}
public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058() { runTest("no IllegalStateException with generic inner aspect"); }
public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058_2() { runTest("no IllegalStateException with generic inner aspect - 2"); }
diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
index b428413d6..d7e0cd677 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
@@ -51,6 +51,59 @@
</compile>
</ajc-test>
+ <ajc-test dir="features153/ptw" title="basic usage of getWithinTypeName">
+ <compile files="CaseOne.java"/>
+ <run class="CaseOne">
+ <stdout>
+ <line text="AClass has an aspect instance"/>
+ <line text="The aspect instance thinks it is for type name AClass"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features153/ptw" title="basic usage of getWithinTypeName - annotation style">
+ <compile files="CaseFive.java" options="-1.5"/>
+ <run class="CaseFive">
+ <stdout>
+ <line text="AClass has an aspect instance"/>
+ <line text="The aspect instance thinks it is for type name AClass"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features153/ptw" title="basic usage of getWithinTypeName - multiple types">
+ <compile files="CaseTwo.java"/>
+ <run class="CaseTwo">
+ <stdout>
+ <line text="BClass aspect instance gives a within type name of BClass"/>
+ <line text="CClass aspect instance gives a within type name of CClass"/>
+ <line text="AClass aspect instance gives a within type name of AClass"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features153/ptw" title="basic usage of getWithinTypeName - non matching types">
+ <compile files="CaseThree.java"/>
+ <run class="CaseThree">
+ <stdout>
+ <line text="BClass aspect instance gives a within type name of &lt;null&gt;"/>
+ <line text="CClass aspect instance gives a within type name of CClass"/>
+ <line text="AClass aspect instance gives a within type name of AClass"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features153/ptw" title="basic usage of getWithinTypeName - types in packages">
+ <compile files="CaseFour.java"/>
+ <run class="a.b.CaseFour">
+ <stdout>
+ <line text="BClass aspect instance gives a within type name of a.b.BClass"/>
+ <line text="CClass aspect instance gives a within type name of a.b.CClass"/>
+ <line text="AClass aspect instance gives a within type name of a.b.AClass"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs153/pr158126" title="annotations, call and constructors problem">
<compile files="A.java,B.java,MyAnnotation.java,MyAspect.java" options="-1.5 -showWeaveInfo">
<message kind="weave" text="Join point 'constructor-call(void B.&lt;init&gt;())' in Type 'A' (A.java:5) advised by before advice from 'MyAspect' (MyAspect.java:3)"/>