From: avasseur Date: Thu, 9 Jun 2005 14:18:36 +0000 (+0000) Subject: @style if test, fixed Ajc that was not having sandbox in cp anymore in some case... X-Git-Tag: PRE_ANDY~182 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5c0167fa97f8521556ac55c7f4a42de430f6f793;p=aspectj.git @style if test, fixed Ajc that was not having sandbox in cp anymore in some case (ltw test failed) --- diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java index 8f4d0dfb5..fd5a2f40d 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java @@ -335,7 +335,7 @@ public class Ajc { newArgs[i] = buff.toString(); if (args[i-1].equals("-classpath")) { hasClasspath = true; - newArgs[i] = newArgs[i] + File.pathSeparator + TESTER_PATH; + newArgs[i] = newArgs[i] + File.pathSeparator + TESTER_PATH + File.pathSeparator + getSandboxDirectory().getAbsolutePath(); } } else { // could be resource file diff --git a/tests/java5/ataspectj/ataspectj/AllLTWTests.java b/tests/java5/ataspectj/ataspectj/AllLTWTests.java index db9f5d95c..252e12af6 100644 --- a/tests/java5/ataspectj/ataspectj/AllLTWTests.java +++ b/tests/java5/ataspectj/ataspectj/AllLTWTests.java @@ -34,6 +34,7 @@ public class AllLTWTests extends TestCase { suite.addTestSuite(AroundInlineMungerTest.class); suite.addTestSuite(SingletonInheritanceTest.class); suite.addTestSuite(PerClauseInheritanceTest.class); + suite.addTestSuite(IfPointcut2Test.class); return suite; } diff --git a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java index 0f8b3539f..9dc681f1a 100644 --- a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java +++ b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java @@ -12,10 +12,6 @@ package ataspectj; import junit.framework.TestCase; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.ProceedingJoinPoint; /** * @author Alexandre Vasseur diff --git a/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java b/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java new file mode 100644 index 000000000..37cd6f042 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/IfPointcut2Test.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * 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.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * @author Alexandre Vasseur + */ +public class IfPointcut2Test extends TestCase { + + static StringBuffer s_log = new StringBuffer(); + + static void log(String s) { + s_log.append(s).append(" "); + } + + public void testSome() { + Foo f = new Foo(); + f.doo(); + f.doo(1); + f.dooMulti(); + assertEquals( + "test aop test2-doo-doo aop2 doo test3-1-doo-doo-doo aop3 doo-1 testTWO-dooMulti testONE-dooMulti aop doMulti ", + s_log.toString() + ); + + s_log = new StringBuffer(); + IfAspect.ISON = false; + f.doo(); + f.doo(1); + f.dooMulti(); + assertEquals( + "test test2-doo-doo doo test3-1-doo-doo-doo doo-1 testTWO-dooMulti doMulti ", + s_log.toString() + ); + } + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static junit.framework.Test suite() { + return new junit.framework.TestSuite(IfPointcut2Test.class); + } + + + @Aspect + public static class IfAspect { + + static boolean ISON = true; + + @Pointcut("execution(* ataspectj.IfPointcut2Test.Foo.doo()) && if()") + public static boolean test() { + log("test"); + return ISON; + } + + @Pointcut("execution(* ataspectj.IfPointcut2Test.Foo.doo()) && if()") + public static boolean test2(JoinPoint.StaticPart sjp, JoinPoint.StaticPart sjp2) {// will require JP flags + log("test2-" + sjp.getSignature().getName() + "-" + sjp2.getSignature().getName()); + return ISON; + } + + @Pointcut("execution(* ataspectj.IfPointcut2Test.Foo.doo(int)) && args(val) && if()") + public static boolean test3(JoinPoint jp, int val, JoinPoint jpbis, JoinPoint.StaticPart jps) { + log( + "test3-" + val + "-" + jp.getSignature().getName() + "-" + jpbis.getSignature().getName() + "-" + jps.getSignature().getName() + ); + return ISON; + } + + //-- if && if thru reference + @Pointcut("if()") + public static boolean testONE(JoinPoint jp) { + log("testONE-" + jp.getSignature().getName()); + return ISON; + } + + @Pointcut("if()") + public static boolean testTWO(JoinPoint.EnclosingStaticPart ejp) { + log("testTWO-" + ejp.getSignature().getName()); + return ISON; + } + + @Before("execution(* ataspectj.IfPointcut2Test.Foo.dooMulti()) && testONE(jp) && testTWO(ejp)") + public void beforeMULTI(JoinPoint jp, JoinPoint.EnclosingStaticPart ejp) { + log("aop"); + } + + //-- basic + @Before("test()") + public void doBefore() { + log("aop"); + } + + @Before("test2(jp, jp2)") + public void doBefore2(JoinPoint.StaticPart jp, JoinPoint.StaticPart jp2) { + log("aop2"); + } + + @Before("test3(jp, i, jpbis, jps)") + public void doBefore3(int i, JoinPoint jp, JoinPoint.StaticPart jps, JoinPoint jpbis) { + log("aop3"); + } + } + + static class Foo { + public void doo() { + log("doo"); + } + + public void doo(int i) { + log("doo-" + i); + } + + public void dooMulti() { + log("doMulti"); + } + } +} diff --git a/tests/java5/ataspectj/ataspectj/IfPointcutTest.java b/tests/java5/ataspectj/ataspectj/IfPointcutTest.java index f793ceb59..eb97bc05e 100644 --- a/tests/java5/ataspectj/ataspectj/IfPointcutTest.java +++ b/tests/java5/ataspectj/ataspectj/IfPointcutTest.java @@ -30,16 +30,16 @@ public class IfPointcutTest extends TestCase { } public void hello(int i) { - System.out.println("IfPointcutTest.hello " + i); + log("hello-" + i); } public void testIf() { s_log = new StringBuffer(); IfPointcutTest me = new IfPointcutTest(); me.hello(1); - assertEquals("aop ", s_log.toString()); + assertEquals("aop hello-1 ", s_log.toString()); me.hello(-1); - assertEquals("aop ", s_log.toString());//unchanged + assertEquals("aop hello-1 hello--1 ", s_log.toString());//unchanged } public static void main(String[] args) { @@ -53,7 +53,7 @@ public class IfPointcutTest extends TestCase { @Aspect public static class TestAspect { - @Pointcut("args(i) && if()") + @Pointcut("args(i) && if() && if(true)") public static boolean positive(int i) { return i>=0; } diff --git a/tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml b/tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml index 7dcbabedf..5f60181e9 100644 --- a/tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml +++ b/tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml @@ -7,7 +7,7 @@ - + @@ -25,5 +25,7 @@ + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index 1130c885c..5bc6ea025 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -29,8 +29,6 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml"); } - - //FIXME AV - those all 4 depends on #75442... public void testRunThemAllWithJavacCompiledAndLTW() { runTest("RunThemAllWithJavacCompiledAndLTW"); } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java index 97454a4b8..b4df3a8c3 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java @@ -102,4 +102,8 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase { public void testIfPointcut() { runTest("IfPointcutTest"); } + + public void testIfPointcut2() { + runTest("IfPointcut2Test"); + } } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml index 61d0e2572..fa16bc3fe 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml @@ -71,6 +71,14 @@ + + + + + + + +