From bf97cc20ba2315b0e72b239f66c20bc474984789 Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 29 Nov 2005 20:45:38 +0000 Subject: [PATCH] tests for parameter name generation in advice annotations --- tests/bugs150/LocalVarTableGen.aj | 26 ++++++++++++++++++ .../annotationGen/AdviceWithParameters.java | 0 tests/java5/reflection/AdviceWithArgs.aj | 27 +++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 6 +++++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 6 +++++ 5 files changed, 65 insertions(+) create mode 100644 tests/bugs150/LocalVarTableGen.aj create mode 100644 tests/java5/ataspectj/annotationGen/AdviceWithParameters.java create mode 100644 tests/java5/reflection/AdviceWithArgs.aj 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 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 @@ + + + + + + -- 2.39.5