diff options
author | aclement <aclement> | 2006-06-23 10:57:49 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-06-23 10:57:49 +0000 |
commit | 9d2bb0c6ea27b577797ca6c7ca21959377b40cef (patch) | |
tree | 5e45af074f72a551e68aa950114ce134f7068f84 /tests | |
parent | 5b90af1d60b15994abaef2c9391b890b8605c482 (diff) | |
download | aspectj-9d2bb0c6ea27b577797ca6c7ca21959377b40cef.tar.gz aspectj-9d2bb0c6ea27b577797ca6c7ca21959377b40cef.zip |
three more tests for @Around
Diffstat (limited to 'tests')
-rw-r--r-- | tests/features151/ataround/BugCase1.java | 29 | ||||
-rw-r--r-- | tests/features151/ataround/BugCase2.java | 28 | ||||
-rw-r--r-- | tests/features151/ataround/MultipleArgs.java | 45 |
3 files changed, 102 insertions, 0 deletions
diff --git a/tests/features151/ataround/BugCase1.java b/tests/features151/ataround/BugCase1.java new file mode 100644 index 000000000..4f1c01a34 --- /dev/null +++ b/tests/features151/ataround/BugCase1.java @@ -0,0 +1,29 @@ +import org.aspectj.lang.*; +import org.aspectj.lang.annotation.*; + +@Aspect +public class BugCase1 { + + @Pointcut("call(* setAge(..)) && args(i)") + void setAge(int i) {} + + @Around("setAge(i)") + public Object twiceAsOld(ProceedingJoinPoint thisJoinPoint, int i) { + System.err.println("advice running"); + return thisJoinPoint.proceed(new Object[]{i*2}); + } + +} + + +public class Foo { + int a; + public void setAge(int i) { + System.err.println("Setting age to "+i); + a=i; + } + + public static void main(String[]argv) { + new Foo().setAge(5); + } +} diff --git a/tests/features151/ataround/BugCase2.java b/tests/features151/ataround/BugCase2.java new file mode 100644 index 000000000..f99833e06 --- /dev/null +++ b/tests/features151/ataround/BugCase2.java @@ -0,0 +1,28 @@ +import org.aspectj.lang.*; +import org.aspectj.lang.annotation.*; + +@Aspect +public class ProceedAspect { + + @Pointcut("execution(* setAge(..)) && args(i)") + void setAge(int i) {} + + @Around("setAge(i)") + public Object twiceAsOld(ProceedingJoinPoint thisJoinPoint, int i) { + System.err.println("advice running"); + return thisJoinPoint.proceed(new Object[]{i*2}); + } +} + + +public class Foo { + int a; + public void setAge(int i) { + System.err.println("Setting age to "+i); + a=i; + } + + public static void main(String[]argv) { + new Foo().setAge(5); + } +} diff --git a/tests/features151/ataround/MultipleArgs.java b/tests/features151/ataround/MultipleArgs.java new file mode 100644 index 000000000..b9c5b8f6e --- /dev/null +++ b/tests/features151/ataround/MultipleArgs.java @@ -0,0 +1,45 @@ + +import org.aspectj.lang.annotation.*; + +@Aspect +public class X { + + + @Before("call(* callone(..)) && !within(X) && args(a,b,c)") + public void b1(ProceedingJoinPoint pjp,int a,String b,List c) { + System.err.println("advice running"); + pjp.proceed(new Object[]{a,b,c}); + } + + @Before("call(* calltwo(..)) && !within(X) && args(a,b,c)") + public void b1(ProceedingJoinPoint pjp,String b,List c,int a) { + System.err.println("advice running"); + pjp.proceed(new Object[]{a,b,c}); + } + + @Before("call(* callone(..)) && !within(X) && args(a,b,c) && this(o)") + public void b1(ProceedingJoinPoint pjp,int a,String b,List c,Object o) { + System.err.println("advice running"); + pjp.proceed(new Object[]{o,a,b,c}); + } + + public static void main(String []argv) { + new Test().doit(); + } +} + + +class Test { + public void doit() { + List l = new ArrayList(); + callone(5,"hello",l); + calltwo(5,"hello",l); + callthree(5,"hello",l); + callfour(5,"hello",l); + } + + public void callone(int i,String s, List l) {} + public void calltwo(int i,String s, List l) {} + public void callthree(int i,String s, List l) {} + public void callfour(int i,String s, List l) {} +} |