diff options
author | aclement <aclement> | 2006-02-02 11:31:58 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-02-02 11:31:58 +0000 |
commit | 5f10ab1ee6592619b75d8f157f937d620f92d698 (patch) | |
tree | 0328e782bd99901e63a52c1ad6d757ed6655ba07 /tests/features151/ataround | |
parent | 7a96a40ab7d5418309c4742bdb0225cd0dfb88ff (diff) | |
download | aspectj-5f10ab1ee6592619b75d8f157f937d620f92d698.tar.gz aspectj-5f10ab1ee6592619b75d8f157f937d620f92d698.zip |
@AJ around tests for 126167
Diffstat (limited to 'tests/features151/ataround')
22 files changed, 729 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); } +} |