summaryrefslogtreecommitdiffstats
path: root/tests/java5
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-06-09 14:18:36 +0000
committeravasseur <avasseur>2005-06-09 14:18:36 +0000
commit5c0167fa97f8521556ac55c7f4a42de430f6f793 (patch)
treeafd248a8cd0f83025c0971ffaf30bea7c3f19f2f /tests/java5
parent81c78513ef92422e97e06002545c3e0ad6a9027c (diff)
downloadaspectj-5c0167fa97f8521556ac55c7f4a42de430f6f793.tar.gz
aspectj-5c0167fa97f8521556ac55c7f4a42de430f6f793.zip
@style if test, fixed Ajc that was not having sandbox in cp anymore in some case (ltw test failed)
Diffstat (limited to 'tests/java5')
-rw-r--r--tests/java5/ataspectj/ataspectj/AllLTWTests.java1
-rw-r--r--tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java4
-rw-r--r--tests/java5/ataspectj/ataspectj/IfPointcut2Test.java134
-rw-r--r--tests/java5/ataspectj/ataspectj/IfPointcutTest.java8
-rw-r--r--tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml4
5 files changed, 142 insertions, 9 deletions
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 <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
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 <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+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 @@
<aspect name="ataspectj.CflowTest.TestAspect"/>
<aspect name="ataspectj.PointcutReferenceTest.TestAspect"/>
<aspect name="ataspectj.AfterXTest.TestAspect"/>
-<!-- <aspect name="ataspectj.IfPointcutTest.TestAspect"/>-->
+ <aspect name="ataspectj.IfPointcutTest.TestAspect"/>
<aspect name="ataspectj.XXJoinPointTest.TestAspect"/>
<aspect name="ataspectj.PrecedenceTest.TestAspect_2"/>
<aspect name="ataspectj.PrecedenceTest.TestAspect_1"/>
@@ -25,5 +25,7 @@
<aspect name="ataspectj.SingletonInheritanceTest.ChildAspect"/>
<aspect name="ataspectj.PerClauseInheritanceTest.ChildAspect"/>
+
+ <aspect name="ataspectj.IfPointcut2Test.IfAspect"/>
</aspects>
</aspectj>