diff options
author | acolyer <acolyer> | 2005-09-21 14:59:55 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-21 14:59:55 +0000 |
commit | a39f595c0cdcddf8eac0b99e1918d0578f2dc501 (patch) | |
tree | 94865da1d5f277582d9d0720347693cd3b3c258a /tests | |
parent | fc2d08e2ae9d03fb377bd0ed0bd56983af4687a5 (diff) | |
download | aspectj-a39f595c0cdcddf8eac0b99e1918d0578f2dc501.tar.gz aspectj-a39f595c0cdcddf8eac0b99e1918d0578f2dc501.zip |
tests and implementation for 108120 - runtime pointcut parsing and matching.
Diffstat (limited to 'tests')
7 files changed, 67 insertions, 1 deletions
diff --git a/tests/java5/ataspectj/annotationGen/PCLib.aj b/tests/java5/ataspectj/annotationGen/PCLib.aj new file mode 100644 index 000000000..f41c9412f --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PCLib.aj @@ -0,0 +1,7 @@ +public aspect PCLib { + + public pointcut anyMethodExecution() : execution(* *(..)); + + public pointcut joinPointWithStringArg(String s) : args(s); + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj b/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj index d6902c9ea..6c1e3b8f3 100644 --- a/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj +++ b/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj @@ -12,12 +12,20 @@ public aspect PointcutsWithParams { Class[] params = p1.getParameterTypes(); if (params.length != 1) throw new RuntimeException("expecting one param"); if (!params[0].equals(String.class)) throw new RuntimeException("expecting a String"); + String[] names = p1.getParameterNames(); + if (names.length != 1) throw new RuntimeException("expecting one name"); + if (!names[0].equals("s")) throw new RuntimeException("expecting 's', found " + names[0]); Pointcut p2 = myType.getPointcut("pc2"); params = p2.getParameterTypes(); if (params.length != 3) throw new RuntimeException("expecting three params"); if (!params[0].equals(Integer.class)) throw new RuntimeException("expecting an Integer"); if (!params[1].equals(Double.class)) throw new RuntimeException("expecting a Double"); if (!params[2].equals(String.class)) throw new RuntimeException("expecting a String"); + names = p2.getParameterNames(); + if (names.length != 3) throw new RuntimeException("expecting one name"); + if (!names[0].equals("i")) throw new RuntimeException("expecting 'i', found '" + names[0] + "'"); + if (!names[1].equals("d")) throw new RuntimeException("expecting 'd', found '" + names[1] + "'"); + if (!names[2].equals("s")) throw new RuntimeException("expecting 's', found '" + names[2] + "'"); } }
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java b/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java new file mode 100644 index 000000000..8f9e530d5 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java @@ -0,0 +1,32 @@ +import org.aspectj.weaver.tools.*; +import java.lang.reflect.*; + +public class RuntimePointcuts { + + + public static void main(String[] args) throws Exception { + PointcutParser parser = new PointcutParser(); + PointcutExpression pc1 = parser.parsePointcutExpression("PCLib.anyMethodExecution()"); + PointcutParameter param = parser.createPointcutParameter("s",String.class); + PointcutExpression pc2 = parser.parsePointcutExpression("PCLib.joinPointWithStringArg(s)",RuntimePointcuts.class,new PointcutParameter[] {param}); + Method foo = RuntimePointcuts.class.getDeclaredMethod("foo", new Class[0]); + Method bar = RuntimePointcuts.class.getDeclaredMethod("bar",new Class[] {String.class}); + ShadowMatch fooMatch1 = pc1.matchesMethodExecution(foo); + if (!fooMatch1.alwaysMatches()) throw new RuntimeException("fooMatch1 should always match"); + ShadowMatch fooMatch2 = pc2.matchesMethodExecution(foo); + if (!fooMatch2.neverMatches()) throw new RuntimeException("fooMatch2 should never match"); + ShadowMatch barMatch1 = pc1.matchesMethodExecution(bar); + if (!barMatch1.alwaysMatches()) throw new RuntimeException("barMatch1 should always match"); + ShadowMatch barMatch2 = pc2.matchesMethodExecution(bar); + if (!barMatch2.alwaysMatches()) throw new RuntimeException("barMatch2 should always match"); + JoinPointMatch jpm = barMatch2.matchesJoinPoint(new Object(),new Object(),new Object[] {"hello"}); + if (!jpm.matches()) throw new RuntimeException("should match at join point"); + if (!jpm.getParameterBindings()[0].getBinding().toString().equals("hello")) + throw new RuntimeException("expecting s to be bound to hello"); + } + + public void foo() {} + + public void bar(String s) {} + +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index c6d3edfa9..5d31fbb16 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -439,7 +439,11 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("raw and generic type conversion with itd cons"); } - public void testUnableToBuildShadows_pr109728() { runTest("Unable to build shadows");} + public void testAtAnnotationBindingWithAround() { + runTest("@annotation binding with around advice"); + } + + public void testUnableToBuildShadows_pr109728() { runTest("Unable to build shadows");} // helper methods..... diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 7d89c1dac..f0bbef6a9 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -590,6 +590,11 @@ <compile files="" options=" -emacssym, -sourceroots ." > </compile> </ajc-test> + + <ajc-test dir="bugs150" title="@annotation binding with around advice"> + <compile files="AnnotationBinding.aj" options="-1.5"/> + <run class="AnnotationBinding"/> + </ajc-test> <!-- ============================================================================ --> <!-- ============================================================================ --> diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java index 005210080..ba6717b95 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java @@ -126,5 +126,9 @@ public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase { public void testDeows() { runTest("ann gen for deows"); } + + public void testRuntimePointcutsReferencingCompiledPointcuts() { + runTest("runtime pointcut resolution referencing compiled pointcuts"); + } } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml index 13e738fa6..7e4b09971 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/annotationgen.xml @@ -142,5 +142,11 @@ </compile> <run class="Deow"/> </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="runtime pointcut resolution referencing compiled pointcuts"> + <compile files="PCLib.aj,RuntimePointcuts.java" options="-1.5"> + </compile> + <run class="RuntimePointcuts"/> + </ajc-test> </suite>
\ No newline at end of file |