]> source.dussan.org Git - aspectj.git/commitdiff
more overweaving tests and fixes: method call/field get/set
authoraclement <aclement>
Thu, 13 May 2010 04:06:42 +0000 (04:06 +0000)
committeraclement <aclement>
Thu, 13 May 2010 04:06:42 +0000 (04:06 +0000)
19 files changed:
tests/features167/overweaving/aop.xml
tests/features167/overweaving/calls/A.aj [new file with mode: 0644]
tests/features167/overweaving/calls/B.aj [new file with mode: 0644]
tests/features167/overweaving/calls/Class1.java [new file with mode: 0644]
tests/features167/overweaving/calls/Class2.java [new file with mode: 0644]
tests/features167/overweaving/calls/aop.xml [new file with mode: 0644]
tests/features167/overweaving/cflow/aop.xml
tests/features167/overweaving/getset/A.aj [new file with mode: 0644]
tests/features167/overweaving/getset/B.aj [new file with mode: 0644]
tests/features167/overweaving/getset/Class1.java [new file with mode: 0644]
tests/features167/overweaving/getset/Class2.java [new file with mode: 0644]
tests/features167/overweaving/getset/aop.xml [new file with mode: 0644]
tests/features167/overweaving/itds1/A.aj [new file with mode: 0644]
tests/features167/overweaving/itds1/C.java [new file with mode: 0644]
tests/features167/overweaving/itds1/X.aj [new file with mode: 0644]
tests/features167/overweaving/itds1/aop.xml [new file with mode: 0644]
tests/features167/overweaving/messy/aop.xml
tests/src/org/aspectj/systemtest/ajc167/OverweavingTests.java
tests/src/org/aspectj/systemtest/ajc167/overweaving.xml

index 957cc2c32249705f89e3fcef5462269a6a051952..0999dda5a2f2787c61944a8ef36326f596ae9f90 100644 (file)
@@ -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 (file)
index 0000000..7ae3e52
--- /dev/null
@@ -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 (file)
index 0000000..fa4b334
--- /dev/null
@@ -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 (file)
index 0000000..c89605c
--- /dev/null
@@ -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 (file)
index 0000000..b602a2f
--- /dev/null
@@ -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 (file)
index 0000000..956854a
--- /dev/null
@@ -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>
index b199c94ea328d26d5d5e9f046dc1d7a1483addc1..920e7faa067ac657ac8ebc1027c186c920ab7b6a 100644 (file)
@@ -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 (file)
index 0000000..25e26c1
--- /dev/null
@@ -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 (file)
index 0000000..4364571
--- /dev/null
@@ -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 (file)
index 0000000..029c8d8
--- /dev/null
@@ -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 (file)
index 0000000..5e3c6cf
--- /dev/null
@@ -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 (file)
index 0000000..956854a
--- /dev/null
@@ -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 (file)
index 0000000..b7e3fcb
--- /dev/null
@@ -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 (file)
index 0000000..8c760bb
--- /dev/null
@@ -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 (file)
index 0000000..9c576ae
--- /dev/null
@@ -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 (file)
index 0000000..b199c94
--- /dev/null
@@ -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>
index 0f99ba16692eeb239a717012efaad5631db68a9d..02d51a9d83a34ab41f2210ae342c0a25100501f7 100644 (file)
@@ -4,7 +4,6 @@
   <aspect name="com.andy.A"/>
 </aspects>
 <weaver options="-verbose -Xset:overWeaving=true -debug">
-  <dump within="*" beforeandafter="true"/>
 </weaver>
 
 </aspectj>
index 1ced76f5976f6a9969c90ef9b3b09089871d481f..e29bd3349390e0575812dac7034b9ee39811dbf7 100644 (file)
@@ -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");
        }
index 358ab7d8526b8cc4bd721ffa76fcc45ab40d2bf9..c48f7b0fa08228261e2e34971b5d6ec6304e8629 100644 (file)
@@ -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"/>