diff options
author | avasseur <avasseur> | 2005-10-21 16:08:10 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-10-21 16:08:10 +0000 |
commit | 1232fbba13b21df11d0a9c58a04657441c447f98 (patch) | |
tree | 90107611785dcae008493f8155c76da66391a60c /tests | |
parent | 5e17799ef005829b992198048e4b18abff288f78 (diff) | |
download | aspectj-1232fbba13b21df11d0a9c58a04657441c447f98.tar.gz aspectj-1232fbba13b21df11d0a9c58a04657441c447f98.zip |
fix issue in test for -1.5 and @AJ ITD with @anno
impl error message for reweavable and not declared in aop.xml as per David Knibb patch, #104218
Diffstat (limited to 'tests')
8 files changed, 183 insertions, 44 deletions
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index 6659b3f69..077fc2667 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -148,7 +148,6 @@ debug="true"> <classpath> <path refid="aj.path"/> - <pathelement path="${aj.sandbox}"/> </classpath> </javac> @@ -160,4 +159,31 @@ <jvmarg value="-Daj5.def=ataspectj/aop-decptest2.xml"/> </java> </target> + + <target name="ltw.oldAspectsDeclared"> + <!--Aspects woven at compile time must be declared in an aop.xml file. + If they are not declared, then they will be lost during reweaving--> + + <!--First test that the error is produced if the declaration is not made--> + <java fork="yes" classname="ataspectj.ltwreweavable.MainReweavableLogging" failonerror="yes"> + <classpath refid="aj.path"/> + <classpath> + <pathelement path="${aj.sandbox}/main1.jar"/> + </classpath> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml"/> + <jvmarg value="-DaspectDeclared=true"/> + </java> + <!--Now ensure that the error is not produced when the declaration is made.--> + <java fork="yes" classname="ataspectj.ltwreweavable.MainReweavableLogging" failonerror="yes"> + <classpath refid="aj.path"/> + <classpath> + <pathelement path="${aj.sandbox}/main1.jar"/> + </classpath> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml"/> + <jvmarg value="-DaspectDeclared=false"/> + </java> + </target> + </project>
\ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/aop-decptest.xml b/tests/java5/ataspectj/ataspectj/aop-decptest.xml index fe04e96b1..3e607df7d 100644 --- a/tests/java5/ataspectj/ataspectj/aop-decptest.xml +++ b/tests/java5/ataspectj/ataspectj/aop-decptest.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper -1.5 -Xlint:ignore"/> <aspects> <aspect name="ataspectj.DeclareParentsImplementsTest.TestAspect"/> <aspect name="ataspectj.DeclareParentsInterfaceTest.TestAspect"/> diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java b/tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java new file mode 100644 index 000000000..e921147ba --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj.ltwreweavable; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Contributed by David Knibb + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +@Aspect +public class AspectReweavableLogging { + + @Before("execution(void ataspectj.ltwreweavable.MainReweavableLogging.test1()) && this(a)") + public void before(Advisable a, JoinPoint thisJoinPoint) { + System.err.println(thisJoinPoint); + a.addJoinPoint(thisJoinPoint.getSignature().getName()); + } +} +
\ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java b/tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java new file mode 100644 index 000000000..caa4a9ac7 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj.ltwreweavable; + +import ataspectj.ltwlog.MessageHolder; + +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Contributed by David Knibb + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class MainReweavableLogging implements Advisable { + private static List joinPoints = new ArrayList(); + + public void test1 () { + + } + + public void test2 () { + + } + + public void addJoinPoint (String name) { + joinPoints.add(name); + } + + public static void main (String[] args) { + String ERROR_STRING = "error aspect 'ataspectj.ltwreweavable.AspectReweavableLogging' woven into 'ataspectj.ltwreweavable.MainReweavableLogging' must be declared in an aop.xml file."; + if(Boolean.getBoolean("aspectDeclared")){ + //if the aspect is declared there should not be an error + if (MessageHolder.startsAs( Arrays.asList( new String[]{ ERROR_STRING } )) ) { + MessageHolder.dump(); + throw new RuntimeException("Error in MainReweavableLogging - unexpected error message - \"" + ERROR_STRING + "\""); + } + } + else{ + //and if the aspect is not declared then there should + if (!MessageHolder.startsAs( Arrays.asList( new String[]{ ERROR_STRING } )) ) { + MessageHolder.dump(); + throw new RuntimeException("Error in MainReweavableLogging - missing expected error message - \"" + ERROR_STRING + "\""); + } + } + } +} diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml new file mode 100644 index 000000000..d89b5b3aa --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml @@ -0,0 +1,6 @@ +<aspectj> + <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/> + <aspects> + <aspect name="ataspectj.ltwreweavable.AspectReweavableLogging"/> + </aspects> +</aspectj>
\ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml new file mode 100644 index 000000000..4b53f2b1f --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml @@ -0,0 +1,5 @@ +<aspectj> + <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/> + <!--aspect is not declared here so as to produce an error --> + <aspects/> +</aspectj>
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index 18c7c8b02..79e3dc307 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -82,12 +82,16 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { runTest("LTW Unweavable"); } - // FIXME asc need to comment this out for now - I need a build through... -// public void testLTWDecp() { -// runTest("LTW Decp"); -// } + public void testLTWDecp() { + runTest("LTW Decp"); + } public void testLTWDecp2() { runTest("LTW Decp2"); } + + public void testCompileTimeAspectsDeclaredToLTWWeaver() { + runTest("Compile time aspects declared to ltw weaver"); + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index 11dd7e656..a316e6799 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -7,90 +7,90 @@ <ajc-test dir="java5/ataspectj" title="AjcLTW PerClauseTest -XnoWeave"> <compile - files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java" - options="-1.5 -XnoWeave"/> + files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java" + options="-1.5 -XnoWeave"/> <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW PerClauseTest -Xreweavable"> <compile - files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java" - options="-1.5"/> + files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java" + options="-1.5"/> <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest"> <compile - files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java" - options="-1.5 -XnoWeave"/> + files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java" + options="-1.5 -XnoWeave"/> <comment> - aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them - since such just added methods are an interesting case (percflow ajc$perCflowStack advice) + aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them + since such just added methods are an interesting case (percflow ajc$perCflowStack advice) </comment> <compile - files="ataspectj/PerClauseTestAspects.java" - options="-1.5 -Xdev:NoAtAspectJProcessing"> - <message kind="warning"/> + files="ataspectj/PerClauseTestAspects.java" + options="-1.5 -Xdev:NoAtAspectJProcessing"> + <message kind="warning"/> </compile> <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoWeave"> <compile - files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" - options="-1.5 -XnoWeave"/> + files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" + options="-1.5 -XnoWeave"/> <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -Xreweavable"> <compile - files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" - options="-1.5"/> + files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" + options="-1.5"/> <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest"> <compile - files="ataspectj/AroundInlineMungerTestAspects.java" - options="-1.5 -Xlint:ignore"/> + files="ataspectj/AroundInlineMungerTestAspects.java" + options="-1.5 -Xlint:ignore"/> <compile - files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" - options="-1.5"/> + files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" + options="-1.5"/> <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable"> <compile - files="ataspectj/AroundInlineMungerTestAspects.java" - options="-1.5 -Xlint:ignore -XnoInline"/> + files="ataspectj/AroundInlineMungerTestAspects.java" + options="-1.5 -Xlint:ignore -XnoInline"/> <compile - files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" - options="-1.5 -XnoInline"/> + files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" + options="-1.5 -XnoInline"/> <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest2"> <compile - files="ataspectj/AroundInlineMungerTestAspects2.aj" - options="-1.5 -Xlint:ignore"/> + files="ataspectj/AroundInlineMungerTestAspects2.aj" + options="-1.5 -Xlint:ignore"/> <compile - files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/TestHelper.java" - options="-1.5"/> + files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/TestHelper.java" + options="-1.5"/> <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest2" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="LTW DumpTest"> <compile - files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java" - options="-1.5"/> + files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java" + options="-1.5"/> <ant file="ajc-ant.xml" target="ltw.DumpTest" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="Ajc Aspect1 LTW Aspect2 -Xreweavable"> <compile - files="ataspectj/ltwreweavable/Main.java,ataspectj/ltwreweavable/Aspect1.java,ataspectj/ltwreweavable/Advisable.java" - options="-1.5" - outjar="main1.jar"/> + files="ataspectj/ltwreweavable/Main.java,ataspectj/ltwreweavable/Aspect1.java,ataspectj/ltwreweavable/Advisable.java" + options="-1.5" + outjar="main1.jar"/> <ant file="ajc-ant.xml" target="ltw.Aspect2MainTest" verbose="true"/> </ajc-test> @@ -105,19 +105,30 @@ <ajc-test dir="java5/ataspectj" title="LTW Decp"> <!-- ajc compile them to test reweable as well --> <compile - files="ataspectj/DeclareParentsInterfaceTest.java,ataspectj/DeclareParentsImplementsTest.java,ataspectj/TestHelper.java" - options="-1.5" - /> + files="ataspectj/DeclareParentsInterfaceTest.java,ataspectj/DeclareParentsImplementsTest.java,ataspectj/TestHelper.java" + options="-1.5" + /> + <!--<run class="ataspectj.DeclareParentsInterfaceTest" ltw="ataspectj/aop-decptest.xml"/>--> <ant file="ajc-ant.xml" target="ltw.Decp" verbose="true"/> </ajc-test> <ajc-test dir="java5/ataspectj" title="LTW Decp2"> <!-- ajc compile them but with only one aspect --> <compile - files="ataspectj/DeclareParentsImplementsReweavableTest.java,ataspectj/TestHelper.java" - options="-1.5" - /> + files="ataspectj/DeclareParentsImplementsReweavableTest.java,ataspectj/TestHelper.java" + options="-1.5" + /> <!-- compile the other aspect alone (won't be applied) --> <ant file="ajc-ant.xml" target="ltw.Decp2" verbose="true"/> </ajc-test> + + + <ajc-test dir="java5/ataspectj" title="Compile time aspects declared to ltw weaver"> + <compile + files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java" + options="-1.5" + outjar="main1.jar"/> + <ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/> + </ajc-test> + </suite>
\ No newline at end of file |