]> source.dussan.org Git - aspectj.git/commitdiff
tests for parameter name generation in advice annotations
authoracolyer <acolyer>
Tue, 29 Nov 2005 20:45:38 +0000 (20:45 +0000)
committeracolyer <acolyer>
Tue, 29 Nov 2005 20:45:38 +0000 (20:45 +0000)
tests/bugs150/LocalVarTableGen.aj [new file with mode: 0644]
tests/java5/ataspectj/annotationGen/AdviceWithParameters.java [new file with mode: 0644]
tests/java5/reflection/AdviceWithArgs.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

diff --git a/tests/bugs150/LocalVarTableGen.aj b/tests/bugs150/LocalVarTableGen.aj
new file mode 100644 (file)
index 0000000..a281dbb
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/tests/java5/reflection/AdviceWithArgs.aj b/tests/java5/reflection/AdviceWithArgs.aj
new file mode 100644 (file)
index 0000000..533b380
--- /dev/null
@@ -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
index c692b30d9579f18a6b40a815a6d4db6368a3c300..3fa9ff605339a23cd720353146ba574a3ad02948 100644 (file)
@@ -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) {
index fc64570434ad72f4ea3cb924d418b8eb4078f513..7cb13ac685c82ed6ff270a72bad0343df887606c 100644 (file)
                <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">