diff options
Diffstat (limited to 'tests/base/test135')
-rw-r--r-- | tests/base/test135/Driver.java | 50 | ||||
-rw-r--r-- | tests/base/test135/JoinPointFields.java | 7 | ||||
-rw-r--r-- | tests/base/test135/TopFoo.java | 6 | ||||
-rw-r--r-- | tests/base/test135/pack/JoinPointFields.java | 35 | ||||
-rw-r--r-- | tests/base/test135/pack/PackFoo.java | 6 | ||||
-rw-r--r-- | tests/base/test135/pack/PackJoinPointFields.java | 6 |
6 files changed, 110 insertions, 0 deletions
diff --git a/tests/base/test135/Driver.java b/tests/base/test135/Driver.java new file mode 100644 index 000000000..7c2b0b5e2 --- /dev/null +++ b/tests/base/test135/Driver.java @@ -0,0 +1,50 @@ +// proper values for thisJoinPoint attributes +// Currently there is a bug (?) in that the parameters value +// of the joinpoint seems to always be null. +package test135; + +import org.aspectj.testing.Tester; + +public class Driver { + public static void main(String[] args) { test(); } + + public static void test() { + + TopFoo foo = new TopFoo(); + JoinPointFields jpf = JoinPointFields.aspectOf(); + + foo.bar(1, "one"); + + Tester.checkEqual(jpf.className, "test135.TopFoo", "className"); + Tester.checkEqual(jpf.methodName, "bar", "methodName"); + Tester.checkEqual(jpf.parameterNames, + new String[] {"intParam", "stringParam"}, + "parameterNames"); + Tester.checkEqual(jpf.parameterTypes, + new Class[] {Integer.TYPE, String.class}, + "parameterTypes"); + //System.out.println(jpf.parameters); + Tester.checkEqual(jpf.parameters, + new Object[] {new Integer(1), "one"}, + "parameters"); //!!! + + test135.pack.PackFoo foo1 = new test135.pack.PackFoo(); + test135.pack.PackJoinPointFields jpf1 = + test135.pack.PackJoinPointFields.aspectOf(); + + foo1.bar(2, "two"); + Tester.checkEqual(jpf1.className, "test135.pack.PackFoo", "className"); + Tester.checkEqual(jpf1.methodName, "bar", "methodName"); + Tester.checkEqual(jpf1.parameterNames, + new String[] {"packIntParam", "packStringParam"}, + "parameterNames"); + Tester.checkEqual(jpf1.parameterTypes, + new Class[] {Integer.TYPE, String.class}, + "parameterTypes"); + Tester.checkEqual(jpf1.parameters, + new Object[] {new Integer(2), "two"}, + "parameters"); + } +} + + diff --git a/tests/base/test135/JoinPointFields.java b/tests/base/test135/JoinPointFields.java new file mode 100644 index 000000000..dd83e7969 --- /dev/null +++ b/tests/base/test135/JoinPointFields.java @@ -0,0 +1,7 @@ +package test135; + +public aspect JoinPointFields extends test135.pack.JoinPointFields issingleton() { //of eachJVM() { + protected pointcut onTypes(): target(*); + + private int x = protectedField; +} diff --git a/tests/base/test135/TopFoo.java b/tests/base/test135/TopFoo.java new file mode 100644 index 000000000..f2d98f40e --- /dev/null +++ b/tests/base/test135/TopFoo.java @@ -0,0 +1,6 @@ +package test135; + +class TopFoo { + public void bar(int intParam, String stringParam) { + } +} diff --git a/tests/base/test135/pack/JoinPointFields.java b/tests/base/test135/pack/JoinPointFields.java new file mode 100644 index 000000000..c541ba2a4 --- /dev/null +++ b/tests/base/test135/pack/JoinPointFields.java @@ -0,0 +1,35 @@ +package test135.pack; + +import org.aspectj.lang.*; +import org.aspectj.lang.reflect.*; + +// a first try at a library class in the test suite +public abstract aspect JoinPointFields { + public String className; + public String methodName; + public String[] parameterNames; + public Class[] parameterTypes; + public Object[] parameters; + + protected int protectedField = 42; + + abstract protected pointcut onTypes(); + + before(): call(!static * *(..)) && onTypes() && !within(JoinPointFields+) { + System.out.println(thisJoinPoint); + + Signature sig = thisJoinPoint.getSignature(); + CodeSignature codeSig = (CodeSignature) sig; + //ReceptionJoinPoint rjp = (ReceptionJoinPoint) thisJoinPoint; + + className = sig.getDeclaringType().getName(); + System.out.println(className); + + methodName = sig.getName(); + parameterNames = codeSig.getParameterNames(); + parameterTypes = codeSig.getParameterTypes(); + //parameters = rjp.getParameters(); + parameters = thisJoinPoint.getArgs(); + System.out.println("DONE: " + thisJoinPoint); + } +} diff --git a/tests/base/test135/pack/PackFoo.java b/tests/base/test135/pack/PackFoo.java new file mode 100644 index 000000000..f00eee490 --- /dev/null +++ b/tests/base/test135/pack/PackFoo.java @@ -0,0 +1,6 @@ +package test135.pack; + +public class PackFoo { + public void bar(int packIntParam, String packStringParam) { + } +} diff --git a/tests/base/test135/pack/PackJoinPointFields.java b/tests/base/test135/pack/PackJoinPointFields.java new file mode 100644 index 000000000..bd6bf46e3 --- /dev/null +++ b/tests/base/test135/pack/PackJoinPointFields.java @@ -0,0 +1,6 @@ +package test135.pack; + +public aspect PackJoinPointFields + extends JoinPointFields issingleton() { /*of eachJVM() {*/ + protected pointcut onTypes(): target(test135.pack.PackFoo); +} |