diff options
Diffstat (limited to 'tests')
7 files changed, 171 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index 393b92f30..6d0dcee0e 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -122,4 +122,43 @@ <jvmarg value="-Daj5.def=ataspectj/aop-unweavabletest.xml"/> </java> </target> + + <target name="ltw.Decp"> + <java fork="yes" classname="ataspectj.DeclareParentsInterfaceTest" failonerror="yes"> + <classpath> + <path refid="aj.path"/> + </classpath> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/aop-decptest.xml"/> + </java> + <java fork="yes" classname="ataspectj.DeclareParentsImplementsTest" failonerror="yes"> + <classpath> + <path refid="aj.path"/> + </classpath> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/aop-decptest.xml"/> + </java> + </target> + + <target name="ltw.Decp2"> + <!-- javac compile the 2nd aspect --> + <javac destdir="${aj.sandbox}" + srcdir="${basedir}" + includes="ataspectj/DeclareParentsImplementsReweavableTestAspect.java" + debug="true"> + <classpath> + <path refid="aj.path"/> + <pathelement path="${aj.sandbox}"/> + </classpath> + </javac> + + <java fork="yes" classname="ataspectj.DeclareParentsImplementsReweavableTest" failonerror="yes"> + <classpath> + <path refid="aj.path"/> + </classpath> + <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> + <jvmarg value="-Daj5.def=ataspectj/aop-decptest2.xml"/> + <jvmarg line="${jdwp}"/> + </java> + </target> </project>
\ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTest.java b/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTest.java new file mode 100644 index 000000000..5e1a7d3c0 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTest.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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; + +import junit.framework.TestCase; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.DeclareParents; + +import java.util.Arrays; + +/** + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class DeclareParentsImplementsReweavableTest extends TestCase { + + static class Target {} + + static interface I1 { int do1(); } + + static class Imp1 implements I1 { + public int do1() {return 1;} + } + + public static interface I2 { int do2(); } + + public static class Imp2 implements I2 { + public int do2() {return 2;} + } + + @Aspect + static class TestAspect { + + @DeclareParents("ataspectj.DeclareParentsImplementsReweavableTest.Target") + public static I1 i1 = new Imp1(); + } + + public void testDecPInt() { + Class[] intfs = Target.class.getInterfaces(); + assertTrue("I1 was not introduced", Arrays.asList(intfs).contains(I1.class)); + assertEquals(1, ((I1)new Target()).do1()); + + // test stuff weaved in by DeclareParentsImplementsReweavableAspect + // thru reweable mode + assertTrue("I2 was not introduced", Arrays.asList(intfs).contains(I2.class)); + assertEquals(2, ((I2)new Target()).do2()); + } + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static junit.framework.Test suite() { + return new junit.framework.TestSuite(DeclareParentsImplementsReweavableTest.class); + } + +} diff --git a/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTestAspect.java b/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTestAspect.java new file mode 100644 index 000000000..c75585f75 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTestAspect.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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; + +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.DeclareParents; + +/** + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +@Aspect +public class DeclareParentsImplementsReweavableTestAspect { + + @DeclareParents("ataspectj.DeclareParentsImplementsReweavableTest.Target") + public static DeclareParentsImplementsReweavableTest.I2 i2 = new DeclareParentsImplementsReweavableTest.Imp2(); + +} diff --git a/tests/java5/ataspectj/ataspectj/aop-decptest.xml b/tests/java5/ataspectj/ataspectj/aop-decptest.xml new file mode 100644 index 000000000..fe04e96b1 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/aop-decptest.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<aspectj> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> + <aspects> + <aspect name="ataspectj.DeclareParentsImplementsTest.TestAspect"/> + <aspect name="ataspectj.DeclareParentsInterfaceTest.TestAspect"/> + </aspects> +</aspectj> diff --git a/tests/java5/ataspectj/ataspectj/aop-decptest2.xml b/tests/java5/ataspectj/ataspectj/aop-decptest2.xml new file mode 100644 index 000000000..2fc5016f8 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/aop-decptest2.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<aspectj> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> + <aspects> + <aspect name="ataspectj.DeclareParentsImplementsReweavableTest.TestAspect"/> + <aspect name="ataspectj.DeclareParentsImplementsReweavableTestAspect"/> + </aspects> +</aspectj> diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index d7af9679a..431232ff5 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -82,4 +82,11 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { runTest("LTW Unweavable"); } + public void testLTWDecp() { + runTest("LTW Decp"); + } + + public void testLTWDecp2() { + runTest("LTW Decp2"); + } } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index aaa2c97e4..11dd7e656 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -102,4 +102,22 @@ <ant file="ajc-ant.xml" target="ltw.Unweavable" verbose="true"/> </ajc-test> + <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" + /> + <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" + /> + <!-- compile the other aspect alone (won't be applied) --> + <ant file="ajc-ant.xml" target="ltw.Decp2" verbose="true"/> + </ajc-test> </suite>
\ No newline at end of file |