]> source.dussan.org Git - aspectj.git/commitdiff
219419: test and fix
authoraclement <aclement>
Fri, 5 Dec 2008 21:57:45 +0000 (21:57 +0000)
committeraclement <aclement>
Fri, 5 Dec 2008 21:57:45 +0000 (21:57 +0000)
tests/bugs163/pr219419/Code.java [new file with mode: 0644]
tests/bugs163/pr219419/Code2.java [new file with mode: 0644]
tests/bugs163/pr219419/Code3.java [new file with mode: 0644]
tests/bugs163/pr219419/Code4.java [new file with mode: 0644]
tests/bugs163/pr219419/Code5.java [new file with mode: 0644]

diff --git a/tests/bugs163/pr219419/Code.java b/tests/bugs163/pr219419/Code.java
new file mode 100644 (file)
index 0000000..c0c523f
--- /dev/null
@@ -0,0 +1,26 @@
+import org.aspectj.lang.annotation.*;
+
+public class Code {
+  public void emitGooeyMess(String argument) throws Exception {
+    throw new RuntimeException("Gooey Mess");
+  }
+
+  public static void main(String []argv) {
+         try {
+         new Code().emitGooeyMess("ewwww");
+         } catch (Exception e) {}
+  }
+}
+
+@Aspect
+class TestAspect {
+  @Pointcut("execution(* Code.*(..)) && args(s)")
+  public void squidStringMethods(String s) {}
+
+  @AfterThrowing(pointcut="squidStringMethods(s)", throwing="e")
+  public void catchGooeyMess(Exception e, String s) {
+  //public void catchGooeyMess(String s, Exception e) {
+    System.out.println("Catching mess. Argument was " + s);
+  }
+}
+
diff --git a/tests/bugs163/pr219419/Code2.java b/tests/bugs163/pr219419/Code2.java
new file mode 100644 (file)
index 0000000..bda50ae
--- /dev/null
@@ -0,0 +1,26 @@
+import org.aspectj.lang.annotation.*;
+
+public class Code2 {
+  public void emitGooeyMess(String argument) throws Exception {
+    throw new RuntimeException("Gooey Mess");
+  }
+
+  public static void main(String []argv) {
+         try {
+         new Code2().emitGooeyMess("ewwww");
+         } catch (Exception e) {}
+  }
+}
+
+@Aspect
+class TestAspect {
+  @Pointcut("execution(* Code2.*(..)) && args(s)")
+  public void squidStringMethods(String s) {}
+
+  @AfterThrowing(pointcut="squidStringMethods(s)", throwing="e")
+  public void catchGooeyMess(String s, Exception e) {
+  //public void catchGooeyMess(String s, Exception e) {
+    System.out.println("Catching mess. Argument was " + s);
+  }
+}
+
diff --git a/tests/bugs163/pr219419/Code3.java b/tests/bugs163/pr219419/Code3.java
new file mode 100644 (file)
index 0000000..9180269
--- /dev/null
@@ -0,0 +1,39 @@
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+
+public class Code3 {
+
+  public Object createBean(String name) {
+    return 37;
+  }
+
+  public static void main(String[] args) {
+    Code3 factory = new Code3();
+    System.out.println("Code3.main returned from call to createBean "+factory.createBean("s"));
+  }
+}
+
+@Aspect
+class AfterReturningTestAspect {
+
+  @AfterReturning(pointcut = "call(Object createBean(String)) && args(beanName)", returning = "bean")
+  // this does not run
+  public void afterReturningCreateBean(/*JoinPoint joinPoint,*/ String beanName, Object bean) throws Throwable {
+  // this matches:
+  //public void afterReturningCreateBean(JoinPoint joinPoint, Object bean, String beanName) throws Throwable {
+    System.out.println("afterReturningCreateBean advice input='" + beanName + "' ret=" + bean);
+  }
+
+  /*
+  @AfterReturning(pointcut = "call(Object aspects.SimpleAfterReturningTest.createBean(String)) " +
+                                                               "&& args(beanName)", returning = "bean")
+                               public void afterReturningCreateBean(JoinPoint joinPoint, Object bean,
+                                               String beanName) throws Throwable {
+                                               System.out.println("afterReturningCreateBean(JoinPoint joinPoint,
+                                               Object bean, String beanName) for '" + beanName + "'=" + bean);
+                                                   }
+                                                   */
+}
+
diff --git a/tests/bugs163/pr219419/Code4.java b/tests/bugs163/pr219419/Code4.java
new file mode 100644 (file)
index 0000000..be0f66b
--- /dev/null
@@ -0,0 +1,36 @@
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+
+public class Code4 {
+
+  public Object createBean(String name) {
+    return 37;
+  }
+
+  public static void main(String[] args) {
+    Code4 factory = new Code4();
+    System.out.println("Code4.main returned from call to createBean "+factory.createBean("s"));
+  }
+}
+
+@Aspect
+class AfterReturningTestAspect {
+
+  @AfterReturning(pointcut = "call(Object createBean(String)) && args(beanName)", returning = "bean")
+  public void afterReturningCreateBean(Object bean, String beanName) throws Throwable {
+    System.out.println("afterReturningCreateBean advice input='" + beanName + "' ret=" + bean);
+  }
+
+  /*
+  @AfterReturning(pointcut = "call(Object aspects.SimpleAfterReturningTest.createBean(String)) " +
+                                                               "&& args(beanName)", returning = "bean")
+                               public void afterReturningCreateBean(JoinPoint joinPoint, Object bean,
+                                               String beanName) throws Throwable {
+                                               System.out.println("afterReturningCreateBean(JoinPoint joinPoint,
+                                               Object bean, String beanName) for '" + beanName + "'=" + bean);
+                                                   }
+                                                   */
+}
+
diff --git a/tests/bugs163/pr219419/Code5.java b/tests/bugs163/pr219419/Code5.java
new file mode 100644 (file)
index 0000000..aa5a741
--- /dev/null
@@ -0,0 +1,27 @@
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+
+public class Code5 {
+
+  public Object createBean(String name) {
+    return 37;
+  }
+
+  public static void main(String[] args) {
+    Code5 factory = new Code5();
+    System.out.println("Code5.main returned from call to createBean "+factory.createBean("s"));
+  }
+}
+
+@Aspect
+class AfterReturningTestAspect {
+
+  @AfterReturning(pointcut = "call(Object createBean(String)) && args(beanName)", returning = "bean")
+  public void afterReturningCreateBean(JoinPoint joinPoint, String beanName, Object bean) throws Throwable {
+    System.out.println("afterReturningCreateBean advice input='" + beanName + "' ret=" + bean);
+  }
+
+}
+