diff options
author | acolyer <acolyer> | 2005-04-25 16:14:07 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-04-25 16:14:07 +0000 |
commit | 90e41018152ca4f04e4442e5fae02ee2b97c2a61 (patch) | |
tree | 8239fcc928f949a9e9e04286f694bce362985ff5 /tests | |
parent | cce34110147c340556de02464bb609f947d9f075 (diff) | |
download | aspectj-90e41018152ca4f04e4442e5fae02ee2b97c2a61.tar.gz aspectj-90e41018152ca4f04e4442e5fae02ee2b97c2a61.zip |
test cases for @AspectJ visitors
Diffstat (limited to 'tests')
34 files changed, 850 insertions, 35 deletions
diff --git a/tests/java5/ataspectj/SimpleBefore.java b/tests/java5/ataspectj/SimpleBefore.java index 2327881b4..8b5019f94 100644 --- a/tests/java5/ataspectj/SimpleBefore.java +++ b/tests/java5/ataspectj/SimpleBefore.java @@ -14,7 +14,7 @@ public class SimpleBefore { X.s.append("2"); } - @Aspect("issingleton") + @Aspect("issingleton()") public static class X { public static StringBuffer s = new StringBuffer(""); diff --git a/tests/java5/ataspectj/annotationGen/APointcut.java b/tests/java5/ataspectj/annotationGen/APointcut.java new file mode 100644 index 000000000..32d504dfd --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/APointcut.java @@ -0,0 +1,13 @@ +import org.aspectj.lang.reflect.*; + +public class APointcut { + + @org.aspectj.lang.annotation.Pointcut("execution(* *.*(..))") + void myPointcut() {}; + + public static void main(String[] args) throws Exception { + AjType myType = AjTypeSystem.getAjType(APointcut.class); + Pointcut pc = myType.getDeclaredPointcut("myPointcut"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/AdviceInAClass.java b/tests/java5/ataspectj/annotationGen/AdviceInAClass.java new file mode 100644 index 000000000..9929781cd --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/AdviceInAClass.java @@ -0,0 +1,8 @@ +import org.aspectj.lang.annotation.Before; + +public class AdviceInAClass { + + @Before("execution(* *(..))") + public void doSomething() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/AfterReturningWithBadPCut.java b/tests/java5/ataspectj/annotationGen/AfterReturningWithBadPCut.java new file mode 100644 index 000000000..6c36178bf --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/AfterReturningWithBadPCut.java @@ -0,0 +1,9 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public class AfterReturningWithBadPCut { + + @AfterReturning("excution(* *.*(..))") + public void logExit() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/BadParameterBinding.java b/tests/java5/ataspectj/annotationGen/BadParameterBinding.java new file mode 100644 index 000000000..8e4c2e58f --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/BadParameterBinding.java @@ -0,0 +1,18 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public class BadParameterBinding { + + @SuppressAjWarnings + @Before("execution(* *(..)) && this(bpb)") + public void logEntry(BadParameterBinding bpb) {} + + @SuppressAjWarnings + @AfterReturning("execution(* *(..)) && this(bpb)") + public void logExit() {} + + @SuppressAjWarnings + @AfterThrowing("call(* TheUnknownType.*(..))") + public void logException() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/BasicAdvice.aj b/tests/java5/ataspectj/annotationGen/BasicAdvice.aj new file mode 100644 index 000000000..04fb00be7 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/BasicAdvice.aj @@ -0,0 +1,122 @@ + +import java.lang.reflect.Method; +import org.aspectj.lang.annotation.*; + +public aspect BasicAdvice { + + @SuppressAjWarnings + before() : execution(* *.*(..)) { + // + } + + @SuppressAjWarnings + after() : call(* Integer.*(..)) { + + } + + @SuppressAjWarnings + after() returning : get(String *) { + + } + + @SuppressAjWarnings + after() returning(String strVal) : get(String *) { + + } + + @SuppressAjWarnings + after() throwing : execution(* *.*(..)) { + + } + + @SuppressAjWarnings + after() throwing(RuntimeException ex) : execution(* *.*(..)) { + + } + + @SuppressAjWarnings + void around() : set(* foo) { + proceed(); + } + + private static int adviceCount = 0; + + public static void main(String[] args) { + Method[] methods = BasicAdvice.class.getDeclaredMethods(); + for (Method method : methods) { + adviceCount++; + if (method.getName().startsWith("ajc$before$")) { + checkBefore(method); + } else if (method.getName().startsWith("ajc$after$")) { + checkAfter(method); + } else if (method.getName().startsWith("ajc$afterReturning$")) { + checkAfterReturning(method); + } else if (method.getName().startsWith("ajc$afterThrowing$")) { + checkAfterThrowing(method); + } else if (method.getName().startsWith("ajc$around$")) { + if (!method.getName().endsWith("proceed")) { + checkAround(method); + } else { + adviceCount--; + } + } else { + adviceCount--; + } + } + if (adviceCount != 7) throw new RuntimeException("Expected 7 advice methods, found " + adviceCount); + } + + private static void checkBefore(Method method) { + assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); + Before beforeAnnotation = method.getAnnotation(Before.class); + assertTrue("expecting execution(* *.*(..))",beforeAnnotation.value().equals("execution(* *.*(..))")); + } + + private static void checkAfter(Method method) { + assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); + After afterAnnotation = method.getAnnotation(After.class); + assertTrue("expecting call(* Integer.*(..))",afterAnnotation.value().equals("call(* Integer.*(..))")); + } + + private static void checkAfterReturning(Method method) { + assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); + AfterReturning afterAnnotation = method.getAnnotation(AfterReturning.class); + if (method.getParameterTypes().length == 1) { + // form with returning arg + assertTrue("expecting get(String *)",afterAnnotation.pointcut().equals("get(String *)")); + assertTrue("expecting empty",afterAnnotation.value().equals("")); + assertTrue("expecting strVal",afterAnnotation.returning().equals("strVal")); + } else { + // form without returning arg + assertTrue("expecting get(String *)",afterAnnotation.pointcut().equals("get(String *)")); + assertTrue("expecting empty",afterAnnotation.value().equals("")); + assertTrue("expecting empty returning",afterAnnotation.returning().equals("")); + } + } + + private static void checkAfterThrowing(Method method) { + assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); + AfterThrowing afterAnnotation = method.getAnnotation(AfterThrowing.class); + if (method.getParameterTypes().length == 1) { + // form with returning arg + assertTrue("expecting execution(* *.*(..))",afterAnnotation.pointcut().equals("execution(* *.*(..))")); + assertTrue("expecting empty",afterAnnotation.value().equals("")); + assertTrue("expecting ex",afterAnnotation.throwing().equals("ex")); + } else { + // form without returning arg + assertTrue("expecting execution(* *.*(..))",afterAnnotation.pointcut().equals("execution(* *.*(..))")); + assertTrue("expecting empty",afterAnnotation.value().equals("")); + assertTrue("expecting empty throwing",afterAnnotation.throwing().equals("")); + } + } + + private static void checkAround(Method method) { + assertTrue("expecting 2 annotations",method.getAnnotations().length == 2); + Around aroundAnnotation = method.getAnnotation(Around.class); + assertTrue("expecting set(* foo)",aroundAnnotation.value().equals("set(* foo)")); + } + + private static void assertTrue(String msg, boolean expr) { + if (!expr) throw new RuntimeException(msg); + } +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/BeforeWithBadReturn.java b/tests/java5/ataspectj/annotationGen/BeforeWithBadReturn.java new file mode 100644 index 000000000..e219e9181 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/BeforeWithBadReturn.java @@ -0,0 +1,9 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public class BeforeWithBadReturn { + + @Before("execution(* *(..))") + public String logEntry() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/InnerAspectAspect.aj b/tests/java5/ataspectj/annotationGen/InnerAspectAspect.aj new file mode 100644 index 000000000..324c9bb3a --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/InnerAspectAspect.aj @@ -0,0 +1,15 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect InnerAspectAspect { + + public static void main(String[] args) { + Annotation[] annotations = InnerAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + } + + private static aspect InnerAspect {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/InnerAspectClass.aj b/tests/java5/ataspectj/annotationGen/InnerAspectClass.aj new file mode 100644 index 000000000..91842f521 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/InnerAspectClass.aj @@ -0,0 +1,15 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public class InnerAspectClass { + + public static void main(String[] args) { + Annotation[] annotations = InnerAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + } + + private static aspect InnerAspect {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PerCflowAspect.aj b/tests/java5/ataspectj/annotationGen/PerCflowAspect.aj new file mode 100644 index 000000000..e0190caf7 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PerCflowAspect.aj @@ -0,0 +1,20 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect PerCflowAspect percflow(execution(* Foo.foo(..))) { + + public static void main(String[] args) { + Annotation[] annotations = PerCflowAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("percflow(execution(* Foo.foo(..)))")) + throw new RuntimeException("value should be equal to perclause but was: " + aspectAnnotation.value()); + } + +} + +class Foo { + + void foo() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PerCflowbelowAspect.aj b/tests/java5/ataspectj/annotationGen/PerCflowbelowAspect.aj new file mode 100644 index 000000000..4018bafed --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PerCflowbelowAspect.aj @@ -0,0 +1,19 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect PerCflowbelowAspect percflowbelow(execution(* Foo.foo(..))) { + + public static void main(String[] args) { + Annotation[] annotations = PerCflowbelowAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("percflowbelow(execution(* Foo.foo(..)))")) throw new RuntimeException("value should be equal to perclause"); + } + +} + +class Foo { + + void foo() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PerTargetAspect.aj b/tests/java5/ataspectj/annotationGen/PerTargetAspect.aj new file mode 100644 index 000000000..c436b8fca --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PerTargetAspect.aj @@ -0,0 +1,21 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect PerTargetAspect pertarget(fooCall()) { + + pointcut fooCall() : call(* Foo.foo(..)); + + public static void main(String[] args) { + Annotation[] annotations = PerTargetAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("pertarget(fooCall())")) throw new RuntimeException("value should be equal to perclause"); + } + +} + +class Foo { + + void foo() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PerThisAspect.aj b/tests/java5/ataspectj/annotationGen/PerThisAspect.aj new file mode 100644 index 000000000..1521b4b4c --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PerThisAspect.aj @@ -0,0 +1,19 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect PerThisAspect perthis(execution(* Foo.foo(..))) { + + public static void main(String[] args) { + Annotation[] annotations = PerThisAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("perthis(execution(* Foo.foo(..)))")) throw new RuntimeException("value should be equal to perclause"); + } + +} + +class Foo { + + void foo() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PerTypeWithinAspect.aj b/tests/java5/ataspectj/annotationGen/PerTypeWithinAspect.aj new file mode 100644 index 000000000..3b435604d --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PerTypeWithinAspect.aj @@ -0,0 +1,13 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect PerTypeWithinAspect pertypewithin(javax.ejb..*) { + + public static void main(String[] args) { + Annotation[] annotations = PerTypeWithinAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("pertypewithin(javax.ejb..*)")) throw new RuntimeException("value should be equal to perclause"); + } + +} diff --git a/tests/java5/ataspectj/annotationGen/PointcutAssortment.java b/tests/java5/ataspectj/annotationGen/PointcutAssortment.java new file mode 100644 index 000000000..1237b28cd --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PointcutAssortment.java @@ -0,0 +1,42 @@ +import org.aspectj.lang.annotation.*; + +public class PointcutAssortment { + + @Pointcut("execution(* PointcutAssortment.*(..))") + void pc1() {} + + @Pointcut("call(* PointcutAssortment.*(..))") + String pc2() {} + + @Pointcut("foo()") + void pc3() {} + + @Pointcut("pc1() || pc2()") + void pc4() { + System.out.println("hi there!"); + } + + @Pointcut("this(Integer)") + void pc5() {} + + @Pointcut("this(i)") + void pc6(Integer i) {} + + @Pointcut("OtherClass.intSet() && pc6(myInt)") + void pc7(Integer myInt) {} + + @Pointcut("get(* *)") + @Pointcut("set(* *)") + void pc8() {} + + @Pointcut("target(foo)") + void pc9() {} + +} + +class OtherClass { + + @Pointcut("set(Integer *)") + void intSet() {}; + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PointcutModifiers.aj b/tests/java5/ataspectj/annotationGen/PointcutModifiers.aj new file mode 100644 index 000000000..88e1769cf --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PointcutModifiers.aj @@ -0,0 +1,45 @@ +import org.aspectj.lang.reflect.*; +import java.lang.reflect.*; + +public abstract aspect PointcutModifiers { + + protected abstract pointcut p1(); + + pointcut p2(); + + public pointcut p3(): get(String s); + + protected pointcut p4() : set(String s); + + private pointcut p5() : call(* String.*(..)); + + public static void main(String[] args) throws NoSuchPointcutException { + AjType myType = AjTypeSystem.getAjType(PointcutModifiers.class); + assertTrue(myType != null, "found my type"); + Pointcut[] pointcuts = myType.getDeclaredPointcuts(); + assertTrue(pointcuts != null, "found some pointcuts"); + if (pointcuts.length != 5) throw new RuntimeException("Expecting 5 pointcuts"); + Pointcut pc1 = myType.getDeclaredPointcut("p1"); + assertTrue(pc1 != null, "found pc1"); + Pointcut pc2 = myType.getDeclaredPointcut("p2"); + assertTrue(pc2 != null, "found pc2"); + Pointcut pc3 = myType.getDeclaredPointcut("p3"); + assertTrue(pc3 != null, "found pc3"); + Pointcut pc4 = myType.getDeclaredPointcut("p4"); + assertTrue(pc4 != null, "found pc4"); + Pointcut pc5 = myType.getDeclaredPointcut("p5"); + assertTrue(pc5 != null, "found pc5"); + assertTrue(Modifier.isAbstract(pc1.getModifiers()),"pc1 is abstract" ); + assertTrue(Modifier.isProtected(pc1.getModifiers()),"pc1 is protected"); + assertTrue(!Modifier.isPrivate(pc2.getModifiers()),"pc2 not private"); + assertTrue(!Modifier.isPublic(pc2.getModifiers()),"pc2 not public"); + assertTrue(!Modifier.isProtected(pc2.getModifiers()),"pc2 not protected"); + assertTrue(Modifier.isPublic(pc3.getModifiers()),"pc3 is public"); + assertTrue(Modifier.isProtected(pc4.getModifiers()),"pc1 is protected"); + assertTrue(Modifier.isPrivate(pc5.getModifiers()),"pc5 is private"); + } + + private static void assertTrue(boolean expr, String msg) { + if (!expr) throw new RuntimeException(msg); + } +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj b/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj new file mode 100644 index 000000000..d6902c9ea --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PointcutsWithParams.aj @@ -0,0 +1,23 @@ +import org.aspectj.lang.reflect.*; + +public aspect PointcutsWithParams { + + pointcut pc1(String s) : args(s); + + pointcut pc2(Integer i, Double d, String s) : args(i,d,s); + + public static void main(String[] args) throws NoSuchPointcutException { + AjType myType = AjTypeSystem.getAjType(PointcutsWithParams.class); + Pointcut p1 = myType.getPointcut("pc1"); + Class[] params = p1.getParameterTypes(); + if (params.length != 1) throw new RuntimeException("expecting one param"); + if (!params[0].equals(String.class)) throw new RuntimeException("expecting a String"); + Pointcut p2 = myType.getPointcut("pc2"); + params = p2.getParameterTypes(); + if (params.length != 3) throw new RuntimeException("expecting three params"); + if (!params[0].equals(Integer.class)) throw new RuntimeException("expecting an Integer"); + if (!params[1].equals(Double.class)) throw new RuntimeException("expecting a Double"); + if (!params[2].equals(String.class)) throw new RuntimeException("expecting a String"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/PrivilegedAspect.aj b/tests/java5/ataspectj/annotationGen/PrivilegedAspect.aj new file mode 100644 index 000000000..50c850430 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/PrivilegedAspect.aj @@ -0,0 +1,16 @@ +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.internal.lang.annotation.ajcPrivileged; +import java.lang.annotation.*; + +public privileged aspect PrivilegedAspect { + + public static void main(String[] args) { + Annotation[] annotations = PrivilegedAspect.class.getAnnotations(); + if (annotations.length != 2) throw new RuntimeException("Should have two annotations"); + Aspect aspectAnnotation = PrivilegedAspect.class.getAnnotation(Aspect.class); + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + ajcPrivileged pAnnotation = PrivilegedAspect.class.getAnnotation(ajcPrivileged.class); + if (pAnnotation == null) throw new RuntimeException("Should be @ajcPrivileged"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/ReferencePointcuts.aj b/tests/java5/ataspectj/annotationGen/ReferencePointcuts.aj new file mode 100644 index 000000000..782021b24 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/ReferencePointcuts.aj @@ -0,0 +1,20 @@ +import org.aspectj.lang.reflect.*; + +public aspect ReferencePointcuts { + + pointcut pc1() : call(* *.*(..)); + + pointcut pc2() : pc1() || execution(* *.*(..)); + + public static void main(String[] args) throws NoSuchPointcutException { + AjType myType = AjTypeSystem.getAjType(ReferencePointcuts.class); + Pointcut p1 = myType.getPointcut("pc1"); + if (!p1.getPointcutExpression().equals("call(* *(..))")) + throw new RuntimeException("unexpected pc expression: " + p1.getPointcutExpression()); + Pointcut p2 = myType.getPointcut("pc2"); + if (!p2.getPointcutExpression().equals("(pc1() || execution(* *(..)))")) + throw new RuntimeException("unexpected pc expression: " + p2.getPointcutExpression()); + + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/Simple14Aspect.aj b/tests/java5/ataspectj/annotationGen/Simple14Aspect.aj new file mode 100644 index 000000000..912d16de0 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/Simple14Aspect.aj @@ -0,0 +1 @@ +public aspect Simple14Aspect {}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/Simple14AspectTest.java b/tests/java5/ataspectj/annotationGen/Simple14AspectTest.java new file mode 100644 index 000000000..d92eb6198 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/Simple14AspectTest.java @@ -0,0 +1,11 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public class Simple14AspectTest { + + public static void main(String[] args) { + Annotation[] annotations = Simple14Aspect.class.getAnnotations(); + if (annotations.length != 0) throw new RuntimeException("Should have no annotations"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/SimpleAnnotatedAspect.aj b/tests/java5/ataspectj/annotationGen/SimpleAnnotatedAspect.aj new file mode 100644 index 000000000..376dee77d --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/SimpleAnnotatedAspect.aj @@ -0,0 +1,13 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; +@Aspect +public class SimpleAnnotatedAspect { + + public static void main(String[] args) { + Annotation[] annotations = SimpleAnnotatedAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/SimpleAspect.aj b/tests/java5/ataspectj/annotationGen/SimpleAspect.aj new file mode 100644 index 000000000..34f6954dc --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/SimpleAspect.aj @@ -0,0 +1,13 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect SimpleAspect { + + public static void main(String[] args) { + Annotation[] annotations = SimpleAspect.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + Aspect aspectAnnotation = (Aspect) annotations[0]; + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/SimplePointcut.aj b/tests/java5/ataspectj/annotationGen/SimplePointcut.aj new file mode 100644 index 000000000..e022f2b53 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/SimplePointcut.aj @@ -0,0 +1,29 @@ +import java.lang.annotation.*; +import org.aspectj.lang.annotation.*; +import java.lang.reflect.*; + +public aspect SimplePointcut { + + pointcut myPointcut() : call(* String.*(..)); + + public static void main(String[] args) { + Method[] methods = SimplePointcut.class.getDeclaredMethods(); + boolean foundit = false; + for (Method method : methods) { + if (method.getName().startsWith("ajc$pointcut$")) { + if (foundit) throw new RuntimeException("Only expecting one pointcut method"); + foundit = true; + if (method.getName().indexOf("$myPointcut$") == -1) { + throw new RuntimeException("Pointcut name not captured"); + } + if (method.getAnnotations().length != 1) { + throw new RuntimeException("Expecting one annotation, found " + method.getAnnotations().length); + } + Pointcut pcAnn = method.getAnnotation(Pointcut.class); + if (!pcAnn.value().equals("call(* java.lang.String.*(..))")) + throw new RuntimeException("Pointcut expression not set correctly in annotation: " + pcAnn.value()); + } + } + } + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/annotationGen/TwoForThePriceOfOne.java b/tests/java5/ataspectj/annotationGen/TwoForThePriceOfOne.java new file mode 100644 index 000000000..842f07ab1 --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/TwoForThePriceOfOne.java @@ -0,0 +1,10 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public class TwoForThePriceOfOne { + + @Before("execution(* *(..))") + @Pointcut("get(* *)") + public void logEntry() {} + +}
\ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/PrecedenceTest.java b/tests/java5/ataspectj/ataspectj/PrecedenceTest.java index e488aa3c6..c5959fc4b 100644 --- a/tests/java5/ataspectj/ataspectj/PrecedenceTest.java +++ b/tests/java5/ataspectj/ataspectj/PrecedenceTest.java @@ -50,7 +50,7 @@ public class PrecedenceTest extends TestCase { @Aspect() public static class TestAspect_1 { @Before("execution(* ataspectj.PrecedenceTest.hello())") - void before() { + public void before() { log("TestAspect_1"); } } @@ -59,7 +59,7 @@ public class PrecedenceTest extends TestCase { @DeclarePrecedence("ataspectj.PrecedenceTest.TestAspect_3, ataspectj.PrecedenceTest.TestAspect_1") public static class TestAspect_2 { @Before("execution(* ataspectj.PrecedenceTest.hello())") - void before() { + public void before() { log("TestAspect_2"); } } @@ -67,7 +67,7 @@ public class PrecedenceTest extends TestCase { @Aspect() public static class TestAspect_3 { @Before("execution(* ataspectj.PrecedenceTest.hello())") - void before() { + public void before() { log("TestAspect_3"); } } diff --git a/tests/java5/ataspectj/ataspectj/XXJoinPointTest.java b/tests/java5/ataspectj/ataspectj/XXJoinPointTest.java index 168e2fbe6..d14eb8a03 100644 --- a/tests/java5/ataspectj/ataspectj/XXJoinPointTest.java +++ b/tests/java5/ataspectj/ataspectj/XXJoinPointTest.java @@ -57,33 +57,33 @@ public class XXJoinPointTest extends TestCase { void pc() {} @Before("pc()") - void before(JoinPoint jp) { + public void before(JoinPoint jp) { assertEquals("hello", jp.getSignature().getName()); log("jp"); } @Before("pc()") - void before(JoinPoint.StaticPart sjp) { + public void before(JoinPoint.StaticPart sjp) { assertEquals("hello", sjp.getSignature().getName()); log("sjp"); } @Before("pc()") - void beforeEnclosing(JoinPoint.EnclosingStaticPart esjp) { + public void beforeEnclosing(JoinPoint.EnclosingStaticPart esjp) { assertEquals("testJoinPointsInAdviceSignature", esjp.getSignature().getName()); log("esjp"); } //weird order @Before("pc()") - void beforeWEIRD1(JoinPoint jp, JoinPoint.StaticPart sjp) { + public void beforeWEIRD1(JoinPoint jp, JoinPoint.StaticPart sjp) { assertEquals("hello", jp.getSignature().getName()); assertEquals("hello", sjp.getSignature().getName()); log("jp-sjp"); } @Before("pc()") - void before(JoinPoint.StaticPart sjp, JoinPoint.EnclosingStaticPart esjp) { + public void before(JoinPoint.StaticPart sjp, JoinPoint.EnclosingStaticPart esjp) { assertEquals("hello", sjp.getSignature().getName()); assertEquals("testJoinPointsInAdviceSignature", esjp.getSignature().getName()); log("sjp-esjp"); @@ -91,7 +91,7 @@ public class XXJoinPointTest extends TestCase { // conventional order @Before("pc()") - void before(JoinPoint.StaticPart sjp, JoinPoint jp, JoinPoint.EnclosingStaticPart esjp) { + public void before(JoinPoint.StaticPart sjp, JoinPoint jp, JoinPoint.EnclosingStaticPart esjp) { assertEquals("hello", sjp.getSignature().getName()); assertEquals("hello", jp.getSignature().getName()); assertEquals("testJoinPointsInAdviceSignature", esjp.getSignature().getName()); @@ -100,7 +100,7 @@ public class XXJoinPointTest extends TestCase { // weird order @Before("pc()") - void beforeWEIRD2(JoinPoint.EnclosingStaticPart esjp, JoinPoint jp, JoinPoint.StaticPart sjp) { + public void beforeWEIRD2(JoinPoint.EnclosingStaticPart esjp, JoinPoint jp, JoinPoint.StaticPart sjp) { assertEquals("testJoinPointsInAdviceSignature", esjp.getSignature().getName()); assertEquals("hello", jp.getSignature().getName()); assertEquals("hello", sjp.getSignature().getName()); diff --git a/tests/java5/ataspectj/coverage/Test040.java b/tests/java5/ataspectj/coverage/Test040.java index 038ebff1e..b4ba98086 100644 --- a/tests/java5/ataspectj/coverage/Test040.java +++ b/tests/java5/ataspectj/coverage/Test040.java @@ -5,6 +5,7 @@ import org.aspectj.lang.annotation.*; class Foo{ } aspect A{ + @SuppressAjWarnings @Before("call(* org.aspectprogrammer..*(..)) && this(Foo)") public void callFromFoo() { System.out.println("Call from Foo"); diff --git a/tests/java5/ataspectj/coverage/Test041.java b/tests/java5/ataspectj/coverage/Test041.java index 28b1562d4..d444561a9 100644 --- a/tests/java5/ataspectj/coverage/Test041.java +++ b/tests/java5/ataspectj/coverage/Test041.java @@ -3,6 +3,7 @@ import org.aspectj.lang.annotation.*; aspect A{ + @SuppressAjWarnings @AdviceName("") before() : call(* org.aspectprogrammer..*(..)) { System.out.println("Call from Foo"); diff --git a/tests/src/org/aspectj/systemtest/AllTests.java b/tests/src/org/aspectj/systemtest/AllTests.java index 22d673892..d8b88d0d7 100644 --- a/tests/src/org/aspectj/systemtest/AllTests.java +++ b/tests/src/org/aspectj/systemtest/AllTests.java @@ -36,7 +36,6 @@ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.3"); //$JUnit-BEGIN$ - suite.addTest(AllTestsAspectJ150.suite()); suite.addTest(Ajc121Tests.suite()); suite.addTest(Ajc120Tests.suite()); suite.addTest(Ajc11Tests.suite()); diff --git a/tests/src/org/aspectj/systemtest/AllTests15.java b/tests/src/org/aspectj/systemtest/AllTests15.java index badf030b5..6390e42a9 100644 --- a/tests/src/org/aspectj/systemtest/AllTests15.java +++ b/tests/src/org/aspectj/systemtest/AllTests15.java @@ -7,6 +7,7 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.aspectj.systemtest.ajc150.AllTestsAspectJ150; +import org.aspectj.systemtest.ajc150.ataspectj.AtAjAnnotationGenTests; public class AllTests15 { @@ -15,6 +16,7 @@ public class AllTests15 { //$JUnit-BEGIN$ suite.addTest(AllTests14.suite()); suite.addTest(AllTestsAspectJ150.suite()); + suite.addTest(AtAjAnnotationGenTests.suite()); //$JUnit-END$ return suite; } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java new file mode 100644 index 000000000..0a2edb2ca --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjAnnotationGenTests.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * initial development Jonas Bonér, Alexandre Vasseur + *******************************************************************************/ +package org.aspectj.systemtest.ajc150.ataspectj; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * A suite for @AspectJ aspects located in java5/ataspectj + * + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class AtAjAnnotationGenTests extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(AtAjAnnotationGenTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/atajc150.xml"); + } + + public void testSimpleAspect() { + runTest("annotation gen for simple aspect"); + } + + public void testSimpleAspectIn14Mode() { + runTest("annotation gen for simple aspect pre 1.5"); + } + + public void testAspectAlreadyAnnotated() { + runTest("annotation gen for simple annotated aspect"); + } + + public void testPrivilegedAspect() { + runTest("annotation gen for privileged aspect"); + } + + public void testPerThisAspect() { + runTest("annotation gen for perthis aspect"); + } + + public void testPerTargetAspect() { + runTest("annotation gen for pertarget aspect"); + } + + public void testPerCflowAspect() { + runTest("annotation gen for percflow aspect"); + } + + public void testPerCflowbelowAspect() { + runTest("annotation gen for percflowbelow aspect"); + } + + public void testPertypewithinAspect() { + runTest("annotation gen for pertypewithin aspect"); + } + + public void testInnerAspectOfClass() { + runTest("annotation gen for inner aspect of aspect"); + } + + public void testInnerAspectOfAspect() { + runTest("annotation gen for inner aspect of class"); + } + + public void testAdvice() { + runTest("annotation gen for advice declarations"); + } + + public void testSimplePointcut() { + runTest("annotation gen for simple pointcut"); + } + + public void testPointcutModifiers() { + runTest("annotation gen for pointcut modifiers"); + } + + public void testPointcutParams() { + runTest("annotation gen for pointcut params"); + } + + public void testPointcutRefs() { + runTest("annotation gen for pointcut refs"); + } + + public void testBeforeWithBadReturn() { + runTest("before ann with non-void return"); + } + + public void testTwoAnnotationsOnSameElement() { + runTest("two anns on same element"); + } + + public void testBadPcutInAdvice() { + runTest("bad pcut in after advice"); + } + + public void testBadParameterBinding() { + runTest("bad parameter binding in advice"); + } + + public void testSimpleAtPointcut() { + runTest("simple pointcut no params"); + } + + public void testPointcutMedley() { + runTest("pointcut medley"); + } + + public void testAdviceDeclaredInClass() { + runTest("advice in a class"); + } +} + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/atajc150-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/atajc150-tests.xml index 3a89a1290..0c436854b 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/atajc150-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/atajc150-tests.xml @@ -5,6 +5,10 @@ <message kind="weave" text="(SimpleBefore.java:13) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/> </compile> <run class="SimpleBefore"/> + <compile files="SimpleBefore.java" options="-1.5 -showWeaveInfo -XnoInline -Xdev:NoAtAspectJProcessing"> + <message kind="weave" text="(SimpleBefore.java:13) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/> + </compile> + <run class="SimpleBefore"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="SimpleAfter"> @@ -12,31 +16,45 @@ <message kind="weave" text="(SimpleAfter.java:13) advised by after advice from 'SimpleAfter$X'"/> </compile> <run class="SimpleAfter"/> + <compile files="SimpleAfter.java" options="-1.5 -showWeaveInfo -XnoInline -Xdev:NoAtAspectJProcessing"> + <message kind="weave" text="(SimpleAfter.java:13) advised by after advice from 'SimpleAfter$X'"/> + </compile> + <run class="SimpleAfter"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="singletonAspectBindings"> <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline"/> <run class="ataspectj.SingletonAspectBindingsTest"/> - </ajc-test> + <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing"/> + <run class="ataspectj.SingletonAspectBindingsTest"/> + </ajc-test> <ajc-test dir="java5/ataspectj" title="CflowTest"> <compile files="ataspectj/CflowTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.CflowTest"/> + <compile files="ataspectj/CflowTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing"/> + <run class="ataspectj.CflowTest"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="PointcutReferenceTest"> <compile files="ataspectj/PointcutReferenceTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.PointcutReferenceTest"/> + <compile files="ataspectj/PointcutReferenceTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing"/> + <run class="ataspectj.PointcutReferenceTest"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="XXJoinPointTest"> <compile files="ataspectj/XXJoinPointTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.XXJoinPointTest"/> + <compile files="ataspectj/XXJoinPointTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing"/> + <run class="ataspectj.XXJoinPointTest"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="PrecedenceTest"> <compile files="ataspectj/PrecedenceTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.PrecedenceTest"/> + <compile files="ataspectj/PrecedenceTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing"/> + <run class="ataspectj.PrecedenceTest"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AfterXTest"> @@ -52,4 +70,139 @@ <ajc-test dir="java5/ataspectj" title="BindingTest"> <compile files="ataspectj/BindingTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.BindingTest"/> - </ajc-test>
\ No newline at end of file + </ajc-test> + + <!-- ================================================================= --> + <!-- Adrian's tests for generation of @AspectJ annotations from ajc --> + <!-- ================================================================= --> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for simple aspect"> + <compile files="SimpleAspect.aj" options="-1.5"/> + <run class="SimpleAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for simple annotated aspect"> + <compile files="SimpleAnnotatedAspect.aj" options="-1.5"/> + <run class="SimpleAnnotatedAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for simple aspect pre 1.5"> + <compile files="Simple14Aspect.aj" options="-1.4"/> + <compile files="Simple14AspectTest.java" options="-1.5"/> + <run class="Simple14AspectTest"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for privileged aspect"> + <compile files="PrivilegedAspect.aj" options="-1.5"/> + <run class="PrivilegedAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for perthis aspect"> + <compile files="PerThisAspect.aj" options="-1.5"/> + <run class="PerThisAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for pertarget aspect"> + <compile files="PerTargetAspect.aj" options="-1.5"/> + <run class="PerTargetAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for percflow aspect"> + <compile files="PerCflowAspect.aj" options="-1.5"/> + <run class="PerCflowAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for percflowbelow aspect"> + <compile files="PerCflowbelowAspect.aj" options="-1.5"/> + <run class="PerCflowbelowAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for pertypewithin aspect"> + <compile files="PerTypeWithinAspect.aj" options="-1.5"/> + <run class="PerTypeWithinAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for inner aspect of aspect"> + <compile files="InnerAspectAspect.aj" options="-1.5"/> + <run class="InnerAspectAspect"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for inner aspect of class"> + <compile files="InnerAspectClass.aj" options="-1.5"/> + <run class="InnerAspectClass"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for advice declarations"> + <compile files="BasicAdvice.aj" options="-1.5"/> + <run class="BasicAdvice"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for simple pointcut"> + <compile files="SimplePointcut.aj" options="-1.5"/> + <run class="SimplePointcut"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for pointcut modifiers"> + <compile files="PointcutModifiers.aj" options="-1.5"/> + <run class="PointcutModifiers"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for pointcut params"> + <compile files="PointcutsWithParams.aj" options="-1.5"/> + <run class="PointcutsWithParams"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="annotation gen for pointcut refs"> + <compile files="ReferencePointcuts.aj" options="-1.5"/> + <run class="ReferencePointcuts"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="before ann with non-void return"> + <compile files="BeforeWithBadReturn.java" options="-1.5"> + <message kind="error" line="7" text="This advice must return void"/> + <message kind="error" line="7" text="This method must return a result of type String"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="two anns on same element"> + <compile files="TwoForThePriceOfOne.java" options="-1.5"> + <message kind="error" line="7" text="The annotation @Pointcut is disallowed for this location"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="bad pcut in after advice"> + <compile files="AfterReturningWithBadPCut.java" options="-1.5"> + <message kind="error" line="6" text="Syntax error on token "excution(* *.*(..))""/> + </compile> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="bad parameter binding in advice"> + <compile files="BadParameterBinding.java" options="-1.5"> + <message kind="warning" line="11" text="no match for this type name: bpb"/> + <message kind="warning" line="15" text="no match for this type name: TheUnknownType"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="simple pointcut no params"> + <compile files="APointcut.java" options="-1.5"/> + <run class="APointcut"/> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="pointcut medley"> + <compile files="PointcutAssortment.java" options="-1.5"> + <message kind="error" line="9" text="Methods annotated with @Pointcut must return void"/> + <message kind="error" line="9" text="This method must return a result of type String"/> + <message kind="error" line="15" text="Pointcuts should have an empty method body"/> + <message kind="error" line="28" text="Duplicate annotation @Pointcut"/> + <message kind="error" line="29" text="Duplicate annotation @Pointcut"/> + <message kind="error" line="11" text="can't find referenced pointcut foo"/> + <message kind="warning" line="32" text="no match for this type name: foo [Xlint:invalidAbsoluteTypeName]"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/ataspectj/annotationGen" title="advice in a class"> + <compile files="AdviceInAClass.java" options="-1.5"> + <message kind="error" line="6" text="Advice must be declared inside an aspect type"/> + </compile> + </ajc-test> +
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml index abea29b4b..f0ad3f4d3 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/coverage/coverage.xml @@ -25,35 +25,39 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut declared on codestyle advice"> <compile files="Test004.java" options="-1.5"> - <message kind="error" line="7" text="Can't declare @Pointcut on advice"/> + <message kind="error" line="9" text="Only @AdviceName AspectJ annotation allowed on advice"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Aspect class extending @Aspect class"> <compile files="Test005.java" options="-1.5"> + <message kind="error" line="9" text="cannot extend a concrete aspect"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="class with @Before extending @Aspect class"> <compile files="Test006.java" options="-1.5"> - <message kind="error" line="8" text="class 'B' can not extend aspect 'A'"/> + <message kind="error" line="10" text="a class cannot extend an aspect"/> + <message kind="error" line="12" text="Advice must be declared inside an aspect type"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before declared on codestyle advice"> <compile files="Test007.java" options="-1.5"> - <message kind="error" line="7" text="@Before declaration should be followed by a method"/> + <message kind="error" line="8" text="Duplicate annotation @Before"/> + <message kind="error" line="9" text="Only @AdviceName AspectJ annotation allowed on advice"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut not returning void"> <compile files="Test008.java" options="-1.5"> - <message kind="error" line="8" text="Method following @Pointcut should have a void return type"/> - </compile> + <message kind="error" line="10" text="Pointcuts should have an empty method body"/> + <message kind="error" line="10" text="Methods annotated with @Pointcut must return void"/> + </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" @@ -66,28 +70,28 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Aspect on interface"> <compile files="Test010.java" options="-1.5"> - <message kind="error" line="6" text="The annotation @Aspect must be followed by a class declaration"/> + <message kind="error" line="6" text="only classes can have an @Aspect annotation"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut on non-aspect class method"> <compile files="Test011.java" options="-1.5"> - <message kind="error" line="6" text="The annotation @Pointcut is disallowed for this location"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before on non-aspect class method"> <compile files="Test012.java" options="-1.5"> - <message kind="error" line="6" text="The annotation @Before is disallowed for this location"/> + <message kind="error" line="6" text="Syntax error on token """/> + <message kind="error" line="7" text="Advice must be declared inside an aspect type"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut on Interface method"> <compile files="Test013.java" options="-1.5"> - <message kind="error" line="6" text="The annotation @Pointcut is disallowed for this location"/> + <message kind="error" line="8" text="pointcuts can only be declared in a class or an aspect"/> </compile> </ajc-test> @@ -102,14 +106,14 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut with non-empty method body"> <compile files="Test015.java" options="-1.5"> - <message kind="error" line="9" text="@Pointcut method body must be empty"/> + <message kind="error" line="8" text="Pointcuts should have an empty method body"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut with throws clause"> <compile files="Test016.java" options="-1.5"> - <message kind="error" line="8" text="@Pointcut method cannot throw anything"/> + <message kind="error" line="8" text="pointcuts cannot throw exceptions!"/> </compile> </ajc-test> @@ -130,28 +134,28 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@AfterReturning with wrong number of args"> <compile files="Test019.java" options="-1.5"> - <message kind="error" line="5" text="formal unbound in pointcut"/> + <message kind="error" line="7" text="formal unbound in pointcut"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before on non-public method"> <compile files="Test020.java" options="-1.5"> - <message kind="error" line="6" text="@Before must be declared on a public method"/> + <message kind="error" line="7" text="advice must be public"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before on method not returning void"> <compile files="Test021.java" options="-1.5"> - <message kind="error" line="6" text="@Before must be declared on a method returning void"/> + <message kind="error" line="7" text="This advice must return void"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut with wrong number of args"> <compile files="Test022.java" options="-1.5"> - <message kind="error" line="8" text="int x is not declared in the pointcut parameters"/> + <message kind="error" line="8" text="formal unbound in pointcut"/> </compile> </ajc-test> @@ -214,7 +218,7 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Around given an extension of ProceedingJoinPoint"> <compile files="Test031.java" options="-1.5"> - <message kind="error" line="9" text="Is this an error?"/> + <message kind="error" line="11" text="formal unbound in pointcut"/> </compile> </ajc-test> @@ -228,7 +232,8 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before on Interface method"> <compile files="Test033.java" options="-1.5"> - <message kind="error" line="4" text="The annotation @Before is disallowed for this location"/> + <message kind="error" line="7" text="advice must be public"/> + <message kind="error" line="7" text="Advice must be declared inside an aspect type"/> </compile> </ajc-test> @@ -242,33 +247,37 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before and @After on one method"> <compile files="Test035.java" options="-1.5"> - <message kind="error" line="7" text="A method may only be declared as advice once"/> + <message kind="error" line="7" text="The annotation @After is disallowed for this location"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before twice on one method"> <compile files="Test036.java" options="-1.5"> - <message kind="error" line="7" text="A method may only be declared as advice once"/> + <message kind="error" line="6" text="Duplicate annotation @Before"/> + <message kind="error" line="7" text="Duplicate annotation @Before"/> + <message kind="error" line="7" text="The annotation @Before is disallowed for this location"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Before advice with empty string"> <compile files="Test037.java" options="-1.5"> + <message kind="error" line="6" text="Syntax error on token """/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="isPrivileged=truu misspelling"> <compile files="Test038.java" options="-1.5"> - <message kind="error" line="5" text="truu is undefined"/> + <message kind="error" line="5" text="The attribute isPrivileged is undefined for the annotation type Aspect"/> </compile> </ajc-test> <ajc-test dir="java5/ataspectj/coverage" pr="" title="@Pointcut with an empty string"> <compile files="Test039.java" options="-1.5"> + <message kind="error" line="11" text="Syntax error on token """/> </compile> </ajc-test> @@ -287,7 +296,7 @@ <ajc-test dir="java5/ataspectj/coverage" pr="" title="@AdviceName used on @Before advice"> <compile files="Test042.java" options="-1.5"> - <message kind="error" line="6" text="The @AdviceName annotation can only be used before codestyle advice"/> + <message kind="error" line="6" text="AdviceName annotation cannot be used for advice defined using annotation style"/> </compile> </ajc-test> |