]> source.dussan.org Git - aspectj.git/commitdiff
tests for 148381
authoraclement <aclement>
Thu, 8 Nov 2007 15:33:36 +0000 (15:33 +0000)
committeraclement <aclement>
Thu, 8 Nov 2007 15:33:36 +0000 (15:33 +0000)
29 files changed:
tests/bugs154/pr148381/error1/META-INF/aop.xml [new file with mode: 0644]
tests/bugs154/pr148381/error1/Main.java [new file with mode: 0644]
tests/bugs154/pr148381/error1/Monitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error1/PerformanceMonitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error1/code.jar [new file with mode: 0644]
tests/bugs154/pr148381/error1/readme [new file with mode: 0644]
tests/bugs154/pr148381/error1/rebuild.sh [new file with mode: 0755]
tests/bugs154/pr148381/error2/META-INF/aop.xml [new file with mode: 0644]
tests/bugs154/pr148381/error2/Main.java [new file with mode: 0644]
tests/bugs154/pr148381/error2/Monitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error2/PerformanceMonitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error2/code.jar [new file with mode: 0644]
tests/bugs154/pr148381/error2/readme [new file with mode: 0644]
tests/bugs154/pr148381/error2/rebuild.sh [new file with mode: 0755]
tests/bugs154/pr148381/error3/META-INF/aop.xml [new file with mode: 0644]
tests/bugs154/pr148381/error3/Main.java [new file with mode: 0644]
tests/bugs154/pr148381/error3/Monitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error3/PerformanceMonitor.java [new file with mode: 0644]
tests/bugs154/pr148381/error3/code.jar [new file with mode: 0644]
tests/bugs154/pr148381/error3/readme [new file with mode: 0644]
tests/bugs154/pr148381/error3/rebuild.sh [new file with mode: 0755]
tests/bugs154/pr148381/readme [new file with mode: 0644]
tests/bugs154/pr148381/simple/META-INF/aop.xml [new file with mode: 0644]
tests/bugs154/pr148381/simple/Main.java [new file with mode: 0644]
tests/bugs154/pr148381/simple/Monitor.java [new file with mode: 0644]
tests/bugs154/pr148381/simple/PerformanceMonitor.java [new file with mode: 0644]
tests/bugs154/pr148381/simple/code.jar [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc154/Ajc154Tests.java
tests/src/org/aspectj/systemtest/ajc154/ajc154.xml

diff --git a/tests/bugs154/pr148381/error1/META-INF/aop.xml b/tests/bugs154/pr148381/error1/META-INF/aop.xml
new file mode 100644 (file)
index 0000000..942caa2
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+    <aspects>
+         <aspect name="test.Monitor"/> 
+    </aspects>
+</aspectj>
diff --git a/tests/bugs154/pr148381/error1/Main.java b/tests/bugs154/pr148381/error1/Main.java
new file mode 100644 (file)
index 0000000..16aef26
--- /dev/null
@@ -0,0 +1,12 @@
+package test;
+
+public class Main {
+        public static void main(String[] args) {
+                new Main().foo();
+        }
+
+        @PerformanceMonitor(expected=1000)
+        public void foo() {
+
+        }
+}
diff --git a/tests/bugs154/pr148381/error1/Monitor.java b/tests/bugs154/pr148381/error1/Monitor.java
new file mode 100644 (file)
index 0000000..540faa8
--- /dev/null
@@ -0,0 +1,29 @@
+package test;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+class Monitor {
+        @Pointcut(value="execution(@PerformanceMonitor * *(..)) && @annotation(monitoringAnnot)", argNames="monitoringAnnot")
+        public void monitored(PerformanceMonitor monitoringAnnot) {}
+
+        // Not enough entries in argNames
+        @Around(value="monitored(monitoringAnnot)", argNames="pjp")
+        public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformanceMonitor monitoringAnnot) throws Throwable {
+                //long start = System.nanoTime();
+                Object ret = pjp.proceed();
+                //long end = System.nanoTime();
+
+                //if(end - start > monitoringAnnot.expected()) {
+                //        System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t"
+                //                        + "Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start));
+                //}
+
+                System.out.println("This method was intercepted by the advice: "+pjp.getSignature().toShortString());
+                return ret;
+        }       
+}
+
diff --git a/tests/bugs154/pr148381/error1/PerformanceMonitor.java b/tests/bugs154/pr148381/error1/PerformanceMonitor.java
new file mode 100644 (file)
index 0000000..e9f6aa3
--- /dev/null
@@ -0,0 +1,9 @@
+package test;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@interface PerformanceMonitor {
+        public int expected();
+}
diff --git a/tests/bugs154/pr148381/error1/code.jar b/tests/bugs154/pr148381/error1/code.jar
new file mode 100644 (file)
index 0000000..6852cb8
Binary files /dev/null and b/tests/bugs154/pr148381/error1/code.jar differ
diff --git a/tests/bugs154/pr148381/error1/readme b/tests/bugs154/pr148381/error1/readme
new file mode 100644 (file)
index 0000000..1ea0ea5
--- /dev/null
@@ -0,0 +1,2 @@
+Error scenario one
+- incorrect number of 'names' in argNames compared the method it is attached to
diff --git a/tests/bugs154/pr148381/error1/rebuild.sh b/tests/bugs154/pr148381/error1/rebuild.sh
new file mode 100755 (executable)
index 0000000..5cb9a02
--- /dev/null
@@ -0,0 +1,2 @@
+javac *.java -d .
+jar -cvMf code.jar test
diff --git a/tests/bugs154/pr148381/error2/META-INF/aop.xml b/tests/bugs154/pr148381/error2/META-INF/aop.xml
new file mode 100644 (file)
index 0000000..942caa2
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+    <aspects>
+         <aspect name="test.Monitor"/> 
+    </aspects>
+</aspectj>
diff --git a/tests/bugs154/pr148381/error2/Main.java b/tests/bugs154/pr148381/error2/Main.java
new file mode 100644 (file)
index 0000000..16aef26
--- /dev/null
@@ -0,0 +1,12 @@
+package test;
+
+public class Main {
+        public static void main(String[] args) {
+                new Main().foo();
+        }
+
+        @PerformanceMonitor(expected=1000)
+        public void foo() {
+
+        }
+}
diff --git a/tests/bugs154/pr148381/error2/Monitor.java b/tests/bugs154/pr148381/error2/Monitor.java
new file mode 100644 (file)
index 0000000..180e10b
--- /dev/null
@@ -0,0 +1,29 @@
+package test;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+class Monitor {
+        @Pointcut(value="execution(@PerformanceMonitor * *(..)) && @annotation(monitoringAnnot)", argNames="monitoringAnnot")
+        public void monitored(PerformanceMonitor monitoringAnnot) {}
+
+        // Not enough entries in argNames
+        @Around(value="monitored(monitoringAnnot)", argNames="")
+        public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformanceMonitor monitoringAnnot) throws Throwable {
+                //long start = System.nanoTime();
+                Object ret = pjp.proceed();
+                //long end = System.nanoTime();
+
+                //if(end - start > monitoringAnnot.expected()) {
+                //        System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t"
+                //                        + "Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start));
+                //}
+
+                System.out.println("This method was intercepted by the advice: "+pjp.getSignature().toShortString());
+                return ret;
+        }       
+}
+
diff --git a/tests/bugs154/pr148381/error2/PerformanceMonitor.java b/tests/bugs154/pr148381/error2/PerformanceMonitor.java
new file mode 100644 (file)
index 0000000..e9f6aa3
--- /dev/null
@@ -0,0 +1,9 @@
+package test;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@interface PerformanceMonitor {
+        public int expected();
+}
diff --git a/tests/bugs154/pr148381/error2/code.jar b/tests/bugs154/pr148381/error2/code.jar
new file mode 100644 (file)
index 0000000..6c01b77
Binary files /dev/null and b/tests/bugs154/pr148381/error2/code.jar differ
diff --git a/tests/bugs154/pr148381/error2/readme b/tests/bugs154/pr148381/error2/readme
new file mode 100644 (file)
index 0000000..7b4e583
--- /dev/null
@@ -0,0 +1,2 @@
+Error scenario two
+- blank argNames supplied
diff --git a/tests/bugs154/pr148381/error2/rebuild.sh b/tests/bugs154/pr148381/error2/rebuild.sh
new file mode 100755 (executable)
index 0000000..5cb9a02
--- /dev/null
@@ -0,0 +1,2 @@
+javac *.java -d .
+jar -cvMf code.jar test
diff --git a/tests/bugs154/pr148381/error3/META-INF/aop.xml b/tests/bugs154/pr148381/error3/META-INF/aop.xml
new file mode 100644 (file)
index 0000000..942caa2
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+    <aspects>
+         <aspect name="test.Monitor"/> 
+    </aspects>
+</aspectj>
diff --git a/tests/bugs154/pr148381/error3/Main.java b/tests/bugs154/pr148381/error3/Main.java
new file mode 100644 (file)
index 0000000..16aef26
--- /dev/null
@@ -0,0 +1,12 @@
+package test;
+
+public class Main {
+        public static void main(String[] args) {
+                new Main().foo();
+        }
+
+        @PerformanceMonitor(expected=1000)
+        public void foo() {
+
+        }
+}
diff --git a/tests/bugs154/pr148381/error3/Monitor.java b/tests/bugs154/pr148381/error3/Monitor.java
new file mode 100644 (file)
index 0000000..de51569
--- /dev/null
@@ -0,0 +1,23 @@
+package test;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+
+class Foo {}
+
+@Aspect
+class Monitor {
+  @Around(value="execution(* *(..))",argNames="")
+  public void b(Foo aa) {}
+  @Pointcut(value="execution(* *(..))",argNames="")
+  public void a(Foo aa) {}
+  @Before(value="execution(* *(..))",argNames="")
+  public void c(Foo aa) {}
+  @After(value="execution(* *(..))",argNames="a,b,c")
+  public void d(Foo aa) {}
+  @AfterThrowing(value="execution(* *(..))",argNames="")
+  public void e(Foo aa) {}
+  @AfterReturning(value="execution(* *(..))",argNames="")
+  public void f(Foo aa) {}
+}
+
diff --git a/tests/bugs154/pr148381/error3/PerformanceMonitor.java b/tests/bugs154/pr148381/error3/PerformanceMonitor.java
new file mode 100644 (file)
index 0000000..e9f6aa3
--- /dev/null
@@ -0,0 +1,9 @@
+package test;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@interface PerformanceMonitor {
+        public int expected();
+}
diff --git a/tests/bugs154/pr148381/error3/code.jar b/tests/bugs154/pr148381/error3/code.jar
new file mode 100644 (file)
index 0000000..91e15cf
Binary files /dev/null and b/tests/bugs154/pr148381/error3/code.jar differ
diff --git a/tests/bugs154/pr148381/error3/readme b/tests/bugs154/pr148381/error3/readme
new file mode 100644 (file)
index 0000000..213f7dc
--- /dev/null
@@ -0,0 +1,2 @@
+Error scenario two
+- wrong argNames for multiple pieces of advice
diff --git a/tests/bugs154/pr148381/error3/rebuild.sh b/tests/bugs154/pr148381/error3/rebuild.sh
new file mode 100755 (executable)
index 0000000..5cb9a02
--- /dev/null
@@ -0,0 +1,2 @@
+javac *.java -d .
+jar -cvMf code.jar test
diff --git a/tests/bugs154/pr148381/readme b/tests/bugs154/pr148381/readme
new file mode 100644 (file)
index 0000000..51cfb57
--- /dev/null
@@ -0,0 +1,7 @@
+rebuilding code.jar is done with:
+
+javac *.java
+jar -cvMf code.jar test
+
+Basically you need to ensure the classes have no local variable tables - that is the default behaviour for javac
+
diff --git a/tests/bugs154/pr148381/simple/META-INF/aop.xml b/tests/bugs154/pr148381/simple/META-INF/aop.xml
new file mode 100644 (file)
index 0000000..942caa2
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+    <aspects>
+         <aspect name="test.Monitor"/> 
+    </aspects>
+</aspectj>
diff --git a/tests/bugs154/pr148381/simple/Main.java b/tests/bugs154/pr148381/simple/Main.java
new file mode 100644 (file)
index 0000000..16aef26
--- /dev/null
@@ -0,0 +1,12 @@
+package test;
+
+public class Main {
+        public static void main(String[] args) {
+                new Main().foo();
+        }
+
+        @PerformanceMonitor(expected=1000)
+        public void foo() {
+
+        }
+}
diff --git a/tests/bugs154/pr148381/simple/Monitor.java b/tests/bugs154/pr148381/simple/Monitor.java
new file mode 100644 (file)
index 0000000..fdba651
--- /dev/null
@@ -0,0 +1,28 @@
+package test;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+class Monitor {
+        @Pointcut(value="execution(@PerformanceMonitor * *(..)) && @annotation(monitoringAnnot)", argNames="monitoringAnnot")
+        public void monitored(PerformanceMonitor monitoringAnnot) {}
+
+        @Around(value="monitored(monitoringAnnot)", argNames="pjp, monitoringAnnot")
+        public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformanceMonitor monitoringAnnot) throws Throwable {
+                //long start = System.nanoTime();
+                Object ret = pjp.proceed();
+                //long end = System.nanoTime();
+
+                //if(end - start > monitoringAnnot.expected()) {
+                //        System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t"
+                //                        + "Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start));
+                //}
+
+                System.out.println("This method was intercepted by the advice: "+pjp.getSignature().toShortString());
+                return ret;
+        }       
+}
+
diff --git a/tests/bugs154/pr148381/simple/PerformanceMonitor.java b/tests/bugs154/pr148381/simple/PerformanceMonitor.java
new file mode 100644 (file)
index 0000000..e9f6aa3
--- /dev/null
@@ -0,0 +1,9 @@
+package test;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@interface PerformanceMonitor {
+        public int expected();
+}
diff --git a/tests/bugs154/pr148381/simple/code.jar b/tests/bugs154/pr148381/simple/code.jar
new file mode 100644 (file)
index 0000000..4a30b29
Binary files /dev/null and b/tests/bugs154/pr148381/simple/code.jar differ
index 731c8777a94143ba47f3e7df17b02dc4a0c34fe9..c29ea92f9ce3b3c0ae2796fdcc86900c9a96a58b 100644 (file)
@@ -45,6 +45,10 @@ public class Ajc154Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 //             runTest("new pointcut designators in a reference pointcut");
 //     }
 
+       public void testArgNamesDoesNotWork_pr148381_1() { runTest("argNames does not work - simple");}
+       public void testArgNamesDoesNotWork_pr148381_2() { runTest("argNames does not work - error1");}
+       public void testArgNamesDoesNotWork_pr148381_3() { runTest("argNames does not work - error2");}
+       public void testArgNamesDoesNotWork_pr148381_4() { runTest("argNames does not work - error3");}
        //public void testAsteriskInAtPointcut_pr209051() { runTest("asterisk in at aj pointcut");}
        public void testDecpProblemWhenTargetAlreadyImplements_pr169432_1() { runTest("declare parents problem when target already implements interface - 1");}
        public void testDecpProblemWhenTargetAlreadyImplements_pr169432_2() { runTest("declare parents problem when target already implements interface - 2");}
index 73ae018394497c286dcee9b06bfcc78dd2e03b87..16c5d0be780a935903c552669c99ac7b183450d0 100644 (file)
@@ -3,6 +3,64 @@
 <!-- AspectJ v1.6.0 Tests -->
 <suite>
 
+
+   <ajc-test dir="bugs154/pr148381/simple" title="argNames does not work - simple">
+     <!-- this compile is just to get code.jar into the sandbox, all the code is already precompiled in code.jar -->
+     <compile options="-1.5" files="PerformanceMonitor.java" classpath="code.jar"/>
+     <run class="test.Main" classpath="code.jar" ltw="META-INF/aop.xml">
+       <stdout>
+         <line text="This method was intercepted by the advice: Main.foo()"/>
+       </stdout>
+       <stderr/>
+     </run>
+   </ajc-test>
+
+   <ajc-test dir="bugs154/pr148381/error1" title="argNames does not work - error1">
+     <!-- this compile is just to get code.jar into the sandbox, all the code is already precompiled in code.jar -->
+     <compile options="-1.5" files="PerformanceMonitor.java" classpath="code.jar"/>
+     <run class="test.Main" classpath="code.jar" ltw="META-INF/aop.xml">
+       <stderr>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'Object flagExpectationMismatch(ProceedingJoinPoint,PerformanceMonitor)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+       </stderr>
+       <stdout/>
+     </run>
+   </ajc-test>
+
+   <ajc-test dir="bugs154/pr148381/error2" title="argNames does not work - error2">
+     <!-- this compile is just to get code.jar into the sandbox, all the code is already precompiled in code.jar -->
+     <compile options="-1.5" files="PerformanceMonitor.java" classpath="code.jar"/>
+     <run class="test.Main" classpath="code.jar" ltw="META-INF/aop.xml">
+       <stderr>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'Object flagExpectationMismatch(ProceedingJoinPoint,PerformanceMonitor)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+       </stderr>
+       <stdout/>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="bugs154/pr148381/error3" title="argNames does not work - error3">
+     <!-- this compile is just to get code.jar into the sandbox, all the code is already precompiled in code.jar -->
+     <compile options="-1.5" files="PerformanceMonitor.java" classpath="code.jar"/>
+     <run class="test.Main" classpath="code.jar" ltw="META-INF/aop.xml">
+       <stderr>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void a(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void f(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void e(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void d(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void c(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+         <line text="argNames annotation value does not specify the right number of argument names for the method 'void b(Foo)'"/>
+         <line text="Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '&lt;javac debug='true'.../&gt;' in Ant)"/>
+       </stderr>
+       <stdout/>
+     </run>
+   </ajc-test>
+   
    <ajc-test dir="bugs154/pr209051" title="asterisk in at aj pointcut">
      <compile options="-1.5" files="Bug.java"/>
      <run class="Bug">