From 9b68a31302174ba06218e5e1182653297f722110 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 30 Sep 2008 20:51:53 +0000 Subject: [PATCH] 192877: testcode --- .../PR192877/base/src/DefaultTestImpl.java | 10 +++ .../PR192877/base/src/Foo.java | 4 + .../PR192877/base/src/FooImpl.java | 5 ++ .../PR192877/base/src/Test.java | 5 ++ .../PR192877/base/src/TestAspect.java | 20 +++++ .../PR192877/inc1/src/Test.java | 5 ++ .../tools/MultiProjectIncrementalTests.java | 83 +++++++++++++++++-- 7 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java create mode 100644 tests/multiIncremental/PR192877/base/src/Foo.java create mode 100644 tests/multiIncremental/PR192877/base/src/FooImpl.java create mode 100644 tests/multiIncremental/PR192877/base/src/Test.java create mode 100644 tests/multiIncremental/PR192877/base/src/TestAspect.java create mode 100644 tests/multiIncremental/PR192877/inc1/src/Test.java diff --git a/tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java b/tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java new file mode 100644 index 000000000..1a2954354 --- /dev/null +++ b/tests/multiIncremental/PR192877/base/src/DefaultTestImpl.java @@ -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 index 000000000..9eac48b58 --- /dev/null +++ b/tests/multiIncremental/PR192877/base/src/Foo.java @@ -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 index 000000000..85c45fa74 --- /dev/null +++ b/tests/multiIncremental/PR192877/base/src/FooImpl.java @@ -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 index 000000000..7d6914e2c --- /dev/null +++ b/tests/multiIncremental/PR192877/base/src/Test.java @@ -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 index 000000000..50d1d1dc9 --- /dev/null +++ b/tests/multiIncremental/PR192877/base/src/TestAspect.java @@ -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 index 000000000..7d6914e2c --- /dev/null +++ b/tests/multiIncremental/PR192877/inc1/src/Test.java @@ -0,0 +1,5 @@ +public interface Test { + void methodA(); + + void methodB(); +} diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 69edd6bdf..1c6e8fc03 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -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