From 8a81e52c5b95c06af9ecc054cda5cb9bb78602dc Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 24 Sep 2008 20:07:24 +0000 Subject: [PATCH] 247742:c27 --- .../ajc153/JDTLikeHandleProviderTests.java | 275 ++++++------------ .../tools/MultiProjectIncrementalTests.java | 56 +++- .../aspectj/systemtest/model/Model5Tests.java | 38 ++- 3 files changed, 176 insertions(+), 193 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index a13f11444..7c87c2609 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -49,14 +49,12 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { IProgramElement pe = top.findElementForType("pkg", "A1"); String expected = "", "", "", "", "(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." + "(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." - + "(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." + "(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)); + 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)); - 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)); + 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)); } 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)); + 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)); - 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)); + 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)); } 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..") + String handle1 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "before(): p..").getHandleIdentifier(); + String handle2 = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE, "before(): exec..") .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)); + 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); + AsmManager.getDefault().dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -330,15 +284,11 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { 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(); - 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)); + String handle1 = top.findElementForLabel(top.getRoot(), 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)); } // if have one declare warning and one declare error statement within an @@ -348,22 +298,14 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { 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, + 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\"") + 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); + 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() { @@ -400,8 +342,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { public void testCompilationUnitSameAsJDT() { // JDT: =TJP Example/src; runTest("method with generic arg same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "genericMethod1(java.util.List)", + compareHandles(IProgramElement.Kind.METHOD, "genericMethod1(java.util.List)", ";"); } @@ -585,49 +507,39 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { // JDT: =Java5 Handles/src;~QMyGenericClass\; runTest("method with two generic args same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "genericMethod2(java.util.List," - + "pkg.MyGenericClass)", - ";~QMyGenericClass\\;"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod2(java.util.List," + + "pkg.MyGenericClass)", ";~QMyGenericClass\\;"); } public void testMethodWithTwoTypeParametersSameAsJDT() { // JDT: =Java5 Handles/src; runTest("method with two type parameters same as jdt"); - compareHandles( - IProgramElement.Kind.METHOD, - "genericMethod4(pkg.MyGenericClass2)", - ";"); + compareHandles(IProgramElement.Kind.METHOD, "genericMethod4(pkg.MyGenericClass2)", + ";"); } public void testMethodWithTwoArgsSameAsJDT_2() { // JDT: =Java5 Handles/src; runTest("method with two args one of which is generic same as jdt"); - compareHandles(IProgramElement.Kind.METHOD, - "genericMethod3(int,java.util.List)", + compareHandles(IProgramElement.Kind.METHOD, "genericMethod3(int,java.util.List)", ";"); } /* - * 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); } // /////////////////////////////////////// @@ -636,8 +548,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { } protected File getSpecFile() { - return new File( - "../tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml"); + return new File("../tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml"); } } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index c2b302c05..69edd6bdf 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -13,6 +13,7 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.Hashtable; @@ -143,6 +144,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkCompileWeaveCount("Annos", 3, 3); } + public void testBrokenHandles_pr247742() { + String p = "BrokenHandles"; + initialiseProject(p); + // alter(p, "inc1"); + build(p); + // alter(p, "inc2"); + // build(p); + dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); + + IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot(); + IProgramElement ipe = findElementAtLine(root, 4); + assertEquals("=BrokenHandles