aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-02-02 11:31:58 +0000
committeraclement <aclement>2006-02-02 11:31:58 +0000
commit5f10ab1ee6592619b75d8f157f937d620f92d698 (patch)
tree0328e782bd99901e63a52c1ad6d757ed6655ba07
parent7a96a40ab7d5418309c4742bdb0225cd0dfb88ff (diff)
downloadaspectj-5f10ab1ee6592619b75d8f157f937d620f92d698.tar.gz
aspectj-5f10ab1ee6592619b75d8f157f937d620f92d698.zip
@AJ around tests for 126167
-rw-r--r--tests/features151/ataround/A1.java31
-rw-r--r--tests/features151/ataround/A10.java38
-rw-r--r--tests/features151/ataround/A11.java37
-rw-r--r--tests/features151/ataround/A2.java31
-rw-r--r--tests/features151/ataround/A3.java33
-rw-r--r--tests/features151/ataround/A4.java31
-rw-r--r--tests/features151/ataround/A5.java32
-rw-r--r--tests/features151/ataround/A6.java32
-rw-r--r--tests/features151/ataround/A7.java37
-rw-r--r--tests/features151/ataround/A8.java37
-rw-r--r--tests/features151/ataround/A9.java38
-rw-r--r--tests/features151/ataround/X1.java29
-rw-r--r--tests/features151/ataround/X10.java35
-rw-r--r--tests/features151/ataround/X11.java35
-rw-r--r--tests/features151/ataround/X2.java29
-rw-r--r--tests/features151/ataround/X3.java31
-rw-r--r--tests/features151/ataround/X4.java30
-rw-r--r--tests/features151/ataround/X5.java30
-rw-r--r--tests/features151/ataround/X6.java30
-rw-r--r--tests/features151/ataround/X7.java34
-rw-r--r--tests/features151/ataround/X8.java34
-rw-r--r--tests/features151/ataround/X9.java35
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/AtAroundTests.java78
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/ataround.xml233
25 files changed, 1041 insertions, 0 deletions
diff --git a/tests/features151/ataround/A1.java b/tests/features151/ataround/A1.java
new file mode 100644
index 000000000..669051759
--- /dev/null
+++ b/tests/features151/ataround/A1.java
@@ -0,0 +1,31 @@
+// Simple - don't attempt to alter target for proceed, just change the arg
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A1 {
+
+ @Around("call(void M.method(String)) && args(p)")
+ public void a( ProceedingJoinPoint pjp, String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed( new Object[] { pjp.getTarget(),"faked" } );
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/A10.java b/tests/features151/ataround/A10.java
new file mode 100644
index 000000000..0ef445502
--- /dev/null
+++ b/tests/features151/ataround/A10.java
@@ -0,0 +1,38 @@
+// Bind this and target on call and change it with proceed
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A10 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ @Around("call(void M.method(String)) && args(p) && this(t) && target(t2)")
+ public void a( ProceedingJoinPoint pjp, M t,String p, M t2) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM2,"faked",newM3});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+
+}
diff --git a/tests/features151/ataround/A11.java b/tests/features151/ataround/A11.java
new file mode 100644
index 000000000..b2e858b30
--- /dev/null
+++ b/tests/features151/ataround/A11.java
@@ -0,0 +1,37 @@
+// only bind arg subset and change that subset
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A11 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ @Around("call(void M.method(..)) && args(*,p,*) && this(t) && target(t2)")
+ public void a( ProceedingJoinPoint pjp, M t,String p, M t2) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM2,"_",newM3});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("x","y","z");
+ }
+
+ public void methodCaller(String param,String param2,String param3) {
+ method(param,param2,param3);
+ }
+
+ public void method(String a,String b,String c) { System.err.println(prefix+a+b+c); }
+}
diff --git a/tests/features151/ataround/A2.java b/tests/features151/ataround/A2.java
new file mode 100644
index 000000000..805b3a1a5
--- /dev/null
+++ b/tests/features151/ataround/A2.java
@@ -0,0 +1,31 @@
+// Bind the target but forget to pass it on the proceed call
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A2 {
+
+ @Around("call(void M.method(String)) && args(p) && target(t)")
+ public void a( ProceedingJoinPoint pjp, M t, String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed( new Object[] { "faked" } ); // too few arguments to proceed?
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/A3.java b/tests/features151/ataround/A3.java
new file mode 100644
index 000000000..6a151933e
--- /dev/null
+++ b/tests/features151/ataround/A3.java
@@ -0,0 +1,33 @@
+// Bind the target but pass args in wrong order on proceed
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A3 {
+
+ @Around("call(void M.method(String)) && args(p) && target(t)")
+ public void a( ProceedingJoinPoint pjp, M t, String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{"faked",t});
+ // Type mismatch: cannot convert from String to M
+ // Type mismatch: cannot convert from M to String
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/A4.java b/tests/features151/ataround/A4.java
new file mode 100644
index 000000000..e831289ed
--- /dev/null
+++ b/tests/features151/ataround/A4.java
@@ -0,0 +1,31 @@
+// Bind the target and pass in the right order
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A4 {
+
+ @Around("call(void M.method(String)) && args(p) && target(t)")
+ public void a( ProceedingJoinPoint pjp, M t, String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{t,"faked"});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/A5.java b/tests/features151/ataround/A5.java
new file mode 100644
index 000000000..899cf6acb
--- /dev/null
+++ b/tests/features151/ataround/A5.java
@@ -0,0 +1,32 @@
+// Bind the target and pass in the right order - but pass in a different target
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A5 {
+ M newM = new M("2");
+
+ @Around("call(void M.method(String)) && args(p) && target(t)")
+ public void a( ProceedingJoinPoint pjp, M t, String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM,"faked"});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/A6.java b/tests/features151/ataround/A6.java
new file mode 100644
index 000000000..3231b9562
--- /dev/null
+++ b/tests/features151/ataround/A6.java
@@ -0,0 +1,32 @@
+// Bind the target but make it the third arg rather than the second
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A6 {
+ M newM = new M("2");
+
+ @Around("call(void M.method(String)) && args(p) && target(t)")
+ public void a( ProceedingJoinPoint pjp, String p, M t) throws Throwable {
+// System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{"faked",newM});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/A7.java b/tests/features151/ataround/A7.java
new file mode 100644
index 000000000..0a207434f
--- /dev/null
+++ b/tests/features151/ataround/A7.java
@@ -0,0 +1,37 @@
+// Bind the this on a call and change it with proceed... makes no difference
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A7 {
+ M newM = new M("2");
+
+ @Around("call(void M.method(String)) && args(p) && this(t)")
+ public void a( ProceedingJoinPoint pjp, M t,String p) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM,"faked"});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+
+}
diff --git a/tests/features151/ataround/A8.java b/tests/features151/ataround/A8.java
new file mode 100644
index 000000000..b71daa381
--- /dev/null
+++ b/tests/features151/ataround/A8.java
@@ -0,0 +1,37 @@
+// Bind the this on a call and change it with proceed... works
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A8 {
+ M newM = new M("2");
+
+ @Around("execution(void M.method(String)) && args(p) && this(t)")
+ public void a( ProceedingJoinPoint pjp, String p, M t) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM,"faked"});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+
+}
diff --git a/tests/features151/ataround/A9.java b/tests/features151/ataround/A9.java
new file mode 100644
index 000000000..97bf674ba
--- /dev/null
+++ b/tests/features151/ataround/A9.java
@@ -0,0 +1,38 @@
+// Bind this and target on execution and change it with proceed
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class A9 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ @Around("execution(void M.method(String)) && args(p) && this(t) && target(t2)")
+ public void a( ProceedingJoinPoint pjp, M t,String p, M t2) throws Throwable {
+ System.err.println("advice from ataj aspect");
+ pjp.proceed(new Object[]{newM2,"faked",newM3});
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+
+}
diff --git a/tests/features151/ataround/X1.java b/tests/features151/ataround/X1.java
new file mode 100644
index 000000000..3570b9733
--- /dev/null
+++ b/tests/features151/ataround/X1.java
@@ -0,0 +1,29 @@
+// Simple - don't attempt to alter target for proceed, just change the arg
+
+aspect X1 {
+
+ void around(String p): call(void M.method(String)) && args(p) {
+ System.err.println("advice from code aspect");
+ proceed( "faked" );
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/X10.java b/tests/features151/ataround/X10.java
new file mode 100644
index 000000000..fc94f27c7
--- /dev/null
+++ b/tests/features151/ataround/X10.java
@@ -0,0 +1,35 @@
+// Bind the this and target on call and change it with proceed...
+
+aspect X10 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ void around(M t,String p,M t2): call(void M.method(String)) && args(p) && this(t) && target(t2) {
+ System.err.println("advice from code aspect");
+ proceed( newM2,"faked" , newM3);
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X11.java b/tests/features151/ataround/X11.java
new file mode 100644
index 000000000..c8b4be16c
--- /dev/null
+++ b/tests/features151/ataround/X11.java
@@ -0,0 +1,35 @@
+// Bind the this and target on call and change it with proceed... but subset arguments in advice
+
+aspect X11 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ void around(M t,String p,M t2): call(void M.method(..)) && args(*,p,*) && this(t) && target(t2) {
+ System.err.println("advice from code aspect");
+ proceed( newM2,"_" , newM3);
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("x","y","z");
+ }
+
+ public void methodCaller(String param,String param2,String param3) {
+ method(param,param2,param3);
+ }
+
+ public void method(String a,String b,String c) { System.err.println(prefix+a+b+c); }
+}
diff --git a/tests/features151/ataround/X2.java b/tests/features151/ataround/X2.java
new file mode 100644
index 000000000..396942824
--- /dev/null
+++ b/tests/features151/ataround/X2.java
@@ -0,0 +1,29 @@
+// Bind the target but forget to pass it on the proceed call
+
+aspect X2 {
+
+ void around(M t,String p): call(void M.method(String)) && args(p) && target(t) {
+ System.err.println("advice from code aspect");
+ proceed( "faked" ); // X2.java:7 [error] too few arguments to proceed, expected 2
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/X3.java b/tests/features151/ataround/X3.java
new file mode 100644
index 000000000..8f3f3dc37
--- /dev/null
+++ b/tests/features151/ataround/X3.java
@@ -0,0 +1,31 @@
+// Bind the target but pass args in wrong order on proceed
+
+aspect X3 {
+
+ void around(M t,String p): call(void M.method(String)) && args(p) && target(t) {
+ System.err.println("advice from code aspect");
+ proceed( "faked" , t);
+ // X3.java:7 [error] Type mismatch: cannot convert from String to M
+ // X3.java:7 [error] Type mismatch: cannot convert from M to String
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M(">");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(s); }
+}
diff --git a/tests/features151/ataround/X4.java b/tests/features151/ataround/X4.java
new file mode 100644
index 000000000..0ac17ee92
--- /dev/null
+++ b/tests/features151/ataround/X4.java
@@ -0,0 +1,30 @@
+// Bind the target and pass in the right order
+
+aspect X4 {
+ M newM = new M("2");
+
+ void around(M t,String p): call(void M.method(String)) && args(p) && target(t) {
+ System.err.println("advice from code aspect");
+ proceed( t , "faked" );
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X5.java b/tests/features151/ataround/X5.java
new file mode 100644
index 000000000..f8b754ff3
--- /dev/null
+++ b/tests/features151/ataround/X5.java
@@ -0,0 +1,30 @@
+// Bind the target and pass in the right order - but pass in a different target
+
+aspect X5 {
+ M newM = new M("2");
+
+ void around(M t,String p): call(void M.method(String)) && args(p) && target(t) {
+ System.err.println("advice from code aspect");
+ proceed( newM , "faked" );
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X6.java b/tests/features151/ataround/X6.java
new file mode 100644
index 000000000..ad8c63096
--- /dev/null
+++ b/tests/features151/ataround/X6.java
@@ -0,0 +1,30 @@
+// Bind the target but make it the second arg rather than the first
+
+aspect X6 {
+ M newM = new M("2");
+
+ void around(String p,M t): call(void M.method(String)) && args(p) && target(t) {
+ System.err.println("advice from code aspect");
+ proceed( "faked" , newM);
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.method("real");
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X7.java b/tests/features151/ataround/X7.java
new file mode 100644
index 000000000..6fb46cc83
--- /dev/null
+++ b/tests/features151/ataround/X7.java
@@ -0,0 +1,34 @@
+// Bind the this on a call and change it with proceed... it is ignored
+
+aspect X7 {
+ M newM = new M("2");
+
+ void around(M t,String p): call(void M.method(String)) && args(p) && this(t) {
+ System.err.println("advice from code aspect");
+ proceed(newM, "faked");
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X8.java b/tests/features151/ataround/X8.java
new file mode 100644
index 000000000..1a13c57bd
--- /dev/null
+++ b/tests/features151/ataround/X8.java
@@ -0,0 +1,34 @@
+// Bind the this on execution and change it with proceed... works, modifies instance that executes
+
+aspect X8 {
+ M newM = new M("2");
+
+ void around(M t,String p): execution(void M.method(String)) && args(p) && this(t) {
+ System.err.println("advice from code aspect");
+ proceed( newM,"faked" );
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/features151/ataround/X9.java b/tests/features151/ataround/X9.java
new file mode 100644
index 000000000..b5ae5cc2f
--- /dev/null
+++ b/tests/features151/ataround/X9.java
@@ -0,0 +1,35 @@
+// Bind the this and target on execution and change it with proceed...
+
+aspect X9 {
+ M newM2 = new M("2");
+ M newM3 = new M("3");
+
+ void around(M t,String p,M t2): execution(void M.method(String)) && args(p) && this(t) && target(t2) {
+ System.err.println("advice from code aspect");
+ proceed( newM2,"faked" , newM3);
+ }
+
+ public static void main(String []argv) {
+ M.main(argv);
+ }
+}
+
+
+
+class M {
+
+ String prefix;
+
+ public M(String prefix) { this.prefix = prefix; }
+
+ public static void main( String[] args ) {
+ M m = new M("1");
+ m.methodCaller("real");
+ }
+
+ public void methodCaller(String param) {
+ method(param);
+ }
+
+ public void method(String s) { System.err.println(prefix+s); }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java b/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java
index 1153be1b6..a3929851a 100644
--- a/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java
+++ b/tests/src/org/aspectj/systemtest/ajc151/AllTestsAspectJ151.java
@@ -20,6 +20,7 @@ public class AllTestsAspectJ151 {
//$JUnit-BEGIN$
suite.addTest(Ajc151Tests.suite());
suite.addTest(NewarrayJoinpointTests.suite());
+ suite.addTest(AtAroundTests.suite());
//$JUnit-END$
return suite;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc151/AtAroundTests.java b/tests/src/org/aspectj/systemtest/ajc151/AtAroundTests.java
new file mode 100644
index 000000000..f2c060316
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc151/AtAroundTests.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc151;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * This testcode shows what is possible with code style and the current limitations
+ * of @AJ style. Each program is written in both styles and those variations
+ * not currently possible are commented out.
+ *
+ * @author AndyClement
+ *
+ */
+
+
+public class AtAroundTests extends XMLBasedAjcTestCase {
+
+ public void testCodeBasic() { runTest("code style - basic"); }
+ public void testAtBasic() { runTest("annotation style - basic"); }
+
+ public void testCodeErrorCase1() { runTest("code style - forget to pass target");}
+ // Don't think we can report correct errors for @AJ as the parameters are specified as an object array
+ // public void testAtErrorCase1() { runTest("annotation style - forget to pass target");}
+
+ public void testCodeErrorCase2() { runTest("code style - incorrect arg types");}
+ // Don't think we can report correct errors for @AJ as the parameters are specified as an object array
+ // public void testAtErrorCase2() { runTest("annotation style - incorrect arg types");}
+
+ public void testCodeBindingTarget() { runTest("code style - correct usage, binding and passing new target for call"); }
+ public void testAtBindingTarget() { runTest("annotation style - correct usage, binding and passing new target for call"); }
+
+ public void testCodeChangingTarget() { runTest("code style - changing target for call"); }
+ public void testAtChangingTarget() { runTest("annotation style - changing target for call"); }
+
+ public void testCodeChangingTargetDifferingOrder() { runTest("code style - changing target for call - reverse order"); }
+ // @AJ cant cope with the changing of the order of arguments bound and passed through proceed
+ //public void testAtChangingTargetDifferingOrder() { runTest("annotation style - changing target for call - reverse order"); }
+
+ public void testCodeBindThisCallChangeProceed() { runTest("code style - bind this on call - change on proceed - no effect");}
+ //public void testAtBindThisCallChangeProceed() { runTest("annotation style - bind this on call - change on proceed - no effect");}
+
+ public void testCodeBindThisExecutionChangeProceed() { runTest("code style - bind this on execution - change on proceed - works");}
+ //public void testAtBindThisExecutionChangeProceed() { runTest("annotation style - bind this on execution - change on proceed - works");}
+
+ public void testCodeBindBothExecutionChangeProceed() { runTest("code style - bind this and target on execution - change on proceed - works");}
+ //public void testAtBindBothExecutionChangeProceed() { runTest("annotation style - bind this and target on execution - change on proceed - works");}
+
+ public void testCodeBindBothCallChangeProceed() { runTest("code style - bind this and target on call - change on proceed - works");}
+ //public void testAtBindBothCallChangeProceed() { runTest("annotation style - bind this and target on call - change on proceed - works");}
+
+ public void testCodeSubsetArguments() { runTest("code style - works with subset of arguments in advice");}
+ //public void testAtSubsetArguments() { runTest("annotation style - works with subset of arguments in advice");}
+
+
+
+ //
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(AtAroundTests.class);
+ }
+
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc151/ataround.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc151/ataround.xml b/tests/src/org/aspectj/systemtest/ajc151/ataround.xml
new file mode 100644
index 000000000..f52d380b2
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc151/ataround.xml
@@ -0,0 +1,233 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<!-- AspectJ v1.5.1 Tests -->
+<suite>
+
+
+ <ajc-test dir="features151/ataround" title="code style - basic">
+ <compile files="X1.java" options="-1.5"/>
+ <run class="X1">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - basic">
+ <compile files="A1.java" options="-1.5"/>
+ <run class="A1">
+ <stderr>
+ <line text="advice from ataj aspect"/>
+ <line text="faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - forget to pass target">
+ <compile files="X2.java" options="-1.5">
+ <message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - forget to pass target">
+ <compile files="A2.java" options="-1.5">
+ <message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
+ </compile>
+ </ajc-test>
+
+
+ <ajc-test dir="features151/ataround" title="code style - incorrect arg types">
+ <compile files="X3.java" options="-1.5">
+ <message kind="error" line="7" text="Type mismatch: cannot convert from String to M"/>
+ <message kind="error" line="7" text="Type mismatch: cannot convert from M to String"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - incorrect arg types">
+ <compile files="A3.java" options="-1.5">
+ <message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
+ </compile>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - correct usage, binding and passing new target for call">
+ <compile files="X4.java" options="-1.5"/>
+ <run class="X4">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="1faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing new target for call">
+ <compile files="A4.java" options="-1.5"/>
+ <run class="A4">
+ <stderr>
+ <line text="advice from ataj aspect"/>
+ <line text="1faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - changing target for call">
+ <compile files="X5.java" options="-1.5"/>
+ <run class="X5">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - changing target for call">
+ <compile files="A5.java" options="-1.5"/>
+ <run class="A5">
+ <stderr>
+ <line text="advice from ataj aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - changing target for call - reverse order">
+ <compile files="X6.java" options="-1.5"/>
+ <run class="X6">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - changing target for call - reverse order">
+ <compile files="A6.java" options="-1.5"/>
+ <run class="A6">
+ <stderr>
+ <line text="advice from ataj aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - bind this on call - change on proceed - no effect">
+ <compile files="X7.java" options="-1.5"/>
+ <run class="X7">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="1faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - bind this on call - change on proceed - no effect">
+ <compile files="A7.java" options="-1.5"/>
+ <run class="A7">
+ <stderr>
+ <line text="advice from ataj aspect"/>
+ <line text="1faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - bind this on execution - change on proceed - works">
+ <compile files="X8.java" options="-1.5"/>
+ <run class="X8">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - bind this on execution - change on proceed - works">
+ <compile files="A8.java" options="-1.5"/>
+ <run class="A8">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="2faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - bind this and target on execution - change on proceed - works">
+ <compile files="X9.java" options="-1.5"/>
+ <run class="X9">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - bind this and target on execution - change on proceed - works">
+ <compile files="A9.java" options="-1.5"/>
+ <run class="A9">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - bind this and target on call - change on proceed - works">
+ <compile files="X10.java" options="-1.5"/>
+ <run class="X10">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - bind this and target on call - change on proceed - works">
+ <compile files="A10.java" options="-1.5"/>
+ <run class="A10">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3faked"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+
+ <ajc-test dir="features151/ataround" title="code style - works with subset of arguments in advice">
+ <compile files="X11.java" options="-1.5"/>
+ <run class="X11">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3x_z"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features151/ataround" title="annotation style - works with subset of arguments in advice">
+ <compile files="A11.java" options="-1.5"/>
+ <run class="A11">
+ <stderr>
+ <line text="advice from code aspect"/>
+ <line text="3x_z"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+</suite> \ No newline at end of file