]> source.dussan.org Git - aspectj.git/commitdiff
PointcutDoctor javadoc - 193065
authoraclement <aclement>
Fri, 7 Dec 2007 13:32:24 +0000 (13:32 +0000)
committeraclement <aclement>
Fri, 7 Dec 2007 13:32:24 +0000 (13:32 +0000)
tests/bugs/pointcutdoctor-bug193065/Aspect.aj [new file with mode: 0644]
tests/bugs/pointcutdoctor-bug193065/Bar.java [new file with mode: 0644]
tests/bugs/pointcutdoctor-bug193065/Foo.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc154/AllTestsAspectJ154.java
tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java

diff --git a/tests/bugs/pointcutdoctor-bug193065/Aspect.aj b/tests/bugs/pointcutdoctor-bug193065/Aspect.aj
new file mode 100644 (file)
index 0000000..60766b7
--- /dev/null
@@ -0,0 +1,18 @@
+
+public aspect Aspect {
+       //:method-call(void Foo.method1())=real
+       //:(virtual) method-call(void Foo.method2())=virtual
+       pointcut calls(): call(* Foo.*(..));
+       
+       //:(virtual) method-call(void Bar.bar())=virtual
+       pointcut callBar():call(* Bar.*(..));
+       
+       //:method-call(void Foo.method1())=real
+       //:(virtual) method-call(void Foo.method2())=virtual
+       pointcut callsWithin(): call(* Foo.*(..)) && within(Bar);
+
+       //:method-call(void Foo.method1())=real
+       //:(virtual) method-call(void Foo.method2())=virtual
+       pointcut callsWithincode(): call(* Foo.*(..))&&withincode(* Bar.*(..));
+
+}
diff --git a/tests/bugs/pointcutdoctor-bug193065/Bar.java b/tests/bugs/pointcutdoctor-bug193065/Bar.java
new file mode 100644 (file)
index 0000000..6cad151
--- /dev/null
@@ -0,0 +1,6 @@
+public class Bar {
+       public void bar() {
+               Foo f = new Foo();
+               f.method1();
+       }
+}
diff --git a/tests/bugs/pointcutdoctor-bug193065/Foo.java b/tests/bugs/pointcutdoctor-bug193065/Foo.java
new file mode 100644 (file)
index 0000000..e49e33e
--- /dev/null
@@ -0,0 +1,9 @@
+public class Foo {
+       public void method1() {
+               
+       }
+       
+       public void method2() {
+               
+       }
+}
index 71f6d1820900639cda0a254b133da56fb7e236a0..751ceeef1c400bf0da15baa48c0d2974d660a253 100644 (file)
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.aspectj.systemtest.ajc154;
 
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -19,6 +20,7 @@ public class AllTestsAspectJ154 {
                TestSuite suite = new TestSuite("AspectJ 1.5.4 tests");
                //$JUnit-BEGIN$
                suite.addTest(Ajc154Tests.suite());
+               //suite.addTestSuite(CustomMungerExtensionTest.class);
         //$JUnit-END$
                return suite;
        }
diff --git a/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java b/tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java
new file mode 100644 (file)
index 0000000..89fcad9
--- /dev/null
@@ -0,0 +1,124 @@
+/* *******************************************************************
+ * Copyright (c) 2007 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://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Linton Ye https://bugs.eclipse.org/bugs/show_bug.cgi?id=193065
+ * ******************************************************************/
+
+package org.aspectj.systemtest.ajc154;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.aspectj.ajde.core.AjCompiler;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbed;
+import org.aspectj.weaver.Advice;
+import org.aspectj.weaver.Checker;
+import org.aspectj.weaver.ConcreteTypeMunger;
+import org.aspectj.weaver.CustomMungerFactory;
+import org.aspectj.weaver.Member;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
+import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.ShadowMunger;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.AjAttribute.AdviceAttribute;
+import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
+import org.aspectj.weaver.patterns.IfPointcut;
+import org.aspectj.weaver.patterns.Pointcut;
+
+public class CustomMungerExtensionTest extends AjdeInteractionTestbed {
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               sandboxDir = new File(".");
+       }
+       
+       public void testExtension() {
+               String testFileDir = "bugs/pointcutdoctor-bug193065";
+               AjCompiler compiler = getCompilerForProjectWithName(testFileDir);
+               compiler.setCustomMungerFactory(new DumbCustomMungerFactory());
+
+               doBuild(testFileDir);
+               
+               CustomMungerFactory factory = (CustomMungerFactory)compiler.getCustomMungerFactory();
+               assertTrue(factory.getAllCreatedCustomShadowMungers().size()>0);
+               for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();)
+                       assertTrue(((DumbShadowMunger)i.next()).called);
+               
+               assertTrue(factory.getAllCreatedCustomTypeMungers().size()>0);
+               for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();)
+                       assertTrue(((DumbTypeMunger)i.next()).called);
+       }
+       
+       class DumbCustomMungerFactory implements CustomMungerFactory {
+               Collection allShadowMungers = new ArrayList();
+               Collection allTypeMungers = new ArrayList();
+               public Collection createCustomShadowMungers(ResolvedType aspectType) {
+                       List/* ShadowMunger */ mungers = new ArrayList/*ShadowMunger*/(); 
+                       Pointcut pointcut = new IfPointcut("abc");
+                       mungers.add(new DumbShadowMunger(new DeclareErrorOrWarning(false, pointcut, "")));
+                       allShadowMungers.addAll(mungers);
+                       return mungers;
+               }
+
+               public Collection createCustomTypeMungers(ResolvedType aspectType) {
+                       List/*ConcreteTypeMunger*/ mungers = new ArrayList/*ShadowMunger*/(); 
+                       mungers.add(new DumbTypeMunger(null, aspectType));
+                       allTypeMungers.addAll(mungers);
+                       return mungers;
+               }
+
+               public Collection getAllCreatedCustomShadowMungers() {
+                       return allShadowMungers;
+               }
+
+               public Collection getAllCreatedCustomTypeMungers() {
+                       return allTypeMungers;
+               }
+       }
+
+       class DumbShadowMunger extends Checker {
+               public DumbShadowMunger(DeclareErrorOrWarning deow) {
+                       super(deow);
+               }
+
+               public ISourceLocation getSourceLocation() {
+                       return ISourceLocation.EMPTY;
+               }
+
+               boolean called;
+
+               public boolean match(Shadow shadow, World world) {
+                       called = true;
+                       return false;
+               }
+       }
+
+       class DumbTypeMunger extends ConcreteTypeMunger {
+               boolean called;
+
+               public DumbTypeMunger(ResolvedTypeMunger munger, ResolvedType aspectType) {
+                       super(munger, aspectType);
+               }
+
+               public ConcreteTypeMunger parameterizedFor(ResolvedType targetType) {
+                       return null;
+               }
+               
+               public boolean matches(ResolvedType onType) {
+                       called = true;
+                       return false;
+               }
+       }
+}
index fbecd0c92a68c1d006bcd3f873c3d2c2bb068928..bf663e5c13f179e1e3457e08c9e5988e6d84a8c9 100644 (file)
@@ -255,6 +255,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen
        public void testAjStateDeleteResourcesInInputDir() {
                // temporary problem with this on linux, think it is a filesystem lastmodtime issue
                if (System.getProperty("os.name","").toLowerCase().equals("linux")) return;
+               if (System.getProperty("os.name","").toLowerCase().indexOf("mac")!=-1) return;
 
                AjBuildManager.COPY_INPATH_DIR_RESOURCES = true;
                try {