diff options
author | avasseur <avasseur> | 2005-10-25 15:36:26 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-10-25 15:36:26 +0000 |
commit | 808a511b8f00f1ea3785796410b5f7c273e7af8e (patch) | |
tree | b7ff9fbac1b61cebc7d73f748775eac356aaa331 /tests | |
parent | 4bc9d287704b1ed797d92a2b19dea6b0f82b8f5b (diff) | |
download | aspectj-808a511b8f00f1ea3785796410b5f7c273e7af8e.tar.gz aspectj-808a511b8f00f1ea3785796410b5f7c273e7af8e.zip |
fix for #113587: when aop.xml include/exclude is used, javac @Aspect are not passed thru the aspectof munger. Added custom logic for that
Diffstat (limited to 'tests')
4 files changed, 106 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/ataspectj/bugs/AspectOfWhenAspectNotInIncludeTest.java b/tests/java5/ataspectj/ataspectj/bugs/AspectOfWhenAspectNotInIncludeTest.java new file mode 100644 index 000000000..5d4437eef --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/bugs/AspectOfWhenAspectNotInIncludeTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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.bugs; + +import junit.framework.TestCase; +import junit.framework.Test; +import junit.framework.TestSuite; +import ataspectj.TestHelper; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.DeclareImplements; +import org.aspectj.lang.Aspects; + +import java.io.Serializable; +import java.lang.reflect.Method; + +/** + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class AspectOfWhenAspectNotInIncludeTest extends TestCase { + + static int I; + + void target() { + I++; + } + + @Aspect + static class TestAspectForAspect { + @DeclareImplements("ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest.TestAspect") + Serializable shouldNotHappenDueToInclude; + } + + @Aspect("perthis(execution(* ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest.target()))") + static class TestAspect { + + public TestAspect() { + int i = 0; + i++; + } + + @Before("execution(* ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest.target())") + public void before() { + I++; + } + } + + public void testInclude() { + I = 0; + target(); + assertEquals(1, I);//aspect not applied as per aop.xml include + } + + public void testAspectOf() { + // aspectOf method has been added to the aspect, no matter the aop.xml include/exclude + try { + Method m = TestAspect.class.getDeclaredMethod("aspectOf", new Class[]{Object.class}); + } catch (Throwable t) { + fail(t.toString()); + } + } + + public void testAspectUntouched() { + if (TestAspect.class.getInterfaces().length > 0) { + fail("Aspect was touched by some aspect while NOT in aop.xml include"); + } + } + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static Test suite() { + return new TestSuite(AspectOfWhenAspectNotInIncludeTest.class); + } + +} diff --git a/tests/java5/ataspectj/ataspectj/bugs/aop-aspectofwhenaspectnotinincludetest.xml b/tests/java5/ataspectj/ataspectj/bugs/aop-aspectofwhenaspectnotinincludetest.xml new file mode 100644 index 000000000..d45adb36a --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/bugs/aop-aspectofwhenaspectnotinincludetest.xml @@ -0,0 +1,9 @@ +<aspectj> + <weaver options="-1.5 -showWeaveInfo"> + <include within="somethingelse..*"/> + </weaver> + <aspects> + <aspect name="ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest.TestAspect"/> + <aspect name="ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest.TestAspectForAspect"/> + </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 d0a88a27e..49e9e7850 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -101,4 +101,9 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { public void testConcreteAspect() { runTest("ConcreteAspect"); } + + public void testAspectOfWhenAspectNotInInclude() { + runTest("AspectOfWhenAspectNotInInclude"); + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index d3bf28f77..257d56805 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -147,4 +147,10 @@ <run class="ataspectj.ConcreteAspectTest" ltw="ataspectj/aop-concreteaspect.xml"/> </ajc-test> + <ajc-test dir="java5/ataspectj" title="AspectOfWhenAspectNotInInclude"> + <compile + files="ataspectj/bugs/AspectOfWhenAspectNotInIncludeTest.java,ataspectj/TestHelper.java" + options="-1.5 -XnoWeave"/> + <run class="ataspectj.bugs.AspectOfWhenAspectNotInIncludeTest" ltw="ataspectj/bugs/aop-aspectofwhenaspectnotinincludetest.xml"/> + </ajc-test> </suite>
\ No newline at end of file |