aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2010-05-13 04:06:42 +0000
committeraclement <aclement>2010-05-13 04:06:42 +0000
commit50b9cc3c0afda97d251f884e4173e04c6c8c25ac (patch)
tree7d25ca37b82226e073060705fce2651494732daf
parent27fa7e935696eda000b944d163ce1f3c4fa5afa5 (diff)
downloadaspectj-50b9cc3c0afda97d251f884e4173e04c6c8c25ac.tar.gz
aspectj-50b9cc3c0afda97d251f884e4173e04c6c8c25ac.zip
more overweaving tests and fixes: method call/field get/set
-rw-r--r--tests/features167/overweaving/aop.xml2
-rw-r--r--tests/features167/overweaving/calls/A.aj3
-rw-r--r--tests/features167/overweaving/calls/B.aj3
-rw-r--r--tests/features167/overweaving/calls/Class1.java5
-rw-r--r--tests/features167/overweaving/calls/Class2.java5
-rw-r--r--tests/features167/overweaving/calls/aop.xml12
-rw-r--r--tests/features167/overweaving/cflow/aop.xml1
-rw-r--r--tests/features167/overweaving/getset/A.aj3
-rw-r--r--tests/features167/overweaving/getset/B.aj3
-rw-r--r--tests/features167/overweaving/getset/Class1.java6
-rw-r--r--tests/features167/overweaving/getset/Class2.java6
-rw-r--r--tests/features167/overweaving/getset/aop.xml12
-rw-r--r--tests/features167/overweaving/itds1/A.aj16
-rw-r--r--tests/features167/overweaving/itds1/C.java13
-rw-r--r--tests/features167/overweaving/itds1/X.aj7
-rw-r--r--tests/features167/overweaving/itds1/aop.xml10
-rw-r--r--tests/features167/overweaving/messy/aop.xml1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java19
-rw-r--r--tests/src/org/aspectj/systemtest/ajc167/overweaving.xml87
19 files changed, 211 insertions, 3 deletions
diff --git a/tests/features167/overweaving/aop.xml b/tests/features167/overweaving/aop.xml
index 957cc2c32..0999dda5a 100644
--- a/tests/features167/overweaving/aop.xml
+++ b/tests/features167/overweaving/aop.xml
@@ -3,7 +3,7 @@
<aspect name="X"/>
</aspects>
<weaver options="-verbose -Xset:overWeaving=true">
- <dump within="*" beforeandafter="true"/>
+<!-- <dump within="*" beforeandafter="true"/>-->
</weaver>
</aspectj>
diff --git a/tests/features167/overweaving/calls/A.aj b/tests/features167/overweaving/calls/A.aj
new file mode 100644
index 000000000..7ae3e52c5
--- /dev/null
+++ b/tests/features167/overweaving/calls/A.aj
@@ -0,0 +1,3 @@
+public aspect A {
+ before(): !cflow(adviceexecution()) && call(* *(..)) {System.out.println("A:"+thisJoinPointStaticPart);}
+}
diff --git a/tests/features167/overweaving/calls/B.aj b/tests/features167/overweaving/calls/B.aj
new file mode 100644
index 000000000..fa4b334d0
--- /dev/null
+++ b/tests/features167/overweaving/calls/B.aj
@@ -0,0 +1,3 @@
+public aspect B {
+ before(): !cflow(adviceexecution()) && call(* *(..)) {System.out.println("B:"+thisJoinPointStaticPart);}
+}
diff --git a/tests/features167/overweaving/calls/Class1.java b/tests/features167/overweaving/calls/Class1.java
new file mode 100644
index 000000000..c89605ca0
--- /dev/null
+++ b/tests/features167/overweaving/calls/Class1.java
@@ -0,0 +1,5 @@
+public class Class1 {
+ public static void main(String[]argv) {
+ System.out.println("Class1.main");
+ }
+}
diff --git a/tests/features167/overweaving/calls/Class2.java b/tests/features167/overweaving/calls/Class2.java
new file mode 100644
index 000000000..b602a2fe9
--- /dev/null
+++ b/tests/features167/overweaving/calls/Class2.java
@@ -0,0 +1,5 @@
+public class Class2 {
+ public static void main(String[]argv) {
+ System.out.println("Class2.main");
+ }
+}
diff --git a/tests/features167/overweaving/calls/aop.xml b/tests/features167/overweaving/calls/aop.xml
new file mode 100644
index 000000000..956854a9e
--- /dev/null
+++ b/tests/features167/overweaving/calls/aop.xml
@@ -0,0 +1,12 @@
+<aspectj>
+<aspects>
+ <aspect name="A"/>
+ <aspect name="B"/>
+</aspects>
+<weaver options="-verbose -Xset:overWeaving=true -debug -showWeaveInfo">
+<!--
+ <dump within="*" beforeandafter="true"/>
+-->
+</weaver>
+
+</aspectj>
diff --git a/tests/features167/overweaving/cflow/aop.xml b/tests/features167/overweaving/cflow/aop.xml
index b199c94ea..920e7faa0 100644
--- a/tests/features167/overweaving/cflow/aop.xml
+++ b/tests/features167/overweaving/cflow/aop.xml
@@ -4,7 +4,6 @@
<aspect name="com.andy.A"/>
</aspects>
<weaver options="-verbose -Xset:overWeaving=true">
- <dump within="*" beforeandafter="true"/>
</weaver>
</aspectj>
diff --git a/tests/features167/overweaving/getset/A.aj b/tests/features167/overweaving/getset/A.aj
new file mode 100644
index 000000000..25e26c127
--- /dev/null
+++ b/tests/features167/overweaving/getset/A.aj
@@ -0,0 +1,3 @@
+public aspect A {
+ before(): !cflow(adviceexecution()) && get(* *) {System.out.println("A:"+thisJoinPointStaticPart);}
+}
diff --git a/tests/features167/overweaving/getset/B.aj b/tests/features167/overweaving/getset/B.aj
new file mode 100644
index 000000000..4364571f3
--- /dev/null
+++ b/tests/features167/overweaving/getset/B.aj
@@ -0,0 +1,3 @@
+public aspect B {
+ before(): !cflow(adviceexecution()) && set(* *) {System.out.println("B:"+thisJoinPointStaticPart);}
+}
diff --git a/tests/features167/overweaving/getset/Class1.java b/tests/features167/overweaving/getset/Class1.java
new file mode 100644
index 000000000..029c8d831
--- /dev/null
+++ b/tests/features167/overweaving/getset/Class1.java
@@ -0,0 +1,6 @@
+public class Class1 {
+ public static String message = "Class1.main";
+ public static void main(String[]argv) {
+ System.out.println(message);
+ }
+}
diff --git a/tests/features167/overweaving/getset/Class2.java b/tests/features167/overweaving/getset/Class2.java
new file mode 100644
index 000000000..5e3c6cf3c
--- /dev/null
+++ b/tests/features167/overweaving/getset/Class2.java
@@ -0,0 +1,6 @@
+public class Class2 {
+ public static String message = "Class2.main";
+ public static void main(String[]argv) {
+ System.out.println(message);
+ }
+}
diff --git a/tests/features167/overweaving/getset/aop.xml b/tests/features167/overweaving/getset/aop.xml
new file mode 100644
index 000000000..956854a9e
--- /dev/null
+++ b/tests/features167/overweaving/getset/aop.xml
@@ -0,0 +1,12 @@
+<aspectj>
+<aspects>
+ <aspect name="A"/>
+ <aspect name="B"/>
+</aspects>
+<weaver options="-verbose -Xset:overWeaving=true -debug -showWeaveInfo">
+<!--
+ <dump within="*" beforeandafter="true"/>
+-->
+</weaver>
+
+</aspectj>
diff --git a/tests/features167/overweaving/itds1/A.aj b/tests/features167/overweaving/itds1/A.aj
new file mode 100644
index 000000000..b7e3fcb91
--- /dev/null
+++ b/tests/features167/overweaving/itds1/A.aj
@@ -0,0 +1,16 @@
+package com.andy;
+
+@interface Anno {}
+
+aspect A {
+ declare @type: com.andy.C: @Anno;
+
+ int C.i = 5;
+
+ public void C.m() {}
+
+ before(): execution(* C.main(..)) {
+ System.out.println("A:"+thisJoinPointStaticPart);
+ }
+
+}
diff --git a/tests/features167/overweaving/itds1/C.java b/tests/features167/overweaving/itds1/C.java
new file mode 100644
index 000000000..8c760bb60
--- /dev/null
+++ b/tests/features167/overweaving/itds1/C.java
@@ -0,0 +1,13 @@
+package com.andy;
+
+public class C {
+ public String name = "andy";
+
+ public static void main(String []argv) {
+ new C().run();
+ }
+
+ public void run() {
+ System.out.println("hello "+name);
+ }
+}
diff --git a/tests/features167/overweaving/itds1/X.aj b/tests/features167/overweaving/itds1/X.aj
new file mode 100644
index 000000000..9c576aeed
--- /dev/null
+++ b/tests/features167/overweaving/itds1/X.aj
@@ -0,0 +1,7 @@
+aspect X {
+before(): cflow(execution(* main(..))) && execution(* *(..)) {
+ System.out.println("X:"+thisJoinPointStaticPart);
+}
+
+}
+
diff --git a/tests/features167/overweaving/itds1/aop.xml b/tests/features167/overweaving/itds1/aop.xml
new file mode 100644
index 000000000..b199c94ea
--- /dev/null
+++ b/tests/features167/overweaving/itds1/aop.xml
@@ -0,0 +1,10 @@
+<aspectj>
+<aspects>
+ <aspect name="X"/>
+ <aspect name="com.andy.A"/>
+</aspects>
+<weaver options="-verbose -Xset:overWeaving=true">
+ <dump within="*" beforeandafter="true"/>
+</weaver>
+
+</aspectj>
diff --git a/tests/features167/overweaving/messy/aop.xml b/tests/features167/overweaving/messy/aop.xml
index 0f99ba166..02d51a9d8 100644
--- a/tests/features167/overweaving/messy/aop.xml
+++ b/tests/features167/overweaving/messy/aop.xml
@@ -4,7 +4,6 @@
<aspect name="com.andy.A"/>
</aspects>
<weaver options="-verbose -Xset:overWeaving=true -debug">
- <dump within="*" beforeandafter="true"/>
</weaver>
</aspectj>
diff --git a/tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java b/tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java
index 1ced76f59..e29bd3349 100644
--- a/tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java
@@ -17,11 +17,30 @@ import junit.framework.Test;
import org.aspectj.testing.XMLBasedAjcTestCase;
/**
+ * Testing whether AspectJ can overweave. Overweaving is where we attempt to weave something that has already been woven. The simple
+ * rule followed is that aspects that applied to the type before are not applied this time around (if they are visible to the
+ * weaver).
*
* @author Andy Clement
*/
public class OverweavingTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testGetSet1() {
+ runTest("getset - 1"); // testing what should happen for get/set
+ }
+
+ public void testGetSet2() {
+ runTest("getset - 2"); // testing what actually happens when overweaving
+ }
+
+ public void testCalls1() {
+ runTest("calls - 1"); // testing what should happen for calls
+ }
+
+ public void testCalls2() {
+ runTest("calls - 2"); // testing what actually happens when overweaving
+ }
+
public void testComplex() {
runTest("really messy");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc167/overweaving.xml b/tests/src/org/aspectj/systemtest/ajc167/overweaving.xml
index 358ab7d85..c48f7b0fa 100644
--- a/tests/src/org/aspectj/systemtest/ajc167/overweaving.xml
+++ b/tests/src/org/aspectj/systemtest/ajc167/overweaving.xml
@@ -2,6 +2,93 @@
<suite>
+
+ <ajc-test dir="features167/overweaving/getset" title="getset - 1">
+ <compile files="A.aj B.aj Class1.java Class2.java" options="-1.5"/>
+ <run class="Class1">
+ <stdout>
+ <line text="B:set(String Class1.message)"/>
+ <line text="A:get(PrintStream java.lang.System.out)"/>
+ <line text="A:get(String Class1.message)"/>
+ <line text="Class1.main"/>
+ </stdout>
+ </run>
+
+ <run class="Class2">
+ <stdout>
+ <line text="B:set(String Class2.message)"/>
+ <line text="A:get(PrintStream java.lang.System.out)"/>
+ <line text="A:get(String Class2.message)"/>
+ <line text="Class2.main"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features167/overweaving/getset" title="getset - 2">
+ <compile files="A.aj Class1.java" options="-1.5"/>
+ <compile files="B.aj" options="-1.5 -Xlint:ignore"/>
+ <compile files="Class2.java" options="-1.5 -Xlint:ignore"/>
+ <run class="Class1" ltw="aop.xml">
+ <stdout>
+ <!-- should be advised by both, but was *already* advised by A during first weave -->
+ <line text="B:set(String Class1.message)"/>
+ <line text="A:get(PrintStream java.lang.System.out)"/>
+ <line text="A:get(String Class1.message)"/>
+ <line text="Class1.main"/>
+ </stdout>
+ </run>
+
+ <run class="Class2" ltw="aop.xml">
+ <stdout>
+ <line text="B:set(String Class2.message)"/>
+ <line text="A:get(PrintStream java.lang.System.out)"/>
+ <line text="A:get(String Class2.message)"/>
+ <line text="Class2.main"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features167/overweaving/calls" title="calls - 1">
+ <compile files="A.aj B.aj Class1.java Class2.java" options="-1.5"/>
+ <run class="Class1">
+ <stdout>
+ <line text="A:call(void java.io.PrintStream.println(String))"/>
+ <line text="B:call(void java.io.PrintStream.println(String))"/>
+ <line text="Class1.main"/>
+ </stdout>
+ </run>
+
+ <run class="Class2">
+ <stdout>
+ <line text="A:call(void java.io.PrintStream.println(String))"/>
+ <line text="B:call(void java.io.PrintStream.println(String))"/>
+ <line text="Class2.main"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features167/overweaving/calls" title="calls - 2">
+ <compile files="A.aj Class1.java" options="-1.5"/>
+ <compile files="B.aj" options="-1.5 -Xlint:ignore"/>
+ <compile files="Class2.java" options="-1.5 -Xlint:ignore"/>
+ <run class="Class1" ltw="aop.xml">
+ <stdout>
+ <!-- should be advised by both, but was *already* advised by A during first weave -->
+ <line text="A:call(void java.io.PrintStream.println(String))"/>
+ <line text="B:call(void java.io.PrintStream.println(String))"/>
+ <line text="Class1.main"/>
+ </stdout>
+ </run>
+
+ <run class="Class2" ltw="aop.xml">
+ <stdout>
+ <line text="A:call(void java.io.PrintStream.println(String))"/>
+ <line text="B:call(void java.io.PrintStream.println(String))"/>
+ <line text="Class2.main"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="features167/overweaving/messy2" title="really messy">
<compile files="A.aj Class1.java" options="-1.5"/>
<compile files="B.aj" options="-1.5 -Xlint:ignore"/>