diff options
7 files changed, 1077 insertions, 641 deletions
diff --git a/tests/model/expected/pr160469_1.txt b/tests/model/expected/pr160469_1.txt index 7a0d90850..0a33af51b 100644 --- a/tests/model/expected/pr160469_1.txt +++ b/tests/model/expected/pr160469_1.txt @@ -15,9 +15,9 @@ === END OF MODEL REPORT ========= === RELATIONSHIPS REPORT ========= After a batch build (targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning (advises) <test{Simple.java[Simple~Simple -(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before (advises) <test{Simple.java[Simple~Simple +(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before!2 (advises) <test{Simple.java[Simple~Simple (targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning -(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before +(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before!2 === END OF RELATIONSHIPS REPORT == === Properties of the model and relationships map ===== import reference=2 diff --git a/tests/model/expected/pr77269_1.txt b/tests/model/expected/pr77269_1.txt index 204502765..a5ef46b3c 100644 --- a/tests/model/expected/pr77269_1.txt +++ b/tests/model/expected/pr77269_1.txt @@ -14,8 +14,8 @@ before(): p.. [advice] TEST_SANDBOX\pack\pr77269.aj:21: === END OF MODEL REPORT ========= === RELATIONSHIPS REPORT ========= After a batch build -(targets=1) <pack*pr77269.aj}A&before (advises) <pack*pr77269.aj[Test~testMethod[new Runnable() {..}~run -(targets=1) <pack*pr77269.aj[Test~testMethod[new Runnable() {..}~run (advised by) <pack*pr77269.aj}A&before +(targets=1) <pack*pr77269.aj}A&before (advises) <pack*pr77269.aj[Test~testMethod[new Runnable~run +(targets=1) <pack*pr77269.aj[Test~testMethod[new Runnable~run (advised by) <pack*pr77269.aj}A&before === END OF RELATIONSHIPS REPORT == === Properties of the model and relationships map ===== method=3 diff --git a/tests/model/expected/pr77269_3.txt b/tests/model/expected/pr77269_3.txt index 02f10cfa1..8e45449a3 100644 --- a/tests/model/expected/pr77269_3.txt +++ b/tests/model/expected/pr77269_3.txt @@ -13,8 +13,8 @@ declare warning: "blah blah blah" [declare warning] TEST_SANDBOX\pack\pr77269c.aj:18: === END OF MODEL REPORT ========= === RELATIONSHIPS REPORT ========= After a batch build -(targets=1) <pack*pr77269c.aj}A`declare warning (matched by) <pack*pr77269c.aj[Test~testMethod[new Runnable() {..}~run?method-call(void pack.Test.someMethod()) -(targets=1) <pack*pr77269c.aj[Test~testMethod[new Runnable() {..}~run?method-call(void pack.Test.someMethod()) (matches declare) <pack*pr77269c.aj}A`declare warning +(targets=1) <pack*pr77269c.aj}A`declare warning (matched by) <pack*pr77269c.aj[Test~testMethod[new Runnable~run?method-call(void pack.Test.someMethod()) +(targets=1) <pack*pr77269c.aj[Test~testMethod[new Runnable~run?method-call(void pack.Test.someMethod()) (matches declare) <pack*pr77269c.aj}A`declare warning === END OF RELATIONSHIPS REPORT == === Properties of the model and relationships map ===== method=3 diff --git a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index eba17ef8b..a13f11444 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -11,6 +11,7 @@ package org.aspectj.systemtest.ajc153; import java.io.File; +import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -26,7 +27,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { IElementHandleProvider handleProvider; - + protected void setUp() throws Exception { super.setUp(); handleProvider = AsmManager.getDefault().getHandleProvider(); @@ -37,7 +38,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { super.tearDown(); AsmManager.getDefault().setHandleProvider(handleProvider); } - + public void testMoreThanOneNamedPointcut() { runTest("More than one named pointcut"); } @@ -55,17 +56,14 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testAdviceHandle() { runTest("advice handle"); compareHandles(IProgramElement.Kind.ADVICE, - "before(): <anonymous pointcut>", - "<pkg*A2.aj}A2&before"); + "before(): <anonymous pointcut>", "<pkg*A2.aj}A2&before"); } public void testPointcutHandle() { runTest("pointcut handle"); - compareHandles(IProgramElement.Kind.POINTCUT, - "p()", - "<pkg*A4.aj}A4+p"); + compareHandles(IProgramElement.Kind.POINTCUT, "p()", "<pkg*A4.aj}A4+p"); } - + public void testGetIPEWithAspectHandle() { runTest("get IProgramElement with aspect handle"); IHierarchy top = AsmManager.getDefault().getHierarchy(); @@ -73,23 +71,21 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { IProgramElement ipe = top.getElement(handle); assertNotNull("should have found ipe with handle " + handle, ipe); IProgramElement ipe2 = top.getElement(handle); - assertEquals("should be the same IPE",ipe,ipe2); + assertEquals("should be the same IPE", ipe, ipe2); } - + public void testAdviceHandleWithCrossCutting() { runTest("advice handle with crosscutting"); compareHandles(IProgramElement.Kind.ADVICE, - "before(): <anonymous pointcut>", - "<pkg*A3.aj}A3&before"); + "before(): <anonymous pointcut>", "<pkg*A3.aj}A3&before"); } public void testPointcutHandleWithArgs() { runTest("pointcut handle with args"); - compareHandles(IProgramElement.Kind.POINTCUT, - "p(java.lang.Integer)", + compareHandles(IProgramElement.Kind.POINTCUT, "p(java.lang.Integer)", "*A6.aj}A6+p+QInteger;"); } - + public void testAdviceHandleWithArgs() { runTest("advice handle with args"); compareHandles(IProgramElement.Kind.ADVICE, @@ -99,53 +95,49 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testFieldITD() { runTest("field itd handle"); - compareHandles(IProgramElement.Kind.INTER_TYPE_FIELD, - "C.x", + compareHandles(IProgramElement.Kind.INTER_TYPE_FIELD, "C.x", "<pkg*A9.aj}A9)C.x"); } - + public void testMethodITD() { runTest("method itd handle"); - compareHandles(IProgramElement.Kind.INTER_TYPE_METHOD, - "C.method()", + compareHandles(IProgramElement.Kind.INTER_TYPE_METHOD, "C.method()", "<pkg*A9.aj}A9)C.method"); } - + public void testMethodITDWithArgs() { runTest("method itd with args handle"); compareHandles(IProgramElement.Kind.INTER_TYPE_METHOD, - "C.methodWithArgs(int)", - "<pkg*A9.aj}A9)C.methodWithArgs)I"); + "C.methodWithArgs(int)", "<pkg*A9.aj}A9)C.methodWithArgs)I"); } - + public void testConstructorITDWithArgs() { runTest("constructor itd with args"); compareHandles(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR, - "C.C(int,java.lang.String)", - "<pkg*A13.aj}A13)C.C)I)QString;"); + "C.C(int,java.lang.String)", "<pkg*A13.aj}A13)C.C)I)QString;"); } - + public void testDeclareParentsHandle() { runTest("declare parents handle"); compareHandles(IProgramElement.Kind.DECLARE_PARENTS, "declare parents: implements C2", "<pkg*A7.aj}A7`declare parents"); } - + public void testTwoDeclareParents() { runTest("two declare parents in same file"); compareHandles(IProgramElement.Kind.DECLARE_PARENTS, "declare parents: extends C5", "<pkg*A7.aj}A7`declare parents!2"); } - + public void testMethodCallHandle() { runTest("method call handle"); compareHandles(IProgramElement.Kind.CODE, "method-call(void pkg.C.m2())", "<pkg*A10.aj[C~m1?method-call(void pkg.C.m2())"); } - + public void testDeclareAtType() { // AJDT: =AJHandleProject/src<pkg*A.aj}A`declare \@type runTest("declare @type"); @@ -153,33 +145,32 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { "declare @type: pkg.C : @MyAnnotation", "<pkg*A12.aj}A`declare @type"); } - + public void testDeclareAtField() { // AJDT: =AJHandleProject/src<pkg*A.aj}A`declare \@field runTest("declare @field"); compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, "declare @field: int pkg.C.someField : @MyAnnotation", - "<pkg*A12.aj}A`declare @field!2"); + "<pkg*A12.aj}A`declare @field!2"); } - + public void testDeclareAtMethod() { // AJDT: =AJHandleProject/src<pkg*A.aj}A`declare \@method runTest("declare @method"); compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, "declare @method: public void pkg.C.method1() : @MyAnnotation", - "<pkg*A12.aj}A`declare @method!3"); + "<pkg*A12.aj}A`declare @method!3"); } - + public void testDeclareAtConstructor() { // AJDT: =AJHandleProject/src<pkg*A.aj}A`declare \@constructor runTest("declare @constructor"); compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, "declare @constructor: pkg.C.new() : @MyAnnotation", - "<pkg*A12.aj}A`declare @constructor!4"); + "<pkg*A12.aj}A`declare @constructor!4"); } - - - // what about 2 pieces of before advice with the same + + // what about 2 pieces of before advice with the same // signature and the same pointcut public void testTwoPiecesOfAdviceWithSameSignatureAndPointcut() { runTest("two pieces of advice with the same signature and pointcut"); @@ -203,30 +194,30 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String expected2 = "<pkg*A5.aj}A5&before!2"; boolean b = expected1.equals(handle1); if (b) { - assertEquals("handleIdentifier - expected " + expected2 + ", but found " - + handle2, expected2, handle2); + assertEquals("handleIdentifier - expected " + expected2 + + ", but found " + handle2, expected2, handle2); } else { - assertEquals("handleIdentifier - expected " + expected1 + ", but found " - + handle2, expected1, handle2); - assertEquals("handleIdentifier - expected " + expected2 + ", but found " - + handle1, expected2, handle1); + assertEquals("handleIdentifier - expected " + expected1 + + ", but found " + handle2, expected1, handle2); + assertEquals("handleIdentifier - expected " + expected2 + + ", but found " + handle1, expected2, handle1); } } - + public void testDeclareWarningHandle() { runTest("declare warning handle"); compareHandles(IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"Illegal call.\"", "<pkg*A11.aj}A11`declare warning"); } - + public void testTwoDeclareWarningHandles() { runTest("two declare warning handles"); compareHandles(IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"blah\"", "<pkg*A11.aj}A11`declare warning!2"); } - + // this is to ensure the logic for not including '1' in the count // works correctly. We don't want a decw ipe with count 1 but we do // want one with count 10. @@ -244,198 +235,218 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { // these two handles are the same unless we have added a counter // on the end public void testIPEsWithSameNameHaveUniqueHandles_methodCall() { - runTest("ipes with same name have unique handles - method-call"); + runTest("ipes with same name have unique handles - method-call"); IHierarchy top = AsmManager.getDefault().getHierarchy(); - String handle1 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + - "void java.io.PrintStream.println(java.lang.String))"; - assertNotNull("expected to find node with handle " + handle1 - + ", but did not",top.getElement(handle1)); - - String handle2 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + - "void java.io.PrintStream.println(java.lang.String))!2"; - assertNotNull("expected to find node with handle " + handle2 - + ", but did not",top.getElement(handle2)); - - String handle3 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + - "void java.io.PrintStream.println(java.lang.String))!3"; - assertNull("expected not to find node with handle " + handle3 - + ", but found one",top.getElement(handle3)); - } - + String handle1 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + + "void java.io.PrintStream.println(java.lang.String))"; + assertNotNull("expected to find node with handle " + handle1 + + ", but did not", top.getElement(handle1)); + + String handle2 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + + "void java.io.PrintStream.println(java.lang.String))!2"; + assertNotNull("expected to find node with handle " + handle2 + + ", but did not", top.getElement(handle2)); + + String handle3 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" + + "void java.io.PrintStream.println(java.lang.String))!3"; + assertNull("expected not to find node with handle " + handle3 + + ", but found one", top.getElement(handle3)); + } + // these two handles should be different anyway so second one // shouldn't have the "2" public void testIPEsWithDiffNamesDontHaveCounter_methodCall() { runTest("ipes with different names do not have counter - method-call"); IHierarchy top = AsmManager.getDefault().getHierarchy(); - String handle1 = "*TwoDiffMethodCalls.aj[Main~main~\\[QString;?method-call(" + - "void java.io.PrintStream.println(java.lang.String))"; - assertNotNull("expected to find node with handle " + handle1 - + ", but did not",top.getElement(handle1)); + String handle1 = "*TwoDiffMethodCalls.aj[Main~main~\\[QString;?method-call(" + + "void java.io.PrintStream.println(java.lang.String))"; + assertNotNull("expected to find node with handle " + handle1 + + ", but did not", top.getElement(handle1)); - String handle2 = "*TwoDiffMethodCalls.aj[Main~method~\\[QString;?method-call(" + - "void java.io.PrintStream.println(java.lang.String))"; - assertNotNull("expected to find node with handle " + handle2 - + ", but did not",top.getElement(handle2)); + String handle2 = "*TwoDiffMethodCalls.aj[Main~method~\\[QString;?method-call(" + + "void java.io.PrintStream.println(java.lang.String))"; + assertNotNull("expected to find node with handle " + handle2 + + ", but did not", top.getElement(handle2)); } - + public void testIPEsWithSameNameHaveUniqueHandles_handler() { runTest("ipes with same name have unique handles - handler"); IHierarchy top = AsmManager.getDefault().getHierarchy(); - String handle1 = "*Handler.aj[C~method?exception-handler(void C." + - "<catch>(java.io.FileNotFoundException))"; - assertNotNull("expected to find node with handle " + handle1 - + ", but did not",top.getElement(handle1)); + String handle1 = "*Handler.aj[C~method?exception-handler(void C." + + "<catch>(java.io.FileNotFoundException))"; + assertNotNull("expected to find node with handle " + handle1 + + ", but did not", top.getElement(handle1)); - String handle2 = "*Handler.aj[C~method?exception-handler(void C." + - "<catch>(java.io.FileNotFoundException))!2"; - assertNotNull("expected to find node with handle " + handle2 - + ", but did not",top.getElement(handle2)); + String handle2 = "*Handler.aj[C~method?exception-handler(void C." + + "<catch>(java.io.FileNotFoundException))!2"; + assertNotNull("expected to find node with handle " + handle2 + + ", but did not", top.getElement(handle2)); } - + public void testIPEsWithSameNameHaveUniqueHandles_get() { runTest("ipes with same name have unique handles - get"); IHierarchy top = AsmManager.getDefault().getHierarchy(); String handle1 = "*Get.aj[C1~method1?field-get(int C1.x)"; - assertNotNull("expected to find node with handle " + handle1 - + ", but did not",top.getElement(handle1)); + assertNotNull("expected to find node with handle " + handle1 + + ", but did not", top.getElement(handle1)); String handle2 = "*Get.aj[C1~method1?field-get(int C1.x)!2"; - assertNotNull("expected to find node with handle " + handle2 - + ", but did not",top.getElement(handle2)); + assertNotNull("expected to find node with handle " + handle2 + + ", but did not", top.getElement(handle2)); } - + public void testIPEsWithSameNameHaveUniqueHandles_set() { runTest("ipes with same name have unique handles - set"); IHierarchy top = AsmManager.getDefault().getHierarchy(); String handle1 = "*Set.aj[C1~method?field-set(int C1.x)"; - assertNotNull("expected to find node with handle " + handle1 - + ", but did not",top.getElement(handle1)); + assertNotNull("expected to find node with handle " + handle1 + + ", but did not", top.getElement(handle1)); String handle2 = "*Set.aj[C1~method?field-set(int C1.x)!2"; - assertNotNull("expected to find node with handle " + handle2 - + ", but did not",top.getElement(handle2)); + assertNotNull("expected to find node with handle " + handle2 + + ", but did not", top.getElement(handle2)); } - + public void testTwoPiecesOfBeforeAdviceInInjarAspectHaveUniqueHandles_pr159896() { runTest("advice with same name in injar aspect should have unique handles"); IHierarchy top = AsmManager.getDefault().getHierarchy(); String handle1 = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.ADVICE,"before(): p..").getHandleIdentifier(); + IProgramElement.Kind.ADVICE, "before(): p..") + .getHandleIdentifier(); String handle2 = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.ADVICE,"before(): exec..").getHandleIdentifier(); - assertFalse("expected the two advice nodes to have unique handles but" + - " did not", handle1.equals(handle2)); + IProgramElement.Kind.ADVICE, "before(): exec..") + .getHandleIdentifier(); + assertFalse("expected the two advice nodes to have unique handles but" + + " did not", handle1.equals(handle2)); + try { + AsmManager.getDefault().dumptree( + AsmManager.getDefault().getHierarchy().getRoot(), 0); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public void testTwoDeclareWarningsInInjarAspectHaveUniqueHandles_pr159896() { runTest("declare warnings in injar aspect should have unique handles"); IHierarchy top = AsmManager.getDefault().getHierarchy(); String handle1 = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.DECLARE_WARNING,"declare warning: \"blah\"").getHandleIdentifier(); + IProgramElement.Kind.DECLARE_WARNING, + "declare warning: \"blah\"").getHandleIdentifier(); String handle2 = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.DECLARE_WARNING,"declare warning: \"blah2\"").getHandleIdentifier(); - assertFalse("expected the two declare warning nodes to have unique handles but" + - " did not", handle1.equals(handle2)); + IProgramElement.Kind.DECLARE_WARNING, + "declare warning: \"blah2\"").getHandleIdentifier(); + assertFalse( + "expected the two declare warning nodes to have unique handles but" + + " did not", handle1.equals(handle2)); } - - // if have one declare warning and one declare error statement within an injar - // aspect, neither of them should have a counter (i.e. "!2") at the end of + + // if have one declare warning and one declare error statement within an + // injar + // aspect, neither of them should have a counter (i.e. "!2") at the end of // their handle public void testOnlyIncrementSameDeclareTypeFromInjar_pr159896() { runTest("dont increment counter for different declares"); IHierarchy top = AsmManager.getDefault().getHierarchy(); - String warning = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.DECLARE_WARNING,"declare warning: \"warning\"").getHandleIdentifier(); - assertTrue("shouldn't have incremented counter for declare warning handle " + - "because only one declare warning statement", - warning.indexOf("!0") == -1 && warning.indexOf("!2") == -1); - String error = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.DECLARE_ERROR,"declare error: \"error\"").getHandleIdentifier(); - assertTrue("shouldn't have incremented counter for declare error handle " + - "because only one declare error statement", - error.indexOf("!0") == -1 && error.indexOf("!2") == -1); - } - - public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() { - runTest("dont increment counter for different advice kinds"); - IHierarchy top = AsmManager.getDefault().getHierarchy(); - String before = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.ADVICE,"before(): p..").getHandleIdentifier(); - assertTrue("shouldn't have incremented counter for before handle " + - "because only one before advice", - before.indexOf("!0") == -1 && before.indexOf("!2") == -1 && before.indexOf("!3") == -1 ); - String after = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.ADVICE,"after(): p..").getHandleIdentifier(); - assertTrue("shouldn't have incremented counter for after handle " + - "because only one after advice", - after.indexOf("!0") == -1 && after.indexOf("!2") == -1 && after.indexOf("!3") == -1 ); - String around = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.ADVICE,"around(): p1..").getHandleIdentifier(); - assertTrue("shouldn't have incremented counter for around handle " + - "because only one around advice", - around.indexOf("!0") == -1 && around.indexOf("!2") == -1 && around.indexOf("!3") == -1 ); - - } - - //---------- following tests ensure we produce the same handles as jdt -----// - //---------- (apart from the prefix) - + String warning = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.DECLARE_WARNING, + "declare warning: \"warning\"").getHandleIdentifier(); + assertTrue( + "shouldn't have incremented counter for declare warning handle " + + "because only one declare warning statement", warning + .indexOf("!0") == -1 + && warning.indexOf("!2") == -1); + String error = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.DECLARE_ERROR, "declare error: \"error\"") + .getHandleIdentifier(); + assertTrue( + "shouldn't have incremented counter for declare error handle " + + "because only one declare error statement", error + .indexOf("!0") == -1 + && error.indexOf("!2") == -1); + } + + // public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() { + // runTest("dont increment counter for different advice kinds"); + // IHierarchy top = AsmManager.getDefault().getHierarchy(); + // String before = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "before(): p..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for before handle " + // + "because only one before advice", before.indexOf("!0") == -1 + // && before.indexOf("!2") == -1 && before.indexOf("!3") == -1); + // String after = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "after(): p..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for after handle " + // + "because only one after advice", after.indexOf("!0") == -1 + // && after.indexOf("!2") == -1 && after.indexOf("!3") == -1); + // String around = top.findElementForLabel(top.getRoot(), + // IProgramElement.Kind.ADVICE, "around(): p1..") + // .getHandleIdentifier(); + // assertTrue("shouldn't have incremented counter for around handle " + // + "because only one around advice", around.indexOf("!0") == -1 + // && around.indexOf("!2") == -1 && around.indexOf("!3") == -1); + // + // } + + // ---------- following tests ensure we produce the same handles as jdt + // -----// + // ---------- (apart from the prefix) + // NOTES: there is no ipe equivalent to a package fragment root or // - + public void testCompilationUnitSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java runTest("compilation unit same as jdt"); - compareHandles(IProgramElement.Kind.FILE_JAVA, - "Demo.java", + compareHandles(IProgramElement.Kind.FILE_JAVA, "Demo.java", "<tjp{Demo.java"); } public void testClassSameAsJDT() { // JDT: =Java5 Handles/src<pkg{C.java[C runTest("class same as jdt"); - compareHandles(IProgramElement.Kind.CLASS, - "C","<pkg{C.java[C"); + compareHandles(IProgramElement.Kind.CLASS, "C", "<pkg{C.java[C"); } public void testInterfaceSameAsJDT() { // JDT: =Java5 Handles/src<pkg{C.java[MyInterface runTest("interface same as jdt"); - compareHandles(IProgramElement.Kind.INTERFACE, - "MyInterface","<pkg{C.java[MyInterface"); + compareHandles(IProgramElement.Kind.INTERFACE, "MyInterface", + "<pkg{C.java[MyInterface"); } - + public void testConstructorSameAsJDT() { // JDT: =Java5 Handles/src<pkg{C.java[C~C runTest("constructor same as jdt"); - compareHandles(IProgramElement.Kind.CONSTRUCTOR, - "C()","<pkg{C.java[C~C"); + compareHandles(IProgramElement.Kind.CONSTRUCTOR, "C()", + "<pkg{C.java[C~C"); } - + public void testConstructorWithArgsSameAsJDT() { // JDT: =Java5 Handles/src<pkg{C.java[C~C~QString; runTest("constructor with args same as jdt"); - compareHandles(IProgramElement.Kind.CONSTRUCTOR, - "C(java.lang.String)","<pkg{C.java[C~C~QString;"); - } - -// public void testPackageDeclarationSameAsJDT() { -// // JDT: =TJP Example/src<tjp{Demo.java%tjp -// fail("package declaration isn't the same"); -// runTest("package declaration same as jdt"); -// compareHandles(IProgramElement.Kind.PACKAGE, -// "tjp", -// "<tjp{Demo.java%tjp"); -// } - + compareHandles(IProgramElement.Kind.CONSTRUCTOR, "C(java.lang.String)", + "<pkg{C.java[C~C~QString;"); + } + + // public void testPackageDeclarationSameAsJDT() { + // // JDT: =TJP Example/src<tjp{Demo.java%tjp + // fail("package declaration isn't the same"); + // runTest("package declaration same as jdt"); + // compareHandles(IProgramElement.Kind.PACKAGE, + // "tjp", + // "<tjp{Demo.java%tjp"); + // } + public void testImportDeclarationSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java#java.io.* runTest("import declaration same as jdt"); - compareHandles(IProgramElement.Kind.IMPORT_REFERENCE, - "java.io.*", + compareHandles(IProgramElement.Kind.IMPORT_REFERENCE, "java.io.*", "<tjp{Demo.java#java.io.*"); - } - + } + public void testTypeSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo runTest("type same as jdt"); @@ -445,17 +456,16 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String found = pe.getHandleIdentifier(); assertEquals("handleIdentifier - expected " + expected + ", but found " + found, expected, found); - } - + } + public void testFieldSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo^d runTest("field same as jdt"); - compareHandles(IProgramElement.Kind.FIELD, - "d", - "<tjp{Demo.java[Demo^d"); - } + compareHandles(IProgramElement.Kind.FIELD, "d", "<tjp{Demo.java[Demo^d"); + } + public void testInitializationSameAsJDT() { - // JDT: =TJP Example/src<tjp{Demo.java[Demo|1 + // JDT: =TJP Example/src<tjp{Demo.java[Demo|1 // and =TJP Example/src<tjp{Demo.java[Demo|2 runTest("initialization same as jdt"); IHierarchy top = AsmManager.getDefault().getHierarchy(); @@ -480,55 +490,53 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { System.err.println("actual: " + handle1); System.err.println("actual: " + handle2); if (b) { - assertEquals("handleIdentifier - expected " + expected2 + ", but found " - + handle2, expected2, handle2); + assertEquals("handleIdentifier - expected " + expected2 + + ", but found " + handle2, expected2, handle2); } else { - assertEquals("handleIdentifier - expected " + expected1 + ", but found " - + handle2, expected1, handle2); - assertEquals("handleIdentifier - expected " + expected2 + ", but found " - + handle1, expected2, handle1); + assertEquals("handleIdentifier - expected " + expected1 + + ", but found " + handle2, expected1, handle2); + assertEquals("handleIdentifier - expected " + expected2 + + ", but found " + handle1, expected2, handle1); } - } + } + public void testMethodWithStringArrayArgsSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo~main~\[QString; runTest("method with string array as argument same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "main(java.lang.String[])", + compareHandles(IProgramElement.Kind.METHOD, "main(java.lang.String[])", "<tjp{Demo.java[Demo~main~\\[QString;"); - } - + } + public void testMethodWithIntArrayArgsSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo~m~\[I runTest("method with int array as argument same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "m(int[])", + compareHandles(IProgramElement.Kind.METHOD, "m(int[])", "<tjp{Demo.java[Demo~m~\\[I"); - } - + } + public void testMethodWithNoArgsSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo~go runTest("method with no args same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "go()", + compareHandles(IProgramElement.Kind.METHOD, "go()", "<tjp{Demo.java[Demo~go"); - } - + } + public void testMethodWithTwoArgsSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo~foo~I~QObject; runTest("method with two args same as jdt"); compareHandles(IProgramElement.Kind.METHOD, "foo(int,java.lang.Object)", "<tjp{Demo.java[Demo~foo~I~QObject;"); - } - + } + public void testMethodWithTwoStringArgsSameAsJDT() { // JDT: =TJP Example/src<tjp{Demo.java[Demo~m2~QString;~QString; runTest("method with two string args same as jdt"); compareHandles(IProgramElement.Kind.METHOD, "m2(java.lang.String,java.lang.String)", - "<tjp{Demo.java[Demo~m2~QString;~QString;"); + "<tjp{Demo.java[Demo~m2~QString;~QString;"); } - + public void testEnumSameAsJDT() { // JDT: =Java5 Handles/src<pkg{E.java[E runTest("enum same as jdt"); @@ -537,16 +545,15 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String expected = "<pkg{E.java[E"; String found = pe.getHandleIdentifier(); assertEquals("handleIdentifier - expected " + expected + ", but found " - + found, expected, found); + + found, expected, found); } - + public void testEnumValueSameAsJDT() { // JDT: =Java5 Handles/src<pkg{E.java[E^A runTest("enum value same as jdt"); - compareHandles(IProgramElement.Kind.ENUM_VALUE, - "A","<pkg{E.java[E^A"); + compareHandles(IProgramElement.Kind.ENUM_VALUE, "A", "<pkg{E.java[E^A"); } - + public void testAnnotationSameAsJDT() { // JDT: =Java5 Handles/src<pkg{MyAnnotation.java[MyAnnotation runTest("annotation same as jdt"); @@ -555,80 +562,74 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { String expected = "<pkg{MyAnnotation.java[MyAnnotation"; String found = pe.getHandleIdentifier(); assertEquals("handleIdentifier - expected " + expected + ", but found " - + found, expected, found); + + found, expected, found); } - + public void testMethodWithListArgSameAsJDT() { // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class~method2~QList; runTest("method with list arg same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "method2(java.util.List)", + compareHandles(IProgramElement.Kind.METHOD, "method2(java.util.List)", "<pkg{Java5Class.java[Java5Class~method2~QList;"); } - + public void testMethodWithGenericArgSameAsJDT() { // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class - // ~genericMethod1~QList\<QString;>; + // ~genericMethod1~QList\<QString;>; runTest("method with generic arg same as jdt"); compareHandles(IProgramElement.Kind.METHOD, "genericMethod1(java.util.List<java.lang.String>)", "<pkg{Java5Class.java[Java5Class~genericMethod1~QList\\<QString;>;"); } - + public void testMethodWithTwoGenericArgsSameAsJDT() { // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class - // ~genericMethod2~QList\<QString;>;~QMyGenericClass\<QInteger;>; + // ~genericMethod2~QList\<QString;>;~QMyGenericClass\<QInteger;>; runTest("method with two generic args same as jdt"); compareHandles(IProgramElement.Kind.METHOD, "genericMethod2(java.util.List<java.lang.String>," - +"pkg.MyGenericClass<java.lang.Integer>)", + + "pkg.MyGenericClass<java.lang.Integer>)", "<pkg{Java5Class.java[Java5Class~genericMethod2~QList" - +"\\<QString;>;~QMyGenericClass\\<QInteger;>;"); + + "\\<QString;>;~QMyGenericClass\\<QInteger;>;"); } - + public void testMethodWithTwoTypeParametersSameAsJDT() { // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class~genericMethod4 - // ~QMyGenericClass2\<QString;QInteger;>; + // ~QMyGenericClass2\<QString;QInteger;>; runTest("method with two type parameters same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, + compareHandles( + IProgramElement.Kind.METHOD, "genericMethod4(pkg.MyGenericClass2<java.lang.String,java.lang.Integer>)", - "<pkg{Java5Class.java[Java5Class~genericMethod4" + - "~QMyGenericClass2\\<QString;QInteger;>;"); + "<pkg{Java5Class.java[Java5Class~genericMethod4" + + "~QMyGenericClass2\\<QString;QInteger;>;"); } - + public void testMethodWithTwoArgsSameAsJDT_2() { // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class - // ~genericMethod3~I~QList\<QString;>; + // ~genericMethod3~I~QList\<QString;>; runTest("method with two args one of which is generic same as jdt"); compareHandles(IProgramElement.Kind.METHOD, "genericMethod3(int,java.util.List<java.lang.String>)", "<pkg{Java5Class.java[Java5Class~genericMethod3~I~QList\\<QString;>;"); } - + /* - * Still to do; - * PROJECT, - PACKAGE, - FILE, - FILE_ASPECTJ, - FILE_LST, - DECLARE_ERROR, - DECLARE_SOFT, - DECLARE_PRECEDENCE, + * Still to do; PROJECT, PACKAGE, FILE, FILE_ASPECTJ, FILE_LST, + * DECLARE_ERROR, DECLARE_SOFT, DECLARE_PRECEDENCE, */ - + // ----------- helper methods --------------- - - private void compareHandles(IProgramElement.Kind kind, String ipeName, String expectedHandle) { + private void compareHandles(IProgramElement.Kind kind, String ipeName, + String expectedHandle) { IHierarchy top = AsmManager.getDefault().getHierarchy(); - IProgramElement pe = top.findElementForLabel(top.getRoot(),kind,ipeName); + IProgramElement pe = top.findElementForLabel(top.getRoot(), kind, + ipeName); String found = pe.getHandleIdentifier(); System.err.println("expected: " + expectedHandle); System.err.println("actual: " + found); - assertEquals("handleIdentifier - expected " + expectedHandle + ", but found " - + found, expectedHandle, found); + assertEquals("handleIdentifier - expected " + expectedHandle + + ", but found " + found, expectedHandle, found); } - + // /////////////////////////////////////// public static Test suite() { return XMLBasedAjcTestCase.loadSuite(JDTLikeHandleProviderTests.class); diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 61eff8711..1890a388c 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -53,6 +53,11 @@ public class AjdeInteractionTestbed extends TestCase { public void configureNewProjectDependency(String fromProjectName, String projectItDependsOn) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + fromProjectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).addDependancy(projectItDependsOn); + } + + public void addSourceFolderForSourceFile(String projectName, File f, String sourceFolder) { + AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); + ((MultiProjTestOutputLocationManager)((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).getOutputLocationManager()).setSourceFolderFor(f,sourceFolder); } public void setNextChangeResponse(String projName, int flags) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java index 21df32114..9d07d1ec7 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java @@ -12,7 +12,9 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.aspectj.ajde.core.IOutputLocationManager; @@ -27,6 +29,7 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage private String testProjectOutputPath; private File classOutputLoc; private File resourceOutputLoc; + private Map sourceFolders = new HashMap(); private List allOutputLocations; public MultiProjTestOutputLocationManager(String testProjectPath) { @@ -73,8 +76,17 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage classOutputLoc = f; } + public void setSourceFolderFor(File sourceFile,String sourceFolder) { + sourceFolders.put(sourceFile.getPath(),sourceFolder); + } + public void setOutputLocForResource(File f) { resourceOutputLoc = f; } + public String getSourceFolderForFile(File sourceFile) { + String f = (String)sourceFolders.get(sourceFile.getPath()); + return f; + } + } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index d3a939b56..6f143541d 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -37,23 +37,30 @@ import org.aspectj.tools.ajc.Ajc; import org.aspectj.util.FileUtil; /** - * The superclass knows all about talking through Ajde to the compiler. The superclass isn't in charge of knowing how to simulate - * overlays for incremental builds, that is in here. As is the ability to generate valid build configs based on a directory - * structure. To support this we just need access to a sandbox directory - this sandbox is managed by the superclass (it only - * assumes all builds occur in <sandboxDir>/<projectName>/ ) + * The superclass knows all about talking through Ajde to the compiler. The + * superclass isn't in charge of knowing how to simulate overlays for + * incremental builds, that is in here. As is the ability to generate valid + * build configs based on a directory structure. To support this we just need + * access to a sandbox directory - this sandbox is managed by the superclass (it + * only assumes all builds occur in <sandboxDir>/<projectName>/ ) * - * The idea is you can initialize multiple projects in the sandbox and they can all be built independently, hopefully exploiting - * incremental compilation. Between builds you can alter the contents of a project using the alter() method that overlays some set - * of new files onto the current set (adding new files/changing existing ones) - you can then drive a new build and check it behaves - * as expected. + * The idea is you can initialize multiple projects in the sandbox and they can + * all be built independently, hopefully exploiting incremental compilation. + * Between builds you can alter the contents of a project using the alter() + * method that overlays some set of new files onto the current set (adding new + * files/changing existing ones) - you can then drive a new build and check it + * behaves as expected. */ -public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { +public class MultiProjectIncrementalTests extends + AbstractMultiProjectIncrementalAjdeInteractionTestbed { /* - * A.aj package pack; public aspect A { pointcut p() : call( C.method before() : p() { // line 7 } } + * A.aj package pack; public aspect A { pointcut p() : call( C.method + * before() : p() { // line 7 } } * - * C.java package pack; public class C { public void method1() { method2(); // line 6 } public void method2() { } public void - * method3() { method2(); // line 13 } + * C.java package pack; public class C { public void method1() { method2(); + * // line 6 } public void method2() { } public void method3() { method2(); + * // line 13 } * * } */ @@ -62,56 +69,80 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; initialiseProject("P4"); build("P4"); - Ajc.dumpAJDEStructureModel("after full build where advice is applying"); + Ajc + .dumpAJDEStructureModel("after full build where advice is applying"); // should be 4 relationship entries // In inc1 the first advised line is 'commented out' alter("P4", "inc1"); build("P4"); checkWasntFullBuild(); - Ajc.dumpAJDEStructureModel("after inc build where first advised line is gone"); + Ajc + .dumpAJDEStructureModel("after inc build where first advised line is gone"); // should now be 2 relationship entries // This will be the line 6 entry in C.java - IProgramElement codeElement = findCode(checkForNode("pack", "C", true)); + IProgramElement codeElement = findCode(checkForNode("pack", "C", + true)); // This will be the line 7 entry in A.java IProgramElement advice = findAdvice(checkForNode("pack", "A", true)); - IRelationshipMap asmRelMap = AsmManager.getDefault().getRelationshipMap(); - assertEquals("There should be two relationships in the relationship map", 2, asmRelMap.getEntries().size()); + IRelationshipMap asmRelMap = AsmManager.getDefault() + .getRelationshipMap(); + assertEquals( + "There should be two relationships in the relationship map", + 2, asmRelMap.getEntries().size()); - for (Iterator iter = asmRelMap.getEntries().iterator(); iter.hasNext();) { + for (Iterator iter = asmRelMap.getEntries().iterator(); iter + .hasNext();) { String sourceOfRelationship = (String) iter.next(); - IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForHandle(sourceOfRelationship); - assertNotNull("expected to find IProgramElement with handle " + sourceOfRelationship + " but didn't", ipe); + IProgramElement ipe = AsmManager.getDefault().getHierarchy() + .findElementForHandle(sourceOfRelationship); + assertNotNull("expected to find IProgramElement with handle " + + sourceOfRelationship + " but didn't", ipe); if (ipe.getKind().equals(IProgramElement.Kind.ADVICE)) { - assertEquals("expected source of relationship to be " + advice.toString() + " but found " + ipe.toString(), - advice, ipe); + assertEquals("expected source of relationship to be " + + advice.toString() + " but found " + + ipe.toString(), advice, ipe); } else if (ipe.getKind().equals(IProgramElement.Kind.CODE)) { - assertEquals( - "expected source of relationship to be " + codeElement.toString() + " but found " + ipe.toString(), - codeElement, ipe); + assertEquals("expected source of relationship to be " + + codeElement.toString() + " but found " + + ipe.toString(), codeElement, ipe); } else { - fail("found unexpected relationship source " + ipe + " with kind " + ipe.getKind() - + " when looking up handle: " + sourceOfRelationship); + fail("found unexpected relationship source " + ipe + + " with kind " + ipe.getKind() + + " when looking up handle: " + + sourceOfRelationship); } List relationships = asmRelMap.get(ipe); - assertNotNull("expected " + ipe.getName() + " to have some " + "relationships", relationships); - for (Iterator iterator = relationships.iterator(); iterator.hasNext();) { + assertNotNull("expected " + ipe.getName() + " to have some " + + "relationships", relationships); + for (Iterator iterator = relationships.iterator(); iterator + .hasNext();) { Relationship rel = (Relationship) iterator.next(); List targets = rel.getTargets(); - for (Iterator iterator2 = targets.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = targets.iterator(); iterator2 + .hasNext();) { String t = (String) iterator2.next(); - IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(t); + IProgramElement link = AsmManager.getDefault() + .getHierarchy().findElementForHandle(t); if (ipe.getKind().equals(IProgramElement.Kind.ADVICE)) { - assertEquals("expected target of relationship to be " + codeElement.toString() + " but found " - + link.toString(), codeElement, link); - } else if (ipe.getKind().equals(IProgramElement.Kind.CODE)) { - assertEquals("expected target of relationship to be " + advice.toString() + " but found " - + link.toString(), advice, link); + assertEquals( + "expected target of relationship to be " + + codeElement.toString() + + " but found " + link.toString(), + codeElement, link); + } else if (ipe.getKind().equals( + IProgramElement.Kind.CODE)) { + assertEquals( + "expected target of relationship to be " + + advice.toString() + " but found " + + link.toString(), advice, link); } else { - fail("found unexpected relationship source " + ipe.getName() + " with kind " + ipe.getKind()); + fail("found unexpected relationship source " + + ipe.getName() + " with kind " + + ipe.getKind()); } } } @@ -128,21 +159,86 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("Annos"); checkWasFullBuild(); checkCompileWeaveCount("Annos", 4, 4); - assertEquals("Should be 3 relationships ", 3, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals("Should be 3 relationships ", 3, AsmManager.getDefault() + .getRelationshipMap().getEntries().size()); alter("Annos", "inc1"); // Comment out the annotation on Parent build("Annos"); checkWasntFullBuild(); - assertEquals("Should be no relationships ", 0, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals("Should be no relationships ", 0, AsmManager.getDefault() + .getRelationshipMap().getEntries().size()); checkCompileWeaveCount("Annos", 3, 3); alter("Annos", "inc2"); // Add the annotation back onto Parent build("Annos"); checkWasntFullBuild(); - assertEquals("Should be 3 relationships ", 3, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals("Should be 3 relationships ", 3, AsmManager.getDefault() + .getRelationshipMap().getEntries().size()); checkCompileWeaveCount("Annos", 3, 3); } + public void testSpacewarHandles() { + // String p = "SpaceWar"; + String p = "Simpler"; + initialiseProject(p); + build(p); + dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + // incomplete + } + + public void testModelWithMultipleSourceFolders() { + initialiseProject("MultiSource"); + // File sourceFolderOne = getProjectRelativePath("MultiSource", "src1"); + // File sourceFolderTwo = getProjectRelativePath("MultiSource", "src2"); + // File sourceFolderThree = getProjectRelativePath("MultiSource", + // "src3"); + addSourceFolderForSourceFile("MultiSource", getProjectRelativePath( + "MultiSource", "src1/CodeOne.java"), "src1"); + addSourceFolderForSourceFile("MultiSource", getProjectRelativePath( + "MultiSource", "src2/CodeTwo.java"), "src2"); + addSourceFolderForSourceFile("MultiSource", getProjectRelativePath( + "MultiSource", "src3/pkg/CodeThree.java"), "src3"); + build("MultiSource"); + IProgramElement srcOne = AsmManager.getDefault().getHierarchy() + .findElementForHandle("=MultiSource/src1"); + IProgramElement CodeOneClass = AsmManager.getDefault().getHierarchy() + .findElementForHandle("=MultiSource/src1{CodeOne.java[CodeOne"); + IProgramElement srcTwoPackage = AsmManager.getDefault().getHierarchy() + .findElementForHandle("=MultiSource/src2<pkg"); + IProgramElement srcThreePackage = AsmManager.getDefault() + .getHierarchy().findElementForHandle("=MultiSource/src3<pkg"); + assertNotNull(srcOne); + assertNotNull(CodeOneClass); + assertNotNull(srcTwoPackage); + assertNotNull(srcThreePackage); + if (srcTwoPackage.equals(srcThreePackage)) { + throw new RuntimeException( + "Should not have found these package nodes to be the same, they are in different source folders"); + } + // dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + } + + public static void dumptree(IProgramElement node, int indent) { + for (int i = 0; i < indent; i++) + System.out.print(" "); + String loc = ""; + if (node != null) { + if (node.getSourceLocation() != null) + loc = node.getSourceLocation().toString(); + } + System.out.println(node + " [" + + (node == null ? "null" : node.getKind().toString()) + "] " + + loc); + if (node != null) { + for (int i = 0; i < indent; i++) + System.out.print(" "); + System.out.println(" hid is " + node.getHandleIdentifier()); + for (Iterator i = node.getChildren().iterator(); i.hasNext();) { + dumptree((IProgramElement) i.next(), indent + 2); + } + } + } + public void testIncrementalItdsWithMultipleAspects_pr173729() { initialiseProject("PR173729"); build("PR173729"); @@ -173,21 +269,31 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } /** - * Build a project containing a resource - then mark the resource readOnly(), then do an inc-compile, it will report an error - * about write access to the resource in the output folder being denied + * Build a project containing a resource - then mark the resource + * readOnly(), then do an inc-compile, it will report an error about write + * access to the resource in the output folder being denied */ /* - * public void testProblemCopyingResources_pr138171() { initialiseProject("PR138171"); + * public void testProblemCopyingResources_pr138171() { + * initialiseProject("PR138171"); * - * File f=getProjectRelativePath("PR138171","res.txt"); Map m = new HashMap(); m.put("res.txt",f); - * AjdeInteractionTestbed.MyProjectPropertiesAdapter.getInstance().setSourcePathResources(m); build("PR138171"); File f2 = - * getProjectOutputRelativePath("PR138171","res.txt"); boolean successful = f2.setReadOnly(); + * File f=getProjectRelativePath("PR138171","res.txt"); Map m = new + * HashMap(); m.put("res.txt",f); + * AjdeInteractionTestbed.MyProjectPropertiesAdapter + * .getInstance().setSourcePathResources(m); build("PR138171"); File f2 = + * getProjectOutputRelativePath("PR138171","res.txt"); boolean successful = + * f2.setReadOnly(); * - * alter("PR138171","inc1"); AjdeInteractionTestbed.MyProjectPropertiesAdapter.getInstance().setSourcePathResources(m); - * build("PR138171"); List msgs = MyTaskListManager.getErrorMessages(); - * assertTrue("there should be one message but there are "+(msgs==null?0:msgs.size())+":\n"+msgs,msgs!=null && msgs.size()==1); - * IMessage msg = (IMessage)msgs.get(0); String exp = "unable to copy resource to output folder: 'res.txt'"; - * assertTrue("Expected message to include this text ["+exp+"] but it does not: "+msg,msg.toString().indexOf(exp)!=-1); } + * alter("PR138171","inc1"); + * AjdeInteractionTestbed.MyProjectPropertiesAdapter + * .getInstance().setSourcePathResources(m); build("PR138171"); List msgs = + * MyTaskListManager.getErrorMessages(); + * assertTrue("there should be one message but there are " + * +(msgs==null?0:msgs.size())+":\n"+msgs,msgs!=null && msgs.size()==1); + * IMessage msg = (IMessage)msgs.get(0); String exp = + * "unable to copy resource to output folder: 'res.txt'"; + * assertTrue("Expected message to include this text [" + * +exp+"] but it does not: "+msg,msg.toString().indexOf(exp)!=-1); } */ // Make simple changes to a project, adding a class @@ -212,15 +318,20 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa long timeTakenForFullBuildAndWeave = getTimeTakenForBuild("P1"); checkWasFullBuild(); // it *will* be a full build under the new // "back-to-the-source strategy - checkCompileWeaveCount("P1", 5, 3); // we compile X and A (the delta) find out that + checkCompileWeaveCount("P1", 5, 3); // we compile X and A (the delta) + // find out that // an aspect has changed, go back to the source // and compile X,A,C, then weave them all. build("P1"); long timeTakenForSimpleIncBuild = getTimeTakenForBuild("P1"); - // I don't think this test will have timing issues as the times should be *RADICALLY* different + // I don't think this test will have timing issues as the times should + // be *RADICALLY* different // On my config, first build time is 2093ms and the second is 30ms - assertTrue("Should not take longer for the trivial incremental build! first=" + timeTakenForFullBuildAndWeave - + "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); + assertTrue( + "Should not take longer for the trivial incremental build! first=" + + timeTakenForFullBuildAndWeave + "ms second=" + + timeTakenForSimpleIncBuild + "ms", + timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); } public void testBuildingTwoProjectsInTurns() { @@ -241,33 +352,39 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("pr240360"); checkWasFullBuild(); checkCompileWeaveCount("pr240360", 5, 4); - assertTrue("There should be an error:\n" + getErrorMessages("pr240360"), !getErrorMessages("pr240360").isEmpty()); + assertTrue( + "There should be an error:\n" + getErrorMessages("pr240360"), + !getErrorMessages("pr240360").isEmpty()); Set s = AsmManager.getDefault().getRelationshipMap().getEntries(); int relmapLength = s.size(); // Delete the erroneous type - String f = getWorkingDir().getAbsolutePath() + File.separatorChar + "pr240360" + File.separatorChar + "src" - + File.separatorChar + "test" + File.separatorChar + "Error.java"; + String f = getWorkingDir().getAbsolutePath() + File.separatorChar + + "pr240360" + File.separatorChar + "src" + File.separatorChar + + "test" + File.separatorChar + "Error.java"; (new File(f)).delete(); build("pr240360"); checkWasntFullBuild(); checkCompileWeaveCount("pr240360", 0, 0); - assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap() + .getEntries().size()); // Readd the erroneous type alter("pr240360", "inc1"); build("pr240360"); checkWasntFullBuild(); checkCompileWeaveCount("pr240360", 1, 0); - assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap() + .getEntries().size()); // Change the advice alter("pr240360", "inc2"); build("pr240360"); checkWasFullBuild(); checkCompileWeaveCount("pr240360", 6, 4); - assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap().getEntries().size()); + assertEquals(relmapLength, AsmManager.getDefault().getRelationshipMap() + .getEntries().size()); } @@ -277,7 +394,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("pr102733_1"); checkWasFullBuild(); checkCompileWeaveCount("pr102733_1", 1, 0); - assertTrue("There should be an error:\n" + getErrorMessages("pr102733_1"), !getErrorMessages("pr102733_1").isEmpty()); + assertTrue("There should be an error:\n" + + getErrorMessages("pr102733_1"), !getErrorMessages( + "pr102733_1").isEmpty()); build("pr102733_1"); // incremental checkCompileWeaveCount("pr102733_1", 0, 0); checkWasntFullBuild(); @@ -285,12 +404,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("pr102733_1"); checkWasntFullBuild(); checkCompileWeaveCount("pr102733_1", 1, 1); - assertTrue("There should be no errors:\n" + getErrorMessages("pr102733_1"), getErrorMessages("pr102733_1").isEmpty()); + assertTrue("There should be no errors:\n" + + getErrorMessages("pr102733_1"), + getErrorMessages("pr102733_1").isEmpty()); alter("pr102733_1", "inc2"); // break it again build("pr102733_1"); checkWasntFullBuild(); checkCompileWeaveCount("pr102733_1", 1, 0); - assertTrue("There should be an error:\n" + getErrorMessages("pr102733_1"), !getErrorMessages("pr102733_1").isEmpty()); + assertTrue("There should be an error:\n" + + getErrorMessages("pr102733_1"), !getErrorMessages( + "pr102733_1").isEmpty()); } // public void testDeclareAtType_pr149293() { @@ -305,14 +428,17 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // } /* - * 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"); System.err.println("xxx"); 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 - * state object - this makes perfect sense - otherwise when reusing the state for another project we'd not be switching to the - * right weaver/world for that project. + * 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 state object - this + * makes perfect sense - otherwise when reusing the state for another + * project we'd not be switching to the right weaver/world for that project. */ public void testBuildingTwoProjectsMakingSmallChanges() { @@ -338,13 +464,15 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR134371"); alter("PR134371", "inc1"); build("PR134371"); - assertTrue("There should be no exceptions handled:\n" + getErrorMessages("PR134371"), getErrorMessages("PR134371") + assertTrue("There should be no exceptions handled:\n" + + getErrorMessages("PR134371"), getErrorMessages("PR134371") .isEmpty()); } /** - * Setup up two simple projects and build them in turn - check the structure model is right after each build + * Setup up two simple projects and build them in turn - check the structure + * model is right after each build */ public void testBuildingTwoProjectsAndVerifyingModel() { initialiseProject("P1"); @@ -383,9 +511,11 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } /** - * Complex. Here we are testing that a state object records structural changes since the last full build correctly. We build a - * simple project from scratch - this will be a full build and so the structural changes since last build count should be 0. We - * then alter a class, adding a new method and check structural changes is 1. + * Complex. Here we are testing that a state object records structural + * changes since the last full build correctly. We build a simple project + * from scratch - this will be a full build and so the structural changes + * since last build count should be 0. We then alter a class, adding a new + * method and check structural changes is 1. */ public void testStateManagement1() { @@ -393,128 +523,165 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject("P1"); build("P1"); // full build - AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirectoryForP1); + AjState ajs = IncrementalStateManager + .findStateManagingOutputLocation(binDirectoryForP1); assertTrue("There should be a state object for project P1", ajs != null); - assertTrue("Should be no structural changes as it was a full build but found: " - + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + assertTrue( + "Should be no structural changes as it was a full build but found: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); alter("P1", "inc3"); // adds a method to the class C.java build("P1"); checkWasntFullBuild(); - ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P1", "bin"))); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File( + getFile("P1", "bin"))); assertTrue("There should be state for project P1", ajs != null); checkWasntFullBuild(); - assertTrue("Should be one structural changes as it was a full build but found: " - + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 1); + assertTrue( + "Should be one structural changes as it was a full build but found: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 1); } /** - * Complex. Here we are testing that a state object records structural changes since the last full build correctly. We build a - * simple project from scratch - this will be a full build and so the structural changes since last build count should be 0. We - * then alter a class, changing body of a method, not the structure and check struc changes is still 0. + * Complex. Here we are testing that a state object records structural + * changes since the last full build correctly. We build a simple project + * from scratch - this will be a full build and so the structural changes + * since last build count should be 0. We then alter a class, changing body + * of a method, not the structure and check struc changes is still 0. */ public void testStateManagement2() { File binDirectoryForP1 = new File(getFile("P1", "bin")); initialiseProject("P1"); - alter("P1", "inc3"); // need this change in here so 'inc4' can be applied without making + alter("P1", "inc3"); // need this change in here so 'inc4' can be + // applied without making // it a structural change build("P1"); // full build - AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirectoryForP1); + AjState ajs = IncrementalStateManager + .findStateManagingOutputLocation(binDirectoryForP1); assertTrue("There should be state for project P1", ajs != null); - assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + assertTrue("Should be no struc changes as its a full build: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs .getNumberOfStructuralChangesSinceLastFullBuild() == 0); - alter("P1", "inc4"); // changes body of main() method but does *not* change the structure of C.java + alter("P1", "inc4"); // changes body of main() method but does *not* + // change the structure of C.java build("P1"); checkWasntFullBuild(); - ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P1", "bin"))); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File( + getFile("P1", "bin"))); assertTrue("There should be state for project P1", ajs != null); checkWasntFullBuild(); - assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), - ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + assertTrue("Shouldn't be any structural changes but there were " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + .getNumberOfStructuralChangesSinceLastFullBuild() == 0); } /** - * The C.java file modified in this test has an inner class - this means the inner class has a this$0 field and <init>(C) ctor - * to watch out for when checking for structural changes + * The C.java file modified in this test has an inner class - this means the + * inner class has a this$0 field and <init>(C) ctor to watch out for when + * checking for structural changes * */ public void testStateManagement3() { - File binDirForInterproject1 = new File(getFile("interprojectdeps1", "bin")); + File binDirForInterproject1 = new File(getFile("interprojectdeps1", + "bin")); initialiseProject("interprojectdeps1"); build("interprojectdeps1"); // full build - AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject1); + AjState ajs = IncrementalStateManager + .findStateManagingOutputLocation(binDirForInterproject1); assertTrue("There should be state for project P1", ajs != null); - assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + assertTrue("Should be no struc changes as its a full build: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs .getNumberOfStructuralChangesSinceLastFullBuild() == 0); alter("interprojectdeps1", "inc1"); // adds a space to C.java build("interprojectdeps1"); checkWasntFullBuild(); - ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps1", "bin"))); - assertTrue("There should be state for project interprojectdeps1", ajs != null); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File( + getFile("interprojectdeps1", "bin"))); + assertTrue("There should be state for project interprojectdeps1", + ajs != null); checkWasntFullBuild(); - assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), - ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + assertTrue("Shouldn't be any structural changes but there were " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + .getNumberOfStructuralChangesSinceLastFullBuild() == 0); } /** - * The C.java file modified in this test has an inner class - which has two ctors - this checks how they are mangled with an - * instance of C. + * The C.java file modified in this test has an inner class - which has two + * ctors - this checks how they are mangled with an instance of C. * */ public void testStateManagement4() { - File binDirForInterproject2 = new File(getFile("interprojectdeps2", "bin")); + File binDirForInterproject2 = new File(getFile("interprojectdeps2", + "bin")); initialiseProject("interprojectdeps2"); build("interprojectdeps2"); // full build - AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject2); - assertTrue("There should be state for project interprojectdeps2", ajs != null); - assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + AjState ajs = IncrementalStateManager + .findStateManagingOutputLocation(binDirForInterproject2); + assertTrue("There should be state for project interprojectdeps2", + ajs != null); + assertTrue("Should be no struc changes as its a full build: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs .getNumberOfStructuralChangesSinceLastFullBuild() == 0); alter("interprojectdeps2", "inc1"); // minor change to C.java build("interprojectdeps2"); checkWasntFullBuild(); - ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps2", "bin"))); - assertTrue("There should be state for project interprojectdeps1", ajs != null); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File( + getFile("interprojectdeps2", "bin"))); + assertTrue("There should be state for project interprojectdeps1", + ajs != null); checkWasntFullBuild(); - assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), - ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + assertTrue("Shouldn't be any structural changes but there were " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + .getNumberOfStructuralChangesSinceLastFullBuild() == 0); } /** - * The C.java file modified in this test has an inner class - it has two ctors but also a reference to C.this in it - which will - * give rise to an accessor being created in C + * The C.java file modified in this test has an inner class - it has two + * ctors but also a reference to C.this in it - which will give rise to an + * accessor being created in C * */ public void testStateManagement5() { - File binDirForInterproject3 = new File(getFile("interprojectdeps3", "bin")); + File binDirForInterproject3 = new File(getFile("interprojectdeps3", + "bin")); initialiseProject("interprojectdeps3"); build("interprojectdeps3"); // full build - AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(binDirForInterproject3); - assertTrue("There should be state for project interprojectdeps3", ajs != null); - assertTrue("Should be no struc changes as its a full build: " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + AjState ajs = IncrementalStateManager + .findStateManagingOutputLocation(binDirForInterproject3); + assertTrue("There should be state for project interprojectdeps3", + ajs != null); + assertTrue("Should be no struc changes as its a full build: " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs .getNumberOfStructuralChangesSinceLastFullBuild() == 0); alter("interprojectdeps3", "inc1"); // minor change to C.java build("interprojectdeps3"); checkWasntFullBuild(); - ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("interprojectdeps3", "bin"))); - assertTrue("There should be state for project interprojectdeps1", ajs != null); + ajs = IncrementalStateManager.findStateManagingOutputLocation(new File( + getFile("interprojectdeps3", "bin"))); + assertTrue("There should be state for project interprojectdeps1", + ajs != null); checkWasntFullBuild(); - assertTrue("Shouldn't be any structural changes but there were " + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), - ajs.getNumberOfStructuralChangesSinceLastFullBuild() == 0); + assertTrue("Shouldn't be any structural changes but there were " + + ajs.getNumberOfStructuralChangesSinceLastFullBuild(), ajs + .getNumberOfStructuralChangesSinceLastFullBuild() == 0); } /** - * Now the most complex test. Create a dependancy between two projects. Building one may affect whether the other does an - * incremental or full build. The structural information recorded in the state object should be getting used to control whether - * a full build is necessary... + * Now the most complex test. Create a dependancy between two projects. + * Building one may affect whether the other does an incremental or full + * build. The structural information recorded in the state object should be + * getting used to control whether a full build is necessary... */ public void testBuildingDependantProjects() { initialiseProject("P1"); @@ -525,11 +692,13 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("P2"); // now everything is consistent and compiled alter("P1", "inc1"); // adds a second class build("P1"); - build("P2"); // although a second class was added - P2 can't be using it, so we don't full build here :) + build("P2"); // although a second class was added - P2 can't be using + // it, so we don't full build here :) checkWasntFullBuild(); alter("P1", "inc3"); // structurally changes one of the classes build("P1"); - build("P2"); // build notices the structural change, but is incremental of I and J as they depend on C + build("P2"); // build notices the structural change, but is incremental + // of I and J as they depend on C checkWasntFullBuild(); alter("P1", "inc4"); build("P1"); @@ -552,19 +721,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter("PR125405", "inc1"); build("PR125405"); // "only abstract aspects can have type parameters" - checkForError("PR125405", "only abstract aspects can have type parameters"); + checkForError("PR125405", + "only abstract aspects can have type parameters"); alter("PR125405", "inc2"); build("PR125405"); checkCompileWeaveCount("PR125405", 1, 1); - assertTrue("Should be no errors, but got " + getErrorMessages("PR125405"), getErrorMessages("PR125405").size() == 0); + assertTrue("Should be no errors, but got " + + getErrorMessages("PR125405"), getErrorMessages("PR125405") + .size() == 0); } public void testPr128618() { initialiseProject("PR128618_1"); initialiseProject("PR128618_2"); configureNewProjectDependency("PR128618_2", "PR128618_1"); - assertTrue("there should be no warning messages before we start", getWarningMessages("PR128618_1").isEmpty()); - assertTrue("there should be no warning messages before we start", getWarningMessages("PR128618_2").isEmpty()); + assertTrue("there should be no warning messages before we start", + getWarningMessages("PR128618_1").isEmpty()); + assertTrue("there should be no warning messages before we start", + getWarningMessages("PR128618_2").isEmpty()); build("PR128618_1"); build("PR128618_2"); @@ -572,18 +746,21 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // there should be one warning against "PR128618_2" List warnings = getWarningMessages("PR128618_2"); - assertTrue("Should be one warning, but there are #" + warnings.size(), warnings.size() == 1); + assertTrue("Should be one warning, but there are #" + warnings.size(), + warnings.size() == 1); IMessage msg = (IMessage) (getWarningMessages("PR128618_2").get(0)); - assertEquals("warning should be against the FFDC.aj resource", "FFDC.aj", msg.getSourceLocation().getSourceFile().getName()); + assertEquals("warning should be against the FFDC.aj resource", + "FFDC.aj", msg.getSourceLocation().getSourceFile().getName()); alter("PR128618_2", "inc1"); build("PR128618_2"); checkWasntFullBuild(); IMessage msg2 = (IMessage) (getWarningMessages("PR128618_2").get(0)); - assertEquals("warning should be against the FFDC.aj resource", "FFDC.aj", msg2.getSourceLocation().getSourceFile() - .getName()); - assertFalse("a new warning message should have been generated", msg.equals(msg2)); + assertEquals("warning should be against the FFDC.aj resource", + "FFDC.aj", msg2.getSourceLocation().getSourceFile().getName()); + assertFalse("a new warning message should have been generated", msg + .equals(msg2)); } public void testPr92837() { @@ -616,7 +793,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // assertNoErrors("pr119570_3"); // } - // If you fiddle with the compiler options - you must manually reset the options at the end of the test + // If you fiddle with the compiler options - you must manually reset the + // options at the end of the test public void testPr117209() { try { initialiseProject("pr117209"); @@ -629,7 +807,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testPr114875() { - // temporary problem with this on linux, think it is a filesystem lastmodtime issue + // temporary problem with this on linux, think it is a filesystem + // lastmodtime issue if (System.getProperty("os.name", "").toLowerCase().equals("linux")) return; initialiseProject("pr114875"); @@ -699,38 +878,52 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR157054"); checkWasFullBuild(); List weaveMessages = getWeavingMessages("PR157054"); - assertTrue("Should be two weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 2); + assertTrue("Should be two weaving messages but there are " + + weaveMessages.size(), weaveMessages.size() == 2); alter("PR157054", "inc1"); build("PR157054"); weaveMessages = getWeavingMessages("PR157054"); - assertTrue("Should be three weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 3); + assertTrue("Should be three weaving messages but there are " + + weaveMessages.size(), weaveMessages.size() == 3); checkWasntFullBuild(); fullBuild("PR157054"); weaveMessages = getWeavingMessages("PR157054"); - assertTrue("Should be three weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 3); + assertTrue("Should be three weaving messages but there are " + + weaveMessages.size(), weaveMessages.size() == 3); } /** - * Checks we aren't leaking mungers across compiles (accumulating multiple instances of the same one that all do the same - * thing). On the first compile the munger is added late on - so at the time we set the count it is still zero. On the - * subsequent compiles we know about this extra one. + * Checks we aren't leaking mungers across compiles (accumulating multiple + * instances of the same one that all do the same thing). On the first + * compile the munger is added late on - so at the time we set the count it + * is still zero. On the subsequent compiles we know about this extra one. */ public void testPr141956_IncrementallyCompilingAtAj() { initialiseProject("PR141956"); build("PR141956"); - assertTrue("Should be zero but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 0); + assertTrue("Should be zero but reports " + + EclipseFactory.debug_mungerCount, + EclipseFactory.debug_mungerCount == 0); alter("PR141956", "inc1"); build("PR141956"); - assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + assertTrue("Should be two but reports " + + EclipseFactory.debug_mungerCount, + EclipseFactory.debug_mungerCount == 2); alter("PR141956", "inc1"); build("PR141956"); - assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + assertTrue("Should be two but reports " + + EclipseFactory.debug_mungerCount, + EclipseFactory.debug_mungerCount == 2); alter("PR141956", "inc1"); build("PR141956"); - assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + assertTrue("Should be two but reports " + + EclipseFactory.debug_mungerCount, + EclipseFactory.debug_mungerCount == 2); alter("PR141956", "inc1"); build("PR141956"); - assertTrue("Should be two but reports " + EclipseFactory.debug_mungerCount, EclipseFactory.debug_mungerCount == 2); + assertTrue("Should be two but reports " + + EclipseFactory.debug_mungerCount, + EclipseFactory.debug_mungerCount == 2); } // public void testPr124399() { @@ -757,59 +950,73 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } /* - * public void testPr111779() { super.VERBOSE=true; initialiseProject("PR111779"); build("PR111779"); alter("PR111779","inc1"); - * build("PR111779"); } + * public void testPr111779() { super.VERBOSE=true; + * initialiseProject("PR111779"); build("PR111779"); + * alter("PR111779","inc1"); build("PR111779"); } */ public void testPr93310_1() { initialiseProject("PR93310_1"); build("PR93310_1"); checkWasFullBuild(); - String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR93310_1" + File.separatorChar + "src" - + File.separatorChar + "pack" + File.separatorChar + "C2.java"; + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + + "PR93310_1" + File.separatorChar + "src" + File.separatorChar + + "pack" + File.separatorChar + "C2.java"; (new File(fileC2)).delete(); alter("PR93310_1", "inc1"); build("PR93310_1"); checkWasFullBuild(); int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); - assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); - String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); - assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); + assertTrue("Expected one deleted file to be noticed, but detected: " + + l, l == 1); + String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions + .get(0); + assertTrue("Should end with C2.java but is " + name, name + .endsWith("C2.java")); } public void testPr93310_2() { initialiseProject("PR93310_2"); build("PR93310_2"); checkWasFullBuild(); - String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR93310_2" + File.separatorChar + "src" - + File.separatorChar + "pack" + File.separatorChar + "C2.java"; + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + + "PR93310_2" + File.separatorChar + "src" + File.separatorChar + + "pack" + File.separatorChar + "C2.java"; (new File(fileC2)).delete(); alter("PR93310_2", "inc1"); build("PR93310_2"); checkWasFullBuild(); int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); - assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); - String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); - assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); + assertTrue("Expected one deleted file to be noticed, but detected: " + + l, l == 1); + String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions + .get(0); + assertTrue("Should end with C2.java but is " + name, name + .endsWith("C2.java")); } - // Stage1: Compile two files, pack.A and pack.A1 - A1 sets a protected field in A. + // Stage1: Compile two files, pack.A and pack.A1 - A1 sets a protected field + // in A. // Stage2: make the field private in class A > gives compile error // Stage3: Add a new aspect whilst there is a compile error ! public void testPr113531() { initialiseProject("PR113531"); build("PR113531"); - assertTrue("build should have compiled ok", getErrorMessages("PR113531").isEmpty()); + assertTrue("build should have compiled ok", + getErrorMessages("PR113531").isEmpty()); alter("PR113531", "inc1"); build("PR113531"); - assertEquals("error message should be 'foo cannot be resolved' ", "foo cannot be resolved", ((IMessage) getErrorMessages( - "PR113531").get(0)).getMessage()); + assertEquals("error message should be 'foo cannot be resolved' ", + "foo cannot be resolved", ((IMessage) getErrorMessages( + "PR113531").get(0)).getMessage()); alter("PR113531", "inc2"); build("PR113531"); - assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR113531"), getCompilerErrorMessages( - "PR113531").isEmpty()); - assertEquals("error message should be 'foo cannot be resolved' ", "foo cannot be resolved", ((IMessage) getErrorMessages( - "PR113531").get(0)).getMessage()); + assertTrue("There should be no exceptions handled:\n" + + getCompilerErrorMessages("PR113531"), + getCompilerErrorMessages("PR113531").isEmpty()); + assertEquals("error message should be 'foo cannot be resolved' ", + "foo cannot be resolved", ((IMessage) getErrorMessages( + "PR113531").get(0)).getMessage()); } // Stage 1: Compile the 4 files, pack.A2 extends pack.A1 (aspects) where @@ -822,20 +1029,23 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPr119882() { initialiseProject("PR119882"); build("PR119882"); - assertTrue("build should have compiled ok", getErrorMessages("PR119882").isEmpty()); + assertTrue("build should have compiled ok", + getErrorMessages("PR119882").isEmpty()); alter("PR119882", "inc1"); build("PR119882"); // fullBuild("PR119882"); List errors = getErrorMessages("PR119882"); - assertTrue("Should be at least one error, but got none", errors.size() == 1); - assertEquals("error message should be 'i cannot be resolved' ", "i cannot be resolved", ((IMessage) errors.get(0)) - .getMessage()); + assertTrue("Should be at least one error, but got none", + errors.size() == 1); + assertEquals("error message should be 'i cannot be resolved' ", + "i cannot be resolved", ((IMessage) errors.get(0)).getMessage()); alter("PR119882", "inc2"); build("PR119882"); - assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR119882"), getCompilerErrorMessages( - "PR119882").isEmpty()); - assertEquals("error message should be 'i cannot be resolved' ", "i cannot be resolved", ((IMessage) errors.get(0)) - .getMessage()); + assertTrue("There should be no exceptions handled:\n" + + getCompilerErrorMessages("PR119882"), + getCompilerErrorMessages("PR119882").isEmpty()); + assertEquals("error message should be 'i cannot be resolved' ", + "i cannot be resolved", ((IMessage) errors.get(0)).getMessage()); } @@ -843,8 +1053,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject("PR112736"); build("PR112736"); checkWasFullBuild(); - String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR112736" + File.separatorChar + "src" - + File.separatorChar + "pack" + File.separatorChar + "A.java"; + String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + + "PR112736" + File.separatorChar + "src" + File.separatorChar + + "pack" + File.separatorChar + "A.java"; (new File(fileC2)).delete(); alter("PR112736", "inc1"); build("PR112736"); @@ -852,7 +1063,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } /** - * We have problems with multiple rewrites of a pointcut across incremental builds. + * We have problems with multiple rewrites of a pointcut across incremental + * builds. */ public void testPr113257() { initialiseProject("PR113257"); @@ -872,18 +1084,21 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); // back to the source } - // Bugzilla Bug 152257 - Incremental compiler doesn't handle exception declaration correctly + // Bugzilla Bug 152257 - Incremental compiler doesn't handle exception + // declaration correctly public void testPr152257() { initialiseProject("PR152257"); configureNonStandardCompileOptions("PR152257", "-XnoInline"); build("PR152257"); List errors = getErrorMessages("PR152257"); - assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); + assertTrue("Should be no warnings, but there are #" + errors.size(), + errors.size() == 0); checkWasFullBuild(); alter("PR152257", "inc1"); build("PR152257"); errors = getErrorMessages("PR152257"); - assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); + assertTrue("Should be no warnings, but there are #" + errors.size(), + errors.size() == 0); checkWasntFullBuild(); } @@ -893,7 +1108,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureShowWeaveInfoMessages("pr128655", true); build("pr128655"); List firstBuildMessages = getWeavingMessages("pr128655"); - assertTrue("Should be at least one message about the dec @type, but there were none", firstBuildMessages.size() > 0); + assertTrue( + "Should be at least one message about the dec @type, but there were none", + firstBuildMessages.size() > 0); alter("pr128655", "inc1"); build("pr128655"); checkWasntFullBuild(); // back to the source @@ -905,7 +1122,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa if (!m1.toString().equals(m2.toString())) { System.err.println("Message during first build was: " + m1); System.err.println("Message during second build was: " + m1); - fail("The two messages should be the same, but are not: \n" + m1 + "!=" + m2); + fail("The two messages should be the same, but are not: \n" + + m1 + "!=" + m2); } } } @@ -917,7 +1135,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureShowWeaveInfoMessages("pr128655_2", true); build("pr128655_2"); List firstBuildMessages = getWeavingMessages("pr128655_2"); - assertTrue("Should be at least one message about the dec @type, but there were none", firstBuildMessages.size() > 0); + assertTrue( + "Should be at least one message about the dec @type, but there were none", + firstBuildMessages.size() > 0); alter("pr128655_2", "inc1"); build("pr128655_2"); checkWasntFullBuild(); // back to the source @@ -929,7 +1149,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa if (!m1.toString().equals(m2.toString())) { System.err.println("Message during first build was: " + m1); System.err.println("Message during second build was: " + m1); - fail("The two messages should be the same, but are not: \n" + m1 + "!=" + m2); + fail("The two messages should be the same, but are not: \n" + + m1 + "!=" + m2); } } } @@ -940,17 +1161,20 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR129613"); alter("PR129613", "inc1"); build("PR129613"); - assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR129613"), getCompilerErrorMessages( - "PR129613").isEmpty()); - assertEquals("warning message should be 'no match for this type name: File [Xlint:invalidAbsoluteTypeName]' ", - "no match for this type name: File [Xlint:invalidAbsoluteTypeName]", ((IMessage) getWarningMessages("PR129613") - .get(0)).getMessage()); + assertTrue("There should be no exceptions handled:\n" + + getCompilerErrorMessages("PR129613"), + getCompilerErrorMessages("PR129613").isEmpty()); + assertEquals( + "warning message should be 'no match for this type name: File [Xlint:invalidAbsoluteTypeName]' ", + "no match for this type name: File [Xlint:invalidAbsoluteTypeName]", + ((IMessage) getWarningMessages("PR129613").get(0)).getMessage()); } // test for comment #0 - adding a comment to a class file shouldn't // cause us to go back to source and recompile everything. To force this // to behave like AJDT we need to include the aspect in 'inc1' so that - // when AjState looks at its timestamp it thinks the aspect has been modified. + // when AjState looks at its timestamp it thinks the aspect has been + // modified. // The logic within CrosscuttingMembers should then work out correctly // that there haven't really been any changes within the aspect and so // we shouldn't go back to source. @@ -985,7 +1209,10 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter("Project1", "inc3"); // structural change to ClassA build("Project1"); - setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See pr245566 comment 3 + setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See + // pr245566 + // comment + // 3 build("Project2"); checkWasntFullBuild(); // Just need to recompile ClassAExtender checkCompileWeaveCount("Project2", 1, 1); @@ -998,9 +1225,13 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter("Project1", "inc4"); // another structural change to ClassA build("Project1"); - setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See pr245566 comment 3 + setNextChangeResponse("Project2", ICompilerConfiguration.EVERYTHING); // See + // pr245566 + // comment + // 3 build("Project2"); - checkWasntFullBuild(); // Should rebuild ClassAExtender and ClassAExtenderExtender + checkWasntFullBuild(); // Should rebuild ClassAExtender and + // ClassAExtenderExtender checkCompileWeaveCount("Project2", 2, 2); checkCompiled("Project2", "ClassAExtenderExtender"); @@ -1014,44 +1245,60 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa if (object.indexOf(typeNameSubstring) != -1) found = true; } - assertTrue("Did not find '" + typeNameSubstring + "' in list of compiled files", found); + assertTrue("Did not find '" + typeNameSubstring + + "' in list of compiled files", found); } // Case001: renaming a private field in a type /* - * public void testPrReducingDependentBuilds_001_221427() { AjdeInteractionTestbed.VERBOSE=true; - * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_1"); initialiseProject("P221427_2"); + * public void testPrReducingDependentBuilds_001_221427() { + * AjdeInteractionTestbed.VERBOSE=true; + * IncrementalStateManager.debugIncrementalStates=true; + * initialiseProject("P221427_1"); initialiseProject("P221427_2"); * configureNewProjectDependency("P221427_2","P221427_1"); * - * build("P221427_1"); build("P221427_2"); alter("P221427_1","inc1"); // rename private class in super project - * MyStateListener.reset(); build("P221427_1"); build("P221427_2"); + * build("P221427_1"); build("P221427_2"); alter("P221427_1","inc1"); // + * rename private class in super project MyStateListener.reset(); + * build("P221427_1"); build("P221427_2"); * - * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_1","bin"))); + * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new + * File(getFile("P221427_1","bin"))); * assertTrue("There should be state for project P221427_1",ajs!=null); - * //System.out.println(MyStateListener.getInstance().getDecisions()); checkWasntFullBuild(); - * assertTrue("Should be one structural change but there were "+ ajs.getNumberOfStructuralChangesSinceLastFullBuild(), + * //System.out.println(MyStateListener.getInstance().getDecisions()); + * checkWasntFullBuild(); + * assertTrue("Should be one structural change but there were "+ + * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), * ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); * * } * - * // Case002: changing a class to final that is extended in a dependent project public void - * testPrReducingDependentBuilds_002_221427() { AjdeInteractionTestbed.VERBOSE=true; - * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_3"); initialiseProject("P221427_4"); + * // Case002: changing a class to final that is extended in a dependent + * project public void testPrReducingDependentBuilds_002_221427() { + * AjdeInteractionTestbed.VERBOSE=true; + * IncrementalStateManager.debugIncrementalStates=true; + * initialiseProject("P221427_3"); initialiseProject("P221427_4"); * configureNewProjectDependency("P221427_4","P221427_3"); * - * build("P221427_3"); build("P221427_4"); // build OK, type in super project is non-final alter("P221427_3","inc1"); // change - * class declaration in super-project to final MyStateListener.reset(); build("P221427_3"); build("P221427_4"); // build FAIL, - * type in super project is now final + * build("P221427_3"); build("P221427_4"); // build OK, type in super + * project is non-final alter("P221427_3","inc1"); // change class + * declaration in super-project to final MyStateListener.reset(); + * build("P221427_3"); build("P221427_4"); // build FAIL, type in super + * project is now final * - * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_3","bin"))); + * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new + * File(getFile("P221427_3","bin"))); * assertTrue("There should be state for project P221427_3",ajs!=null); * System.out.println(MyStateListener.getInstance().getDecisions()); * - * List errors = getErrorMessages("P221427_4"); if (errors.size()!=1) { if (errors.size()==0) - * fail("Expected error about not being able to extend final class"); for (Iterator iterator = errors.iterator(); - * iterator.hasNext();) { Object object = (Object) iterator.next(); System.out.println(object); } - * fail("Expected 1 error but got "+errors.size()); } // assertTrue("Shouldn't be one structural change but there were "+ // - * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), // ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); + * List errors = getErrorMessages("P221427_4"); if (errors.size()!=1) { if + * (errors.size()==0) + * fail("Expected error about not being able to extend final class"); for + * (Iterator iterator = errors.iterator(); iterator.hasNext();) { Object + * object = (Object) iterator.next(); System.out.println(object); } + * fail("Expected 1 error but got "+errors.size()); } // + * assertTrue("Shouldn't be one structural change but there were "+ // + * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), // + * ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); * * } */ @@ -1068,19 +1315,23 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPr129163_3() { initialiseProject("PR129163_4"); build("PR129163_4"); - checkWasFullBuild(); // should be a full build because initializing project + checkWasFullBuild(); // should be a full build because initializing + // project initialiseProject("PR129163_3"); configureNewProjectDependency("PR129163_3", "PR129163_4"); build("PR129163_3"); - checkWasFullBuild(); // should be a full build because initializing project + checkWasFullBuild(); // should be a full build because initializing + // project alter("PR129163_4", "inc1"); build("PR129163_4"); - checkWasntFullBuild(); // should be an incremental build because although + checkWasntFullBuild(); // should be an incremental build because + // although // "inc1" includes the aspect A1.aj, it actually hasn't // changed so we shouldn't go back to source alter("PR129163_3", "inc1"); build("PR129163_3"); - checkWasntFullBuild(); // should be an incremental build because nothing has + checkWasntFullBuild(); // should be an incremental build because nothing + // has // changed within the class and no aspects have changed // within the running of the test } @@ -1091,7 +1342,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject("PR133117"); configureNonStandardCompileOptions("PR133117", "-Xlint:warning"); build("PR133117"); - assertTrue("There should only be one xlint warning message reported:\n" + getWarningMessages("PR133117"), + assertTrue("There should only be one xlint warning message reported:\n" + + getWarningMessages("PR133117"), getWarningMessages("PR133117").size() == 1); alter("PR133117", "inc1"); build("PR133117"); @@ -1103,8 +1355,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa noGuardWarnings.add(element); } } - assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings, - noGuardWarnings.size() == 2); + assertTrue( + "There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + + noGuardWarnings, noGuardWarnings.size() == 2); } public void testPr131505() { @@ -1112,7 +1365,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureNonStandardCompileOptions("PR131505", "-outxml"); build("PR131505"); checkWasFullBuild(); - String outputDir = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR131505" + File.separatorChar + "bin"; + String outputDir = getWorkingDir().getAbsolutePath() + + File.separatorChar + "PR131505" + File.separatorChar + "bin"; // aop.xml file shouldn't contain any aspects checkXMLAspectCount("PR131505", "", 0, outputDir); // add a new aspect A which should be included in the aop.xml file @@ -1128,7 +1382,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasntFullBuild(); checkXMLAspectCount("PR131505", "", 1, outputDir); checkXMLAspectCount("PR131505", "A", 1, outputDir); - // add another new aspect A1 which should also be included in the aop.xml file + // add another new aspect A1 which should also be included in the + // aop.xml file // ...there should be no duplicate entries in the file alter("PR131505", "inc3"); build("PR131505"); @@ -1137,7 +1392,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkXMLAspectCount("PR131505", "A1", 1, outputDir); checkXMLAspectCount("PR131505", "A", 1, outputDir); // delete aspect A1 which meanss that aop.xml file should only contain A - File a1 = new File(getWorkingDir().getAbsolutePath() + File.separatorChar + "PR131505" + File.separatorChar + "A1.aj"); + File a1 = new File(getWorkingDir().getAbsolutePath() + + File.separatorChar + "PR131505" + File.separatorChar + + "A1.aj"); a1.delete(); build("PR131505"); checkWasFullBuild(); @@ -1159,7 +1416,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR136585"); alter("PR136585", "inc1"); build("PR136585"); - assertTrue("There should be no errors reported:\n" + getErrorMessages("PR136585"), getErrorMessages("PR136585").isEmpty()); + assertTrue("There should be no errors reported:\n" + + getErrorMessages("PR136585"), getErrorMessages("PR136585") + .isEmpty()); } public void testPr133532() { @@ -1169,7 +1428,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR133532"); alter("PR133532", "inc2"); build("PR133532"); - assertTrue("There should be no errors reported:\n" + getErrorMessages("PR133532"), getErrorMessages("PR133532").isEmpty()); + assertTrue("There should be no errors reported:\n" + + getErrorMessages("PR133532"), getErrorMessages("PR133532") + .isEmpty()); } public void testPr133532_2() { @@ -1177,11 +1438,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("pr133532_2"); alter("pr133532_2", "inc2"); build("pr133532_2"); - assertTrue("There should be no errors reported:\n" + getErrorMessages("pr133532_2"), getErrorMessages("pr133532_2") - .isEmpty()); - String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions(); + assertTrue("There should be no errors reported:\n" + + getErrorMessages("pr133532_2"), + getErrorMessages("pr133532_2").isEmpty()); + String decisions = AjdeInteractionTestbed.MyStateListener + .getDecisions(); String expect = "Need to recompile 'A.aj'"; - assertTrue("Couldn't find build decision: '" + expect + "' in the list of decisions made:\n" + decisions, decisions + assertTrue("Couldn't find build decision: '" + expect + + "' in the list of decisions made:\n" + decisions, decisions .indexOf(expect) != -1); } @@ -1190,27 +1454,35 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR133532_3"); alter("PR133532_3", "inc1"); build("PR133532_3"); - assertTrue("There should be no errors reported:\n" + getErrorMessages("PR133532_3"), getErrorMessages("PR133532_3") - .isEmpty()); + assertTrue("There should be no errors reported:\n" + + getErrorMessages("PR133532_3"), + getErrorMessages("PR133532_3").isEmpty()); } public void testPr134541() { initialiseProject("PR134541"); build("PR134541"); - assertEquals("[Xlint:adviceDidNotMatch] should be associated with line 5", 5, ((IMessage) getWarningMessages("PR134541") - .get(0)).getSourceLocation().getLine()); + assertEquals( + "[Xlint:adviceDidNotMatch] should be associated with line 5", + 5, ((IMessage) getWarningMessages("PR134541").get(0)) + .getSourceLocation().getLine()); alter("PR134541", "inc1"); build("PR134541"); if (AsmManager.getDefault().getHandleProvider().dependsOnLocation()) - checkWasFullBuild(); // the line number has changed... but nothing structural about the code + checkWasFullBuild(); // the line number has changed... but nothing + // structural about the code else - checkWasntFullBuild(); // the line number has changed... but nothing structural about the code - assertEquals("[Xlint:adviceDidNotMatch] should now be associated with line 7", 7, - ((IMessage) getWarningMessages("PR134541").get(0)).getSourceLocation().getLine()); + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code + assertEquals( + "[Xlint:adviceDidNotMatch] should now be associated with line 7", + 7, ((IMessage) getWarningMessages("PR134541").get(0)) + .getSourceLocation().getLine()); } public void testJDTLikeHandleProviderWithLstFile_pr141730() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + IElementHandleProvider handleProvider = AsmManager.getDefault() + .getHandleProvider(); AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); try { // The JDTLike-handles should start with the name @@ -1219,50 +1491,61 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("JDTLikeHandleProvider"); IHierarchy top = AsmManager.getDefault().getHierarchy(); IProgramElement pe = top.findElementForType("pkg", "A"); - String expectedHandle = "JDTLikeHandleProvider<pkg*A.aj}A"; - assertEquals("expected handle to be " + expectedHandle + ", but found " + pe.getHandleIdentifier(), expectedHandle, pe - .getHandleIdentifier()); + String expectedHandle = "=JDTLikeHandleProvider<pkg*A.aj}A"; + assertEquals("expected handle to be " + expectedHandle + + ", but found " + pe.getHandleIdentifier(), + expectedHandle, pe.getHandleIdentifier()); } finally { AsmManager.getDefault().setHandleProvider(handleProvider); } } public void testMovingAdviceDoesntChangeHandles_pr141730() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + IElementHandleProvider handleProvider = AsmManager.getDefault() + .getHandleProvider(); AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); try { initialiseProject("JDTLikeHandleProvider"); build("JDTLikeHandleProvider"); checkWasFullBuild(); IHierarchy top = AsmManager.getDefault().getHierarchy(); - IProgramElement pe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, + IProgramElement pe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.ADVICE, "before(): <anonymous pointcut>"); // add a line which shouldn't change the handle alter("JDTLikeHandleProvider", "inc1"); build("JDTLikeHandleProvider"); checkWasntFullBuild(); IHierarchy top2 = AsmManager.getDefault().getHierarchy(); - IProgramElement pe2 = top.findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, + IProgramElement pe2 = top.findElementForLabel(top2.getRoot(), + IProgramElement.Kind.ADVICE, "before(): <anonymous pointcut>"); - assertEquals("expected advice to be on line " + pe.getSourceLocation().getLine() + 1 + " but was on " - + pe2.getSourceLocation().getLine(), pe.getSourceLocation().getLine() + 1, pe2.getSourceLocation().getLine()); - assertEquals("expected advice to have handle " + pe.getHandleIdentifier() + " but found handle " - + pe2.getHandleIdentifier(), pe.getHandleIdentifier(), pe2.getHandleIdentifier()); + assertEquals("expected advice to be on line " + + pe.getSourceLocation().getLine() + 1 + " but was on " + + pe2.getSourceLocation().getLine(), pe.getSourceLocation() + .getLine() + 1, pe2.getSourceLocation().getLine()); + assertEquals("expected advice to have handle " + + pe.getHandleIdentifier() + " but found handle " + + pe2.getHandleIdentifier(), pe.getHandleIdentifier(), pe2 + .getHandleIdentifier()); } finally { AsmManager.getDefault().setHandleProvider(handleProvider); } } public void testSwappingAdviceAndHandles_pr141730() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + IElementHandleProvider handleProvider = AsmManager.getDefault() + .getHandleProvider(); AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); try { initialiseProject("JDTLikeHandleProvider"); build("JDTLikeHandleProvider"); IHierarchy top = AsmManager.getDefault().getHierarchy(); - IProgramElement call = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "after(): callPCD.."); - IProgramElement exec = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "after(): execPCD.."); + IProgramElement call = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.ADVICE, "after(): callPCD.."); + IProgramElement exec = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.ADVICE, "after(): execPCD.."); // swap the two after advice statements over. This forces // a full build which means 'after(): callPCD..' will now // be the second after advice in the file and have the same @@ -1272,55 +1555,73 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); IHierarchy top2 = AsmManager.getDefault().getHierarchy(); - IProgramElement newCall = top2.findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, "after(): callPCD.."); - IProgramElement newExec = top2.findElementForLabel(top2.getRoot(), IProgramElement.Kind.ADVICE, "after(): execPCD.."); - - assertEquals("after swapping places, expected 'after(): callPCD..' " + "to be on line " - + newExec.getSourceLocation().getLine() + " but was on line " + call.getSourceLocation().getLine(), newExec - .getSourceLocation().getLine(), call.getSourceLocation().getLine()); - assertEquals("after swapping places, expected 'after(): callPCD..' " + "to have handle " + exec.getHandleIdentifier() - + " (because was full build) but had " + newCall.getHandleIdentifier(), exec.getHandleIdentifier(), newCall - .getHandleIdentifier()); + IProgramElement newCall = top2.findElementForLabel(top2.getRoot(), + IProgramElement.Kind.ADVICE, "after(): callPCD.."); + IProgramElement newExec = top2.findElementForLabel(top2.getRoot(), + IProgramElement.Kind.ADVICE, "after(): execPCD.."); + + assertEquals( + "after swapping places, expected 'after(): callPCD..' " + + "to be on line " + + newExec.getSourceLocation().getLine() + + " but was on line " + + call.getSourceLocation().getLine(), newExec + .getSourceLocation().getLine(), call + .getSourceLocation().getLine()); + assertEquals( + "after swapping places, expected 'after(): callPCD..' " + + "to have handle " + exec.getHandleIdentifier() + + " (because was full build) but had " + + newCall.getHandleIdentifier(), exec + .getHandleIdentifier(), newCall + .getHandleIdentifier()); } finally { AsmManager.getDefault().setHandleProvider(handleProvider); } } public void testInitializerCountForJDTLikeHandleProvider_pr141730() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + IElementHandleProvider handleProvider = AsmManager.getDefault() + .getHandleProvider(); AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); try { initialiseProject("JDTLikeHandleProvider"); build("JDTLikeHandleProvider"); - String expected = "JDTLikeHandleProvider<pkg*A.aj[C|1"; + String expected = "=JDTLikeHandleProvider<pkg*A.aj[C|1"; IHierarchy top = AsmManager.getDefault().getHierarchy(); - IProgramElement init = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.INITIALIZER, "..."); - assertEquals("expected initializers handle to be " + expected + "," + " but found " + init.getHandleIdentifier(true), - expected, init.getHandleIdentifier(true)); + IProgramElement init = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.INITIALIZER, "..."); + assertEquals("expected initializers handle to be " + expected + "," + + " but found " + init.getHandleIdentifier(true), expected, + init.getHandleIdentifier(true)); alter("JDTLikeHandleProvider", "inc2"); build("JDTLikeHandleProvider"); checkWasFullBuild(); IHierarchy top2 = AsmManager.getDefault().getHierarchy(); - IProgramElement init2 = top2.findElementForLabel(top2.getRoot(), IProgramElement.Kind.INITIALIZER, "..."); - assertEquals("expected initializers handle to still be " + expected + "," + " but found " - + init2.getHandleIdentifier(true), expected, init2.getHandleIdentifier(true)); + IProgramElement init2 = top2.findElementForLabel(top2.getRoot(), + IProgramElement.Kind.INITIALIZER, "..."); + assertEquals("expected initializers handle to still be " + expected + + "," + " but found " + init2.getHandleIdentifier(true), + expected, init2.getHandleIdentifier(true)); } finally { AsmManager.getDefault().setHandleProvider(handleProvider); } } - // 134471 related tests perform incremental compilation and verify features of the structure model post compile + // 134471 related tests perform incremental compilation and verify features + // of the structure model post compile public void testPr134471_IncrementalCompilationAndModelUpdates() { try { // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; // Step1. Build the code, simple advice from aspect A onto class C initialiseProject("PR134471"); - configureNonStandardCompileOptions("PR134471", "-showWeaveInfo -emacssym"); + configureNonStandardCompileOptions("PR134471", + "-showWeaveInfo -emacssym"); configureShowWeaveInfoMessages("PR134471", true); build("PR134471"); @@ -1329,12 +1630,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa IProgramElement nodeForAdvice = findAdvice(nodeForTypeA); List relatedElements = getRelatedElements(nodeForAdvice, 1); - // Step3. Check the advice applying at the first 'code' join point in pkg.C is from aspect pkg.A, line 7 - IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + // Step3. Check the advice applying at the first 'code' join point + // in pkg.C is from aspect pkg.A, line 7 + IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode( + "pkg", "C", true))); int line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); - // Step4. Simulate the aspect being saved but with no change at all in it + // Step4. Simulate the aspect being saved but with no change at all + // in it alter("PR134471", "inc1"); build("PR134471"); @@ -1343,44 +1648,57 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa nodeForAdvice = findAdvice(nodeForTypeA); relatedElements = getRelatedElements(nodeForAdvice, 1); - // Step6. Check the advice applying at the first 'code' join point in pkg.C is from aspect pkg.A, line 7 - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + // Step6. Check the advice applying at the first 'code' join point + // in pkg.C is from aspect pkg.A, line 7 + programElement = getFirstRelatedElement(findCode(checkForNode( + "pkg", "C", true))); line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); } finally { // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true; } } - // now the advice moves down a few lines - hopefully the model will notice... see discussion in 134471 + // now the advice moves down a few lines - hopefully the model will + // notice... see discussion in 134471 public void testPr134471_MovingAdvice() { // Step1. build the project initialiseProject("PR134471_2"); - configureNonStandardCompileOptions("PR134471_2", "-showWeaveInfo -emacssym"); + configureNonStandardCompileOptions("PR134471_2", + "-showWeaveInfo -emacssym"); configureShowWeaveInfoMessages("PR134471_2", true); build("PR134471_2"); // Step2. confirm advice is from correct location - IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode( + "pkg", "C", true))); int line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); - // Step3. No structural change to the aspect but the advice has moved down a few lines... (change in source location) + // Step3. No structural change to the aspect but the advice has moved + // down a few lines... (change in source location) alter("PR134471_2", "inc1"); build("PR134471_2"); if (AsmManager.getDefault().getHandleProvider().dependsOnLocation()) - checkWasFullBuild(); // the line number has changed... but nothing structural about the code + checkWasFullBuild(); // the line number has changed... but nothing + // structural about the code else - checkWasntFullBuild(); // the line number has changed... but nothing structural about the code + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code - // checkWasFullBuild(); // this is true whilst we consider sourcelocation in the type/shadow munger equals() method - have + // checkWasFullBuild(); // this is true whilst we consider + // sourcelocation in the type/shadow munger equals() method - have // to until the handles are independent of location // Step4. Check we have correctly realised the advice moved to line 11 - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true))); line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 11 - but is at line " + line, line == 11); + assertTrue("advice should be at line 11 - but is at line " + line, + line == 11); } public void testAddingAndRemovingDecwWithStructureModel() { @@ -1388,28 +1706,34 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("P3"); alter("P3", "inc1"); build("P3"); - assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("P3"), getCompilerErrorMessages("P3") - .isEmpty()); + assertTrue("There should be no exceptions handled:\n" + + getCompilerErrorMessages("P3"), + getCompilerErrorMessages("P3").isEmpty()); alter("P3", "inc2"); build("P3"); - assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("P3"), getCompilerErrorMessages("P3") - .isEmpty()); + assertTrue("There should be no exceptions handled:\n" + + getCompilerErrorMessages("P3"), + getCompilerErrorMessages("P3").isEmpty()); } - // same as first test with an extra stage that asks for C to be recompiled, it should still be advised... + // same as first test with an extra stage that asks for C to be recompiled, + // it should still be advised... public void testPr134471_IncrementallyRecompilingTheAffectedClass() { try { // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; // Step1. build the project initialiseProject("PR134471"); - configureNonStandardCompileOptions("PR134471", "-showWeaveInfo -emacssym"); + configureNonStandardCompileOptions("PR134471", + "-showWeaveInfo -emacssym"); configureShowWeaveInfoMessages("PR134471", true); build("PR134471"); // Step2. confirm advice is from correct location - IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode( + "pkg", "C", true))); int line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); // Step3. No change to the aspect at all alter("PR134471", "inc1"); @@ -1420,15 +1744,18 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa IProgramElement nodeForAdvice = findAdvice(nodeForTypeA); List relatedElements = getRelatedElements(nodeForAdvice, 1); - // Step5. No change to the file C but it should still be advised afterwards + // Step5. No change to the file C but it should still be advised + // afterwards alter("PR134471", "inc2"); build("PR134471"); checkWasntFullBuild(); // Step6. confirm advice is from correct location - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true))); + programElement = getFirstRelatedElement(findCode(checkForNode( + "pkg", "C", true))); line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); } finally { // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true; } @@ -1440,45 +1767,60 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // Step1. build the project initialiseProject("PR134471_3"); - configureNonStandardCompileOptions("PR134471_3", "-showWeaveInfo -emacssym"); + configureNonStandardCompileOptions("PR134471_3", + "-showWeaveInfo -emacssym"); configureShowWeaveInfoMessages("PR134471_3", true); build("PR134471_3"); checkWasFullBuild(); - // Step2. confirm declare warning is from correct location, decw matches line 7 in pkg.C - IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step2. confirm declare warning is from correct location, decw matches + // line 7 in pkg.C + IProgramElement programElement = getFirstRelatedElement(findCode( + checkForNode("pkg", "C", true), 7)); int line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 10 - but is at line " + line, line == 10); + assertTrue("declare warning should be at line 10 - but is at line " + + line, line == 10); - // Step3. confirm advice is from correct location, advice matches line 6 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 6)); + // Step3. confirm advice is from correct location, advice matches line 6 + // in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 6)); line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); // Step4. Move declare warning in the aspect alter("PR134471_3", "inc1"); build("PR134471_3"); if (AsmManager.getDefault().getHandleProvider().dependsOnLocation()) - checkWasFullBuild(); // the line number has changed... but nothing structural about the code + checkWasFullBuild(); // the line number has changed... but nothing + // structural about the code else - checkWasntFullBuild(); // the line number has changed... but nothing structural about the code + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code // checkWasFullBuild(); - // Step5. confirm declare warning is from correct location, decw (now at line 12) in pkg.A matches line 7 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step5. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 7)); line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + assertTrue("declare warning should be at line 12 - but is at line " + + line, line == 12); // Step6. Now just simulate 'resave' of the aspect, nothing has changed alter("PR134471_3", "inc2"); build("PR134471_3"); checkWasntFullBuild(); - // Step7. confirm declare warning is from correct location, decw (now at line 12) in pkg.A matches line 7 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step7. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 7)); line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + assertTrue("declare warning should be at line 12 - but is at line " + + line, line == 12); } // similar to previous test but with 'declare warning' as well as advice @@ -1486,55 +1828,74 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // Step1. build the project initialiseProject("PR134471_3"); - configureNonStandardCompileOptions("PR134471_3", "-showWeaveInfo -emacssym"); + configureNonStandardCompileOptions("PR134471_3", + "-showWeaveInfo -emacssym"); configureShowWeaveInfoMessages("PR134471_3", true); build("PR134471_3"); checkWasFullBuild(); - // Step2. confirm declare warning is from correct location, decw matches line 7 in pkg.C - IProgramElement programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step2. confirm declare warning is from correct location, decw matches + // line 7 in pkg.C + IProgramElement programElement = getFirstRelatedElement(findCode( + checkForNode("pkg", "C", true), 7)); int line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 10 - but is at line " + line, line == 10); + assertTrue("declare warning should be at line 10 - but is at line " + + line, line == 10); - // Step3. confirm advice is from correct location, advice matches line 6 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 6)); + // Step3. confirm advice is from correct location, advice matches line 6 + // in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 6)); line = programElement.getSourceLocation().getLine(); - assertTrue("advice should be at line 7 - but is at line " + line, line == 7); + assertTrue("advice should be at line 7 - but is at line " + line, + line == 7); // Step4. Move declare warning in the aspect alter("PR134471_3", "inc1"); build("PR134471_3"); if (AsmManager.getDefault().getHandleProvider().dependsOnLocation()) - checkWasFullBuild(); // the line number has changed... but nothing structural about the code + checkWasFullBuild(); // the line number has changed... but nothing + // structural about the code else - checkWasntFullBuild(); // the line number has changed... but nothing structural about the code + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code // checkWasFullBuild(); - // Step5. confirm declare warning is from correct location, decw (now at line 12) in pkg.A matches line 7 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step5. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 7)); line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + assertTrue("declare warning should be at line 12 - but is at line " + + line, line == 12); // Step6. Now just simulate 'resave' of the aspect, nothing has changed alter("PR134471_3", "inc2"); build("PR134471_3"); checkWasntFullBuild(); - // Step7. confirm declare warning is from correct location, decw (now at line 12) in pkg.A matches line 7 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step7. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 7)); line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + assertTrue("declare warning should be at line 12 - but is at line " + + line, line == 12); - // Step8. Now just simulate resave of the pkg.C type - no change at all... are relationships gonna be repaired OK? + // Step8. Now just simulate resave of the pkg.C type - no change at + // all... are relationships gonna be repaired OK? alter("PR134471_3", "inc3"); build("PR134471_3"); checkWasntFullBuild(); - // Step9. confirm declare warning is from correct location, decw (now at line 12) in pkg.A matches line 7 in pkg.C - programElement = getFirstRelatedElement(findCode(checkForNode("pkg", "C", true), 7)); + // Step9. confirm declare warning is from correct location, decw (now at + // line 12) in pkg.A matches line 7 in pkg.C + programElement = getFirstRelatedElement(findCode(checkForNode("pkg", + "C", true), 7)); line = programElement.getSourceLocation().getLine(); - assertTrue("declare warning should be at line 12 - but is at line " + line, line == 12); + assertTrue("declare warning should be at line 12 - but is at line " + + line, line == 12); } public void testDontLoseXlintWarnings_pr141556() { @@ -1542,10 +1903,12 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureNonStandardCompileOptions("PR141556", "-Xlint:warning"); build("PR141556"); checkWasFullBuild(); - String warningMessage = "can not build thisJoinPoint " + "lazily for this advice since it has no suitable guard " + String warningMessage = "can not build thisJoinPoint " + + "lazily for this advice since it has no suitable guard " + "[Xlint:noGuardForLazyTjp]"; - assertEquals("warning message should be '" + warningMessage + "'", warningMessage, ((IMessage) getWarningMessages( - "PR141556").get(0)).getMessage()); + assertEquals("warning message should be '" + warningMessage + "'", + warningMessage, ((IMessage) getWarningMessages("PR141556").get( + 0)).getMessage()); // add a space to the Aspect but dont do a build alter("PR141556", "inc1"); @@ -1554,26 +1917,32 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // build the project and we should not have lost the xlint warning build("PR141556"); checkWasntFullBuild(); - assertTrue("there should still be a warning message ", !getWarningMessages("PR141556").isEmpty()); - assertEquals("warning message should be '" + warningMessage + "'", warningMessage, ((IMessage) getWarningMessages( - "PR141556").get(0)).getMessage()); + assertTrue("there should still be a warning message ", + !getWarningMessages("PR141556").isEmpty()); + assertEquals("warning message should be '" + warningMessage + "'", + warningMessage, ((IMessage) getWarningMessages("PR141556").get( + 0)).getMessage()); } public void testAdviceDidNotMatch_pr152589() { initialiseProject("PR152589"); build("PR152589"); List warnings = getWarningMessages("PR152589"); - assertTrue("There should be no warnings:\n" + warnings, warnings.isEmpty()); + assertTrue("There should be no warnings:\n" + warnings, warnings + .isEmpty()); alter("PR152589", "inc1"); build("PR152589"); if (AsmManager.getDefault().getHandleProvider().dependsOnLocation()) - checkWasFullBuild(); // the line number has changed... but nothing structural about the code + checkWasFullBuild(); // the line number has changed... but nothing + // structural about the code else - checkWasntFullBuild(); // the line number has changed... but nothing structural about the code + checkWasntFullBuild(); // the line number has changed... but nothing + // structural about the code // checkWasFullBuild(); warnings = getWarningMessages("PR152589"); - assertTrue("There should be no warnings after adding a whitespace:\n" + warnings, warnings.isEmpty()); + assertTrue("There should be no warnings after adding a whitespace:\n" + + warnings, warnings.isEmpty()); } // see comment #11 of bug 154054 @@ -1595,31 +1964,36 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testPR158573() { - IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + IElementHandleProvider handleProvider = AsmManager.getDefault() + .getHandleProvider(); AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); initialiseProject("PR158573"); build("PR158573"); List warnings = getWarningMessages("PR158573"); - assertTrue("There should be no warnings:\n" + warnings, warnings.isEmpty()); + assertTrue("There should be no warnings:\n" + warnings, warnings + .isEmpty()); alter("PR158573", "inc1"); build("PR158573"); checkWasntFullBuild(); warnings = getWarningMessages("PR158573"); - assertTrue("There should be no warnings after changing the value of a " + "variable:\n" + warnings, warnings.isEmpty()); + assertTrue("There should be no warnings after changing the value of a " + + "variable:\n" + warnings, warnings.isEmpty()); AsmManager.getDefault().setHandleProvider(handleProvider); } /** - * If the user has specified that they want Java 6 compliance and kept the default classfile and source file level settings - * (also 6.0) then expect an error saying that we don't support java 6. + * If the user has specified that they want Java 6 compliance and kept the + * default classfile and source file level settings (also 6.0) then expect + * an error saying that we don't support java 6. */ public void testPR164384_1() { initialiseProject("PR164384"); Hashtable javaOptions = new Hashtable(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); - javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", + "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); configureJavaOptionsMap("PR164384", javaOptions); @@ -1627,59 +2001,71 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List errors = getErrorMessages("PR164384"); if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { - assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); + assertTrue("There should be no errors:\n" + errors, errors + .isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; String found = ((IMessage) errors.get(0)).getMessage(); - assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, - expectedError, found); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' - // rather than an 'abort'. Aborts are really for compiler exceptions. - assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue( + "expected there to be more than the one compliance level" + + " error but only found that one", errors.size() > 1); } } /** - * If the user has specified that they want Java 6 compliance and selected classfile and source file level settings to be 5.0 - * then expect an error saying that we don't support java 6. + * If the user has specified that they want Java 6 compliance and selected + * classfile and source file level settings to be 5.0 then expect an error + * saying that we don't support java 6. */ public void testPR164384_2() { initialiseProject("PR164384"); Hashtable javaOptions = new Hashtable(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); - javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", + "1.5"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); configureJavaOptionsMap("PR164384", javaOptions); build("PR164384"); List errors = getErrorMessages("PR164384"); if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { - assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); + assertTrue("There should be no errors:\n" + errors, errors + .isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; String found = ((IMessage) errors.get(0)).getMessage(); - assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, - expectedError, found); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' - // rather than an 'abort'. Aborts are really for compiler exceptions. - assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue( + "expected there to be more than the one compliance level" + + " error but only found that one", errors.size() > 1); } } /** - * If the user has specified that they want Java 6 compliance and set the classfile level to be 6.0 and source file level to be - * 5.0 then expect an error saying that we don't support java 6. + * If the user has specified that they want Java 6 compliance and set the + * classfile level to be 6.0 and source file level to be 5.0 then expect an + * error saying that we don't support java 6. */ public void testPR164384_3() { initialiseProject("PR164384"); Hashtable javaOptions = new Hashtable(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); - javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); + javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", + "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); configureJavaOptionsMap("PR164384", javaOptions); @@ -1687,15 +2073,19 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List errors = getErrorMessages("PR164384"); if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { - assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); + assertTrue("There should be no errros:\n" + errors, errors + .isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; String found = ((IMessage) errors.get(0)).getMessage(); - assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, - expectedError, found); + assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' - // rather than an 'abort'. Aborts are really for compiler exceptions. - assertTrue("expected there to be more than the one compliance level" + " error but only found that one", + // rather than an 'abort'. Aborts are really for compiler + // exceptions. + assertTrue( + "expected there to be more than the one compliance level" + + " error but only found that one", errors.size() > 1); } } @@ -1703,8 +2093,10 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPr168840() throws Exception { initialiseProject("inpathTesting"); - String inpathTestingDir = getWorkingDir() + File.separator + "inpathTesting"; - String inpathDir = inpathTestingDir + File.separator + "injarBin" + File.separator + "pkg"; + String inpathTestingDir = getWorkingDir() + File.separator + + "inpathTesting"; + String inpathDir = inpathTestingDir + File.separator + "injarBin" + + File.separator + "pkg"; String expectedOutputDir = inpathTestingDir + File.separator + "bin"; // set up the inpath to have the directory on it's path @@ -1715,49 +2107,64 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("inpathTesting"); // the declare warning matches one place so expect one warning message List warnings = getWarningMessages("inpathTesting"); - assertTrue("Expected there to be one warning message but found " + warnings.size() + ": " + warnings, warnings.size() == 1); + assertTrue("Expected there to be one warning message but found " + + warnings.size() + ": " + warnings, warnings.size() == 1); // copy over the updated version of the inpath class file - File from = new File(testdataSrcDir + File.separatorChar + "inpathTesting" + File.separatorChar + "newInpathClass" + File from = new File(testdataSrcDir + File.separatorChar + + "inpathTesting" + File.separatorChar + "newInpathClass" + File.separatorChar + "InpathClass.class"); - File destination = new File(inpathDir + File.separatorChar + "InpathClass.class"); + File destination = new File(inpathDir + File.separatorChar + + "InpathClass.class"); FileUtil.copyFile(from, destination); build("inpathTesting"); checkWasntFullBuild(); - // the newly copied inpath class means the declare warning now matches two + // the newly copied inpath class means the declare warning now matches + // two // places, therefore expect two warning messages warnings = getWarningMessages("inpathTesting"); - assertTrue("Expected there to be two warning message but found " + warnings.size() + ": " + warnings, warnings.size() == 2); + assertTrue("Expected there to be two warning message but found " + + warnings.size() + ": " + warnings, warnings.size() == 2); } // --- helper code --- /** - * Retrieve program elements related to this one regardless of the relationship. A JUnit assertion is made that the number that - * the 'expected' number are found. + * Retrieve program elements related to this one regardless of the + * relationship. A JUnit assertion is made that the number that the + * 'expected' number are found. * - * @param programElement Program element whose related elements are to be found - * @param expected the number of expected related elements + * @param programElement + * Program element whose related elements are to be found + * @param expected + * the number of expected related elements */ - private List/* IProgramElement */getRelatedElements(IProgramElement programElement, int expected) { + private List/* IProgramElement */getRelatedElements( + IProgramElement programElement, int expected) { List relatedElements = getRelatedElements(programElement); StringBuffer debugString = new StringBuffer(); if (relatedElements != null) { for (Iterator iter = relatedElements.iterator(); iter.hasNext();) { String element = (String) iter.next(); - debugString.append(AsmManager.getDefault().getHierarchy().findElementForHandle(element).toLabelString()).append( - "\n"); + debugString.append( + AsmManager.getDefault().getHierarchy() + .findElementForHandle(element).toLabelString()) + .append("\n"); } } - assertTrue("Should be " + expected + " element" + (expected > 1 ? "s" : "") + " related to this one '" + programElement - + "' but found :\n " + debugString, relatedElements != null && relatedElements.size() == 1); + assertTrue("Should be " + expected + " element" + + (expected > 1 ? "s" : "") + " related to this one '" + + programElement + "' but found :\n " + debugString, + relatedElements != null && relatedElements.size() == 1); return relatedElements; } - private IProgramElement getFirstRelatedElement(IProgramElement programElement) { + private IProgramElement getFirstRelatedElement( + IProgramElement programElement) { List rels = getRelatedElements(programElement, 1); - return AsmManager.getDefault().getHierarchy().findElementForHandle((String) rels.get(0)); + return AsmManager.getDefault().getHierarchy().findElementForHandle( + (String) rels.get(0)); } private List/* IProgramElement */getRelatedElements(IProgramElement advice) { @@ -1797,19 +2204,22 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } /** - * Finds the first 'code' program element below the element supplied - will return null if there aren't any + * Finds the first 'code' program element below the element supplied - will + * return null if there aren't any */ private IProgramElement findCode(IProgramElement ipe) { return findCode(ipe, -1); } /** - * Searches a hierarchy of program elements for a 'code' element at the specified line number, a line number of -1 means just - * return the first one you find + * Searches a hierarchy of program elements for a 'code' element at the + * specified line number, a line number of -1 means just return the first + * one you find */ private IProgramElement findCode(IProgramElement ipe, int linenumber) { if (ipe.getKind() == IProgramElement.Kind.CODE) { - if (linenumber == -1 || ipe.getSourceLocation().getLine() == linenumber) + if (linenumber == -1 + || ipe.getSourceLocation().getLine() == linenumber) return ipe; } List kids = ipe.getChildren(); @@ -1826,25 +2236,31 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // - memory usage (freemem calls?) // - relationship map - // --------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + // ------------------------- - private IProgramElement checkForNode(String packageName, String typeName, boolean shouldBeFound) { - IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForType(packageName, typeName); + private IProgramElement checkForNode(String packageName, String typeName, + boolean shouldBeFound) { + IProgramElement ipe = AsmManager.getDefault().getHierarchy() + .findElementForType(packageName, typeName); if (shouldBeFound) { if (ipe == null) printModel(); - assertTrue("Should have been able to find '" + packageName + "." + typeName + "' in the asm", ipe != null); + assertTrue("Should have been able to find '" + packageName + "." + + typeName + "' in the asm", ipe != null); } else { if (ipe != null) printModel(); - assertTrue("Should have NOT been able to find '" + packageName + "." + typeName + "' in the asm", ipe == null); + assertTrue("Should have NOT been able to find '" + packageName + + "." + typeName + "' in the asm", ipe == null); } return ipe; } private void printModel() { try { - AsmManager.dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + AsmManager.dumptree(AsmManager.getDefault().getHierarchy() + .getRoot(), 0); } catch (IOException e) { e.printStackTrace(); } @@ -1866,7 +2282,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } private void assertNoErrors(String projectName) { - assertTrue("Should be no errors, but got " + getErrorMessages(projectName), getErrorMessages(projectName).size() == 0); + assertTrue("Should be no errors, but got " + + getErrorMessages(projectName), getErrorMessages(projectName) + .size() == 0); } }
\ No newline at end of file |