diff options
author | avasseur <avasseur> | 2005-07-04 12:58:41 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-07-04 12:58:41 +0000 |
commit | 44dc6e9700b0e9a013d53c8444971e4ba47f9699 (patch) | |
tree | 2133ba50eff90f6c5b38b65175faedaee8c35e68 /tests | |
parent | c3b7d70b101defcc0b0284895ceb56bfca6a1548 (diff) | |
download | aspectj-44dc6e9700b0e9a013d53c8444971e4ba47f9699.tar.gz aspectj-44dc6e9700b0e9a013d53c8444971e4ba47f9699.zip |
fix source location for @AJ + fix the AsmManager behavior for @AJ (still no luck in AJDT though)
Diffstat (limited to 'tests')
6 files changed, 186 insertions, 8 deletions
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index e4d4008eb..bd5f98a2b 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -21,7 +21,7 @@ <!-- use META-INF/aop.xml style --> <classpath path="ataspectj/pathentry"/> <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/> - <!--<jvmarg line="${jdwp}"/>--> +<!-- <jvmarg line="${jdwp}"/>--> </java> </target> diff --git a/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java b/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java index 27ce636b4..e59821cb8 100644 --- a/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java +++ b/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java @@ -19,6 +19,9 @@ import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import junit.framework.TestCase; +import java.io.File; +import java.io.FileReader; + /** * Test various advice and JoinPoint + binding, without pc ref * @@ -129,4 +132,20 @@ public class SingletonAspectBindingsTest extends TestCase { } } + +// public void testHe() throws Throwable { +// //Allow to look inn file based on advises/advised-by offset numbers +// File f = new File("../tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj"); +// FileReader r = new FileReader(f); +// int i = 0; +// for (i = 0; i < 2800; i++) { +// r.read(); +// } +// for (;i < 2900; i++) { +// if (i == 2817) System.out.print("X"); +// System.out.print((char)r.read()); +// } +// System.out.print("|DONE"); +// r.close(); +// } } diff --git a/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj b/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj new file mode 100644 index 000000000..5083375bb --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj @@ -0,0 +1,150 @@ +/******************************************************************************* + * 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: + * initial implementation Alexandre Vasseur + *******************************************************************************/ +package ataspectj; + +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import junit.framework.TestCase; + +import java.io.File; +import java.io.FileReader; + +/** + * Test various advice and JoinPoint + binding, without pc ref + * + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class SingletonAspectBindingsTest2 extends TestCase { + + static StringBuffer s_log = new StringBuffer(); + static void log(String s) { + s_log.append(s).append(" "); + } + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static junit.framework.Test suite() { + return new junit.framework.TestSuite(SingletonAspectBindingsTest2.class); + } + + public void hello() { + log("hello"); + } + + public void hello(String s) { + log("hello-"); + log(s); + } + + public void testExecutionWithThisBinding() { + s_log = new StringBuffer(); + SingletonAspectBindingsTest2 me = new SingletonAspectBindingsTest2(); + me.hello(); + // see here advice precedence as in source code order + //TODO check around relative order + // see fix in BcelWeaver sorting shadowMungerList + //assertEquals("around2_ around_ before hello after _around _around2 ", s_log.toString()); + assertEquals("around_ around2_ before hello _around2 _around after ", s_log.toString()); + } + + public void testExecutionWithArgBinding() { + s_log = new StringBuffer(); + SingletonAspectBindingsTest2 me = new SingletonAspectBindingsTest2(); + me.hello("x"); + assertEquals("before- x hello- x ", s_log.toString()); + } + + + //@Aspect + static aspect TestAspect { + + static int s = 0; + + static { + s++; + } + + public TestAspect() { + // assert clinit has run when singleton aspectOf reaches that + assertTrue(s>0); + } + + //public static TestAspect aspectOf() {return null;} + + void around() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) { + //public void aaround(ProceedingJoinPoint jp) { + log("around_"); + try { + proceed(); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + log("_around"); + } + + void around(Object t) : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) && this(t) { + //public void around2(ProceedingJoinPoint jp, Object t) { + log("around2_"); + assertEquals(SingletonAspectBindingsTest2.class.getName(), t.getClass().getName()); + try { + proceed(t); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + log("_around2"); + } + + before() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) { + //public void before(JoinPoint.StaticPart sjp) { + log("before"); + assertEquals("hello", thisJoinPointStaticPart.getSignature().getName()); + } + + after() : execution(* ataspectj.SingletonAspectBindingsTest2.hello()) { + //public void after(JoinPoint.StaticPart sjp) { + log("after"); + assertEquals("execution(public void ataspectj.SingletonAspectBindingsTest2.hello())", thisJoinPointStaticPart.toLongString()); + } + + //TODO see String alias, see before advice name clash - all that works + // 1/ String is in java.lang.* - see SimpleScope.javalangPrefix array + // 2/ the advice is register thru its Bcel Method mirror + before(String s) : execution(* ataspectj.SingletonAspectBindingsTest2.hello(String)) && args(s) { + //public void before(String s, JoinPoint.StaticPart sjp) { + log("before-"); + log(s); + assertEquals("hello", thisJoinPointStaticPart.getSignature().getName()); + } + + } + +// public void testHe() throws Throwable { +// File f = new File("../tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest2.aj"); +// FileReader r = new FileReader(f); +// int i = 0; +// for (i = 0; i < 3950; i++) { +// r.read(); +// } +// for (;i < 4000; i++) { +// if (i == 3983) System.out.print("X"); +// System.out.print((char)r.read()); +// } +// System.out.print("|DONE"); +// r.close(); +// } +} diff --git a/tests/src/org/aspectj/systemtest/AllTests.java b/tests/src/org/aspectj/systemtest/AllTests.java index 0ea78b169..bc1c4ad9c 100644 --- a/tests/src/org/aspectj/systemtest/AllTests.java +++ b/tests/src/org/aspectj/systemtest/AllTests.java @@ -27,9 +27,6 @@ import org.aspectj.systemtest.xlint.XLintTests; /** * @author colyer - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public class AllTests { @@ -54,6 +51,7 @@ public class AllTests { suite.addTest(SUIDTests.suite()); suite.addTest(XLintTests.suite()); //$JUnit-END$ + return suite; } } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java index b4df3a8c3..eda07cb53 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java @@ -40,7 +40,13 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase { } public void testSingletonAspectBindings() { + //Note AV: uncomment setReporting to get it in modules/tests folder + //org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true); runTest("singletonAspectBindings"); + // same stuff with AJ + //org.aspectj.asm.AsmManager.setReporting("debug-aj.txt",true,true,true,true); + runTest("singletonAspectBindings2"); + } public void testCflowTest() { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml index fa16bc3fe..f4e209b07 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml @@ -3,11 +3,11 @@ <ajc-test dir="java5/ataspectj" title="SimpleBefore"> <compile files="SimpleBefore.java" options="-1.5 -showWeaveInfo -XnoInline"> - <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/> + <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:33)"/> </compile> <run class="SimpleBefore"/> <compile files="SimpleBefore.java" options="-1.5 -showWeaveInfo -XnoInline -Xdev:NoAtAspectJProcessing"> - <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:1)"/> + <message kind="weave" text="(SimpleBefore.java:23) advised by before advice from 'SimpleBefore$X' (SimpleBefore.java:33)"/> </compile> <run class="SimpleBefore"/> </ajc-test> @@ -24,12 +24,17 @@ </ajc-test> <ajc-test dir="java5/ataspectj" title="singletonAspectBindings"> - <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline"/> + <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline"/> <run class="ataspectj.SingletonAspectBindingsTest"/> - <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing"/> + <compile files="ataspectj/SingletonAspectBindingsTest.java,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline -Xdev:NoAtAspectJProcessing"/> <run class="ataspectj.SingletonAspectBindingsTest"/> </ajc-test> + <ajc-test dir="java5/ataspectj" title="singletonAspectBindings2"> + <compile files="ataspectj/SingletonAspectBindingsTest2.aj,ataspectj/TestHelper.java" options="-1.5 -emacssym -XnoInline"/> + <run class="ataspectj.SingletonAspectBindingsTest2"/> + </ajc-test> + <ajc-test dir="java5/ataspectj" title="CflowTest"> <compile files="ataspectj/CflowTest.java,ataspectj/TestHelper.java" options="-1.5"/> <run class="ataspectj.CflowTest"/> |