diff options
author | acolyer <acolyer> | 2005-11-29 20:45:38 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-11-29 20:45:38 +0000 |
commit | bf97cc20ba2315b0e72b239f66c20bc474984789 (patch) | |
tree | 1ca09eeea1deda7ac871a85aeb65ee5157624aac | |
parent | 7cf0d6499ce9894015f192adb68cac3e5501148f (diff) | |
download | aspectj-bf97cc20ba2315b0e72b239f66c20bc474984789.tar.gz aspectj-bf97cc20ba2315b0e72b239f66c20bc474984789.zip |
tests for parameter name generation in advice annotations
-rw-r--r-- | tests/bugs150/LocalVarTableGen.aj | 26 | ||||
-rw-r--r-- | tests/java5/ataspectj/annotationGen/AdviceWithParameters.java | 0 | ||||
-rw-r--r-- | tests/java5/reflection/AdviceWithArgs.aj | 27 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 6 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 6 |
5 files changed, 65 insertions, 0 deletions
diff --git a/tests/bugs150/LocalVarTableGen.aj b/tests/bugs150/LocalVarTableGen.aj new file mode 100644 index 000000000..a281dbb11 --- /dev/null +++ b/tests/bugs150/LocalVarTableGen.aj @@ -0,0 +1,26 @@ +public aspect LocalVarTableGen { + + int x = 5; + + public String foo(String s) { + String myLocal = "" + x + s; + return myLocal; + } + + public String bar(String s) { + String myLocal = "" + x + s; + return myLocal; + } + + before() : execution(* foo(..)) { + System.out.println("before foo"); + } + + after(String in) returning(String out) : + execution(* bar(..)) && args(in) + { + System.out.println("after bar"); + } + + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/AdviceWithParameters.java b/tests/java5/ataspectj/annotationGen/AdviceWithParameters.java new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/AdviceWithParameters.java diff --git a/tests/java5/reflection/AdviceWithArgs.aj b/tests/java5/reflection/AdviceWithArgs.aj new file mode 100644 index 000000000..533b38012 --- /dev/null +++ b/tests/java5/reflection/AdviceWithArgs.aj @@ -0,0 +1,27 @@ +import org.aspectj.lang.annotation.*; +import java.lang.reflect.*; + +public aspect AdviceWithArgs { + + @SuppressAjWarnings + before(String s) : execution(* *(..)) && args(s) { + System.out.println(s); + } + + public static void main(String[] args) throws Exception { + Method[] meths = AdviceWithArgs.class.getMethods(); + boolean found = false; + for (Method meth : meths) { + if (meth.isAnnotationPresent(Before.class)) { + found = true; + Before bAnn = meth.getAnnotation(Before.class); + String argNames = bAnn.argNames(); + if (!argNames.equals("s")) { + throw new RuntimeException("Expected 's' but got '" + argNames + "'"); + } + break; + } + } + if (!found) throw new RuntimeException("Did not find expected advice annotation"); + } +}
\ 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 c692b30d9..3fa9ff605 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -753,6 +753,11 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("double parameter generic abstract type"); } + + public void testArgNamesInAdviceAnnotations() { + runTest("arg names in advice annotations"); + } + /* * Load-time weaving bugs */ @@ -778,6 +783,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { assertNotNull("Should have some relationships but does not",l); } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index fc6457043..7cb13ac68 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -118,6 +118,12 @@ <run class="Simple" classpath="../lib/aspectj/lib/aspectjrt121.jar"/> </ajc-test> + <ajc-test dir="java5/reflection" title="arg names in advice annotations"> + <compile files="AdviceWithArgs.aj" options="-1.5"></compile> + <run class="AdviceWithArgs"/> + </ajc-test> + + <ajc-test dir="java5/reflection" pr="114322" title="reflection on abstract ITDs (Billing example)"> <compile files="ReflectBilling.java,Billing.aj" options="-1.5"/> <run class="ReflectBilling"> |