From 8ed07c9e61d00d788e7d05d6c90bbeb3d378dcff Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 17 Sep 2008 18:36:12 +0000 Subject: jdt like handle fixes: anonymous inner classes --- tests/model/expected/pr77269_1.txt | 4 +- tests/model/expected/pr77269_2.txt | 6 +- .../AdviceHandles/base/src/Handles.aj | 33 +- .../tools/MultiProjectIncrementalTests.java | 1077 +++++++------------- .../org/aspectj/systemtest/model/ModelTests.java | 72 +- 5 files changed, 468 insertions(+), 724 deletions(-) diff --git a/tests/model/expected/pr77269_1.txt b/tests/model/expected/pr77269_1.txt index a5ef46b3c..71c826f64 100644 --- a/tests/model/expected/pr77269_1.txt +++ b/tests/model/expected/pr77269_1.txt @@ -7,15 +7,15 @@ testMethod() [method] TEST_SANDBOX\pack\pr77269.aj:4: new Runnable() {..} [class] TEST_SANDBOX\pack\pr77269.aj:5: run() [method] TEST_SANDBOX\pack\pr77269.aj:6: - 1$C [class] TEST_SANDBOX\pack\pr77269.aj:9: + C [class] TEST_SANDBOX\pack\pr77269.aj:9: m() [method] TEST_SANDBOX\pack\pr77269.aj:10: A [aspect] TEST_SANDBOX\pack\pr77269.aj:17: p() [pointcut] TEST_SANDBOX\pack\pr77269.aj:19: before(): p.. [advice] TEST_SANDBOX\pack\pr77269.aj:21: === END OF MODEL REPORT ========= === RELATIONSHIPS REPORT ========= After a batch build -(targets=1) // ) + * 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 // ) * - * 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 } * * } */ @@ -70,80 +62,56 @@ public class MultiProjectIncrementalTests extends // 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()); } } } @@ -160,21 +128,18 @@ public class MultiProjectIncrementalTests extends 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); } @@ -186,61 +151,70 @@ public class MultiProjectIncrementalTests extends dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); // incomplete } - + public void testAdviceHandlesAreJDTCompatible() { String p = "AdviceHandles"; initialiseProject(p); addSourceFolderForSourceFile(p, getProjectRelativePath(p, "src/Handles.aj"), "src"); build(p); IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot(); - IProgramElement typeDecl = findElementAtLine(root,4); - assertEquals("=AdviceHandles/src(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 (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"); @@ -778,24 +677,19 @@ public class MultiProjectIncrementalTests extends 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"); @@ -803,21 +697,18 @@ public class MultiProjectIncrementalTests extends // 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() { @@ -935,52 +826,38 @@ public class MultiProjectIncrementalTests extends 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() { @@ -1007,49 +884,40 @@ public class MultiProjectIncrementalTests extends } /* - * 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 @@ -1059,21 +927,17 @@ public class MultiProjectIncrementalTests extends 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 @@ -1086,23 +950,20 @@ public class MultiProjectIncrementalTests extends 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()); } @@ -1110,9 +971,8 @@ public class MultiProjectIncrementalTests extends 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"); @@ -1120,8 +980,7 @@ public class MultiProjectIncrementalTests extends } /** - * 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"); @@ -1148,14 +1007,12 @@ public class MultiProjectIncrementalTests extends 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(); } @@ -1165,9 +1022,7 @@ public class MultiProjectIncrementalTests extends 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 @@ -1179,8 +1034,7 @@ public class MultiProjectIncrementalTests extends 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); } } } @@ -1192,9 +1046,7 @@ public class MultiProjectIncrementalTests extends 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 @@ -1206,8 +1058,7 @@ public class MultiProjectIncrementalTests extends 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); } } } @@ -1218,13 +1069,11 @@ public class MultiProjectIncrementalTests extends 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 @@ -1302,60 +1151,44 @@ public class MultiProjectIncrementalTests extends 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); * * } */ @@ -1399,8 +1232,7 @@ public class MultiProjectIncrementalTests extends 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"); @@ -1412,9 +1244,8 @@ public class MultiProjectIncrementalTests extends 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() { @@ -1422,8 +1253,7 @@ public class MultiProjectIncrementalTests extends 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 @@ -1449,9 +1279,7 @@ public class MultiProjectIncrementalTests extends 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(); @@ -1473,9 +1301,7 @@ public class MultiProjectIncrementalTests extends 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() { @@ -1485,9 +1311,7 @@ public class MultiProjectIncrementalTests extends 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() { @@ -1495,14 +1319,11 @@ public class MultiProjectIncrementalTests extends 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); } @@ -1511,18 +1332,15 @@ public class MultiProjectIncrementalTests extends 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()) @@ -1531,15 +1349,12 @@ public class MultiProjectIncrementalTests extends 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()); + 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 @@ -1549,60 +1364,49 @@ public class MultiProjectIncrementalTests extends IHierarchy top = AsmManager.getDefault().getHierarchy(); IProgramElement pe = top.findElementForType("pkg", "A"); String expectedHandle = "=JDTLikeHandleProvider"); // 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(): "); - 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 @@ -1612,34 +1416,22 @@ public class MultiProjectIncrementalTests extends 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"); @@ -1647,22 +1439,18 @@ public class MultiProjectIncrementalTests extends String expected = "=JDTLikeHandleProvider 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", + 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); @@ -2130,19 +1860,16 @@ public class MultiProjectIncrementalTests extends 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", + assertTrue("expected there to be more than the one compliance level" + " error but only found that one", errors.size() > 1); } } @@ -2150,10 +1877,8 @@ public class MultiProjectIncrementalTests extends 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 @@ -2164,15 +1889,12 @@ public class MultiProjectIncrementalTests extends 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"); @@ -2181,47 +1903,36 @@ public class MultiProjectIncrementalTests extends // 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) { @@ -2261,22 +1972,19 @@ public class MultiProjectIncrementalTests extends } /** - * 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(); @@ -2293,31 +2001,26 @@ public class MultiProjectIncrementalTests extends // - 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(); } @@ -2339,9 +2042,7 @@ public class MultiProjectIncrementalTests extends } 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 diff --git a/tests/src/org/aspectj/systemtest/model/ModelTests.java b/tests/src/org/aspectj/systemtest/model/ModelTests.java index d4f597bd3..36d042121 100644 --- a/tests/src/org/aspectj/systemtest/model/ModelTests.java +++ b/tests/src/org/aspectj/systemtest/model/ModelTests.java @@ -20,10 +20,11 @@ import org.aspectj.weaver.World; /** * Tests the model when there is no requirement on Java5 features. - * @see org.aspectj.systemtest.model.ModelTestCase + * + * @see org.aspectj.systemtest.model.ModelTestCase */ public class ModelTests extends ModelTestCase { - + static { // Switch this to true for a single iteration if you want to reconstruct the // 'expected model' files. @@ -32,10 +33,21 @@ public class ModelTests extends ModelTestCase { debugTest = false; } - public void testAdviceInStructureModelWithAnonymousInnerClass_pr77269() {runModelTest("advice in structure model with anonymous inner class","pr77269_1");} - public void testAdviceInStructureModelWithNamedInnerClass_pr77269() {runModelTest("advice in structure model with named inner class","pr77269_2");} - public void testDWInStructureModelWithAnonymousInnerClass_pr77269() {runModelTest("declare warning in structure model with anonymous inner class","pr77269_3");} - public void testNewIProgramElementMethods_pr141730() {runModelTest("new iprogramelement methods","pr141730_1");} + public void testAdviceInStructureModelWithAnonymousInnerClass_pr77269() { + runModelTest("advice in structure model with anonymous inner class", "pr77269_1"); + } + + public void testAdviceInStructureModelWithNamedInnerClass_pr77269() { + runModelTest("advice in structure model with named inner class", "pr77269_2"); + } + + public void testDWInStructureModelWithAnonymousInnerClass_pr77269() { + runModelTest("declare warning in structure model with anonymous inner class", "pr77269_3"); + } + + public void testNewIProgramElementMethods_pr141730() { + runModelTest("new iprogramelement methods", "pr141730_1"); + } // if not filling in the model for aspects contained in jar files then // want to ensure that the relationship map is correct and has nodes @@ -44,12 +56,12 @@ public class ModelTests extends ModelTestCase { public void testAspectPathRelWhenNotFillingInModel_pr141730() { World.createInjarHierarchy = false; try { - runModelTest("ensure aspectpath injar relationships are correct when not filling in model","pr141730_3"); + runModelTest("ensure aspectpath injar relationships are correct when not filling in model", "pr141730_3"); } finally { World.createInjarHierarchy = true; } } - + public void testPCDInClassAppearsInModel_pr148027() { boolean b = AsmHierarchyBuilder.shouldAddUsesPointcut; AsmHierarchyBuilder.shouldAddUsesPointcut = true; @@ -61,20 +73,36 @@ public class ModelTests extends ModelTestCase { AsmHierarchyBuilder.shouldAddUsesPointcut = b; } } - -// public void testInpathAdvisedCode_prX() { runModelTest("inpath advised elements","prX"); } - - public void testSourceLocationAndJarFile_pr145963() {runModelTest("sourcelocation and jar file","pr145963_1");} - public void testSourceLocationAndClassFile_pr145963() {runModelTest("sourcelocation and class file","pr145963_2");} - public void testAspectInDefaultPackage_pr145963() {runModelTest("aspect in default package", "pr145963_3");} - public void testAspectInJavaFile_pr145963() {runModelTest("aspect in java file", "pr145963_4");} - - public void testAbstractAspectsAndAdvice_pr160469() {runModelTest("ensure advice from abstract aspects appear correctly in the model","pr160469_1");} - public void testAbstractAspectsAndDeow_pr160469() {runModelTest("ensure deow from abstract aspects appear correctly in the model","pr160469_2");} - - //public void testMultipleIdenticalJpsOnOneLine_pr238054() { runModelTest("multiple identical jps on one line","pr238054");} - - ///////////////////////////////////////// + + // public void testInpathAdvisedCode_prX() { runModelTest("inpath advised elements","prX"); } + + public void testSourceLocationAndJarFile_pr145963() { + runModelTest("sourcelocation and jar file", "pr145963_1"); + } + + public void testSourceLocationAndClassFile_pr145963() { + runModelTest("sourcelocation and class file", "pr145963_2"); + } + + public void testAspectInDefaultPackage_pr145963() { + runModelTest("aspect in default package", "pr145963_3"); + } + + public void testAspectInJavaFile_pr145963() { + runModelTest("aspect in java file", "pr145963_4"); + } + + public void testAbstractAspectsAndAdvice_pr160469() { + runModelTest("ensure advice from abstract aspects appear correctly in the model", "pr160469_1"); + } + + public void testAbstractAspectsAndDeow_pr160469() { + runModelTest("ensure deow from abstract aspects appear correctly in the model", "pr160469_2"); + } + + // public void testMultipleIdenticalJpsOnOneLine_pr238054() { runModelTest("multiple identical jps on one line","pr238054");} + + // /////////////////////////////////////// public static Test suite() { return XMLBasedAjcTestCase.loadSuite(ModelTests.class); } -- cgit v1.2.3