]> source.dussan.org Git - aspectj.git/commitdiff
192877: testcode
authoraclement <aclement>
Tue, 30 Sep 2008 20:51:53 +0000 (20:51 +0000)
committeraclement <aclement>
Tue, 30 Sep 2008 20:51:53 +0000 (20:51 +0000)
tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java [new file with mode: 0644]
tests/multiIncremental/PR192877/base/src/Foo.java [new file with mode: 0644]
tests/multiIncremental/PR192877/base/src/FooImpl.java [new file with mode: 0644]
tests/multiIncremental/PR192877/base/src/Test.java [new file with mode: 0644]
tests/multiIncremental/PR192877/base/src/TestAspect.java [new file with mode: 0644]
tests/multiIncremental/PR192877/inc1/src/Test.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

diff --git a/tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java b/tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java
new file mode 100644 (file)
index 0000000..1a29543
--- /dev/null
@@ -0,0 +1,10 @@
+
+public class DefaultTestImpl implements Test {
+    public void methodA() {
+        System.out.println("methodA");
+    }
+
+    public void methodB() {
+        System.out.println("methodB");
+    }
+}
diff --git a/tests/multiIncremental/PR192877/base/src/Foo.java b/tests/multiIncremental/PR192877/base/src/Foo.java
new file mode 100644 (file)
index 0000000..9eac48b
--- /dev/null
@@ -0,0 +1,4 @@
+
+public interface Foo {
+    void doSomething();
+}
diff --git a/tests/multiIncremental/PR192877/base/src/FooImpl.java b/tests/multiIncremental/PR192877/base/src/FooImpl.java
new file mode 100644 (file)
index 0000000..85c45fa
--- /dev/null
@@ -0,0 +1,5 @@
+public class FooImpl implements Foo {
+    public void doSomething() {
+        System.out.println("doSomething");
+    }
+}
diff --git a/tests/multiIncremental/PR192877/base/src/Test.java b/tests/multiIncremental/PR192877/base/src/Test.java
new file mode 100644 (file)
index 0000000..7d6914e
--- /dev/null
@@ -0,0 +1,5 @@
+public interface Test {
+    void methodA();
+
+    void methodB();
+}
diff --git a/tests/multiIncremental/PR192877/base/src/TestAspect.java b/tests/multiIncremental/PR192877/base/src/TestAspect.java
new file mode 100644 (file)
index 0000000..50d1d1d
--- /dev/null
@@ -0,0 +1,20 @@
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.DeclareParents;
+
+@Aspect
+public class TestAspect {
+   @DeclareParents(value="Foo+",defaultImpl=DefaultTestImpl.class)
+   public Test implementedInterface;
+
+   @Before("execution(* Foo.doSomething()) && this(t)")
+   public void verifyRunningSender(Test t) {
+       t.methodA();
+       t.methodB();
+   }
+   
+   public static void main(String[] args) {
+       Foo foo = new FooImpl();
+       foo.doSomething();
+   }
+}
\ No newline at end of file
diff --git a/tests/multiIncremental/PR192877/inc1/src/Test.java b/tests/multiIncremental/PR192877/inc1/src/Test.java
new file mode 100644 (file)
index 0000000..7d6914e
--- /dev/null
@@ -0,0 +1,5 @@
+public interface Test {
+    void methodA();
+
+    void methodB();
+}
index 69edd6bdfa00bd76ee2e97b1b990087dd6ae4fdc..1c6e8fc032a8d6f41491bf975fdf63c87f00dc96 100644 (file)
@@ -171,6 +171,69 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                // incomplete
        }
 
+       public void testBeanExample() throws Exception {
+               String p = "BeanExample";
+               initialiseProject(p);
+               build(p);
+               dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0);
+               PrintWriter pw = new PrintWriter(System.out);
+               AsmManager.getDefault().dumprels(pw);
+               pw.flush();
+               // incomplete
+       }
+
+       private void checkIfContainsFile(Set s, String filename, boolean shouldBeFound) {
+               StringBuffer sb = new StringBuffer("Set of files\n");
+               for (Iterator iterator = s.iterator(); iterator.hasNext();) {
+                       Object object = iterator.next();
+                       sb.append(object).append("\n");
+               }
+               for (Iterator iterator = s.iterator(); iterator.hasNext();) {
+                       File fname = (File) iterator.next();
+                       if (fname.getName().endsWith(filename)) {
+                               if (!shouldBeFound) {
+                                       System.out.println(sb.toString());
+                                       fail("Unexpectedly found file " + filename);
+                               } else {
+                                       return;
+                               }
+                       }
+               }
+               if (shouldBeFound) {
+                       System.out.println(sb.toString());
+                       fail("Did not find filename " + filename);
+               }
+       }
+
+       /**
+        * Checking return values of the AsmManager API calls that can be invoked post incremental build that tell the caller which
+        * files had their relationships altered. As well as the affected (woven) files, it is possible to query the aspects that wove
+        * those files.
+        */
+       public void testChangesOnBuild() throws Exception {
+               String p = "ChangesOnBuild";
+               initialiseProject(p);
+               build(p);
+               // Not incremental
+               checkIfContainsFile(AsmManager.getDefault().getModelChangesOnLastBuild(), "A.java", false);
+               alter(p, "inc1");
+               build(p);
+               // Incremental
+               checkIfContainsFile(AsmManager.getDefault().getModelChangesOnLastBuild(), "A.java", true);
+               checkIfContainsFile(AsmManager.getDefault().getAspectsWeavingFilesOnLastBuild(), "X.java", true);
+               checkIfContainsFile(AsmManager.getDefault().getAspectsWeavingFilesOnLastBuild(), "Y.java", false);
+       }
+
+       public void testITDIncremental_pr192877() {
+               String p = "PR192877";
+               initialiseProject(p);
+               build(p);
+               checkWasFullBuild();
+               alter(p, "inc1");
+               build(p);
+               checkWasntFullBuild();
+       }
+
        public void testAdviceHandlesAreJDTCompatible() {
                String p = "AdviceHandles";
                initialiseProject(p);
@@ -363,10 +426,10 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                configureAspectPath(bug2, getProjectRelativePath(bug, "bin"));
                build(bug);
                build(bug2);
-//             dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0);
-//             PrintWriter pw = new PrintWriter(System.out);
-//             AsmManager.getDefault().dumprels(pw);
-//             pw.flush();
+               // dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0);
+               // PrintWriter pw = new PrintWriter(System.out);
+               // AsmManager.getDefault().dumprels(pw);
+               // pw.flush();
                IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot();
                assertEquals("=AspectPathTwo/binaries<pkg(Asp.class}Asp&before", findElementAtLine(root, 5).getHandleIdentifier());
                assertEquals("=AspectPathTwo/binaries<(Asp2.class}Asp2&before", findElementAtLine(root, 16).getHandleIdentifier());
@@ -516,10 +579,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
        // assertNoErrors();
        // }
 
-       /*
-        * public void testRefactoring_pr148285() { configureBuildStructureModel(true); initialiseProject("PR148285");
-        * build("PR148285"); System.err.println("xxx"); alter("PR148285","inc1"); build("PR148285"); }
-        */
+       public void testRefactoring_pr148285() {
+               // configureBuildStructureModel(true);
+
+               initialiseProject("PR148285");
+               build("PR148285");
+               alter("PR148285", "inc1");
+               build("PR148285");
+       }
 
        /**
         * In order for this next test to run, I had to move the weaver/world pair we keep in the AjBuildManager instance down into the