]> source.dussan.org Git - aspectj.git/commitdiff
@style if test, fixed Ajc that was not having sandbox in cp anymore in some case...
authoravasseur <avasseur>
Thu, 9 Jun 2005 14:18:36 +0000 (14:18 +0000)
committeravasseur <avasseur>
Thu, 9 Jun 2005 14:18:36 +0000 (14:18 +0000)
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
tests/java5/ataspectj/ataspectj/AllLTWTests.java
tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java
tests/java5/ataspectj/ataspectj/IfPointcut2Test.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/IfPointcutTest.java
tests/java5/ataspectj/ataspectj/pathentry/META-INF/aop.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml

index 8f4d0dfb5080ae7921cd6044aebf0b479c762381..fd5a2f40d8ab07eeac419c2ba8595a949977dfe1 100644 (file)
@@ -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
index db9f5d95cd2d329d3eaff7288f62ec4b4cca1e49..252e12af61551f5fbc572ffc6d78950cc8fee896 100644 (file)
@@ -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;
     }
index 0f8b3539f7c67579e0761da5a0bc33ceb5d8aceb..9dc681f1ac817ee731f18e68280293adbae4c43c 100644 (file)
 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 (file)
index 0000000..37cd6f0
--- /dev/null
@@ -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");
+        }
+    }
+}
index f793ceb59867c4b68fbf14a844eb6d2863c7a60d..eb97bc05ed2f4f8070a17a4278f30b32cc281310 100644 (file)
@@ -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;
         }
index 7dcbabedffd59ce491e79dd9ca3491d25dd60b03..5f60181e96cbbe0713e95f52c075cdc5e1bcd232 100644 (file)
@@ -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>
index 1130c885cd9c45795d1a5ea82bc4feec4f397b1e..5bc6ea025b5f85cb7d72130db3f012d59ffcf0bd 100644 (file)
@@ -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");
        }
index 97454a4b8d7803a76663fc1fbf4f009d2868675b..b4df3a8c3026fa3c11b5c01b241b94798129b32d 100644 (file)
@@ -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
index 61d0e2572299bd0e9d8aa1b03fd5346586b14f76..fa16bc3fe9aba89d59df8599a3fe84cddfa28402 100644 (file)
 <!--        <run class="ataspectj.IfPointcutTest"/>-->
     </ajc-test>
 
+    <ajc-test dir="java5/ataspectj" title="IfPointcut2Test">
+        <compile files="ataspectj/IfPointcut2Test.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing"/>
+        <run class="ataspectj.IfPointcut2Test"/>
+        <!-- FIXME AV - Adrian in JDT stuff -->
+<!--        <compile files="ataspectj/IfPointcut2Test.java,ataspectj/TestHelper.java" options="-1.5"/>-->
+<!--        <run class="ataspectj.IfPointcut2Test"/>-->
+    </ajc-test>
+
     <ajc-test dir="java5/ataspectj" title="BindingTest">
         <compile files="ataspectj/BindingTest.java,ataspectj/TestHelper.java" options="-1.5"/>
         <run class="ataspectj.BindingTest"/>