]> source.dussan.org Git - aspectj.git/commitdiff
247742:c27
authoraclement <aclement>
Wed, 24 Sep 2008 20:07:24 +0000 (20:07 +0000)
committeraclement <aclement>
Wed, 24 Sep 2008 20:07:24 +0000 (20:07 +0000)
tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
tests/src/org/aspectj/systemtest/model/Model5Tests.java

index a13f1144490cf81622503daea5f0ea0469a58835..7c87c260948815235b9a3db16d9a87f4872484f8 100644 (file)
@@ -49,14 +49,12 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                IProgramElement pe = top.findElementForType("pkg", "A1");
                String expected = "<pkg*A1.aj}A1";
                String found = pe.getHandleIdentifier();
-               assertEquals("handleIdentifier - expected " + expected + ", but found "
-                               + found, expected, found);
+               assertEquals("handleIdentifier - expected " + expected + ", but found " + found, expected, found);
        }
 
        public void testAdviceHandle() {
                runTest("advice handle");
-               compareHandles(IProgramElement.Kind.ADVICE,
-                               "before(): <anonymous pointcut>", "<pkg*A2.aj}A2&before");
+               compareHandles(IProgramElement.Kind.ADVICE, "before(): <anonymous pointcut>", "<pkg*A2.aj}A2&before");
        }
 
        public void testPointcutHandle() {
@@ -76,81 +74,66 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
 
        public void testAdviceHandleWithCrossCutting() {
                runTest("advice handle with crosscutting");
-               compareHandles(IProgramElement.Kind.ADVICE,
-                               "before(): <anonymous pointcut>", "<pkg*A3.aj}A3&before");
+               compareHandles(IProgramElement.Kind.ADVICE, "before(): <anonymous pointcut>", "<pkg*A3.aj}A3&before");
        }
 
        public void testPointcutHandleWithArgs() {
                runTest("pointcut handle with args");
-               compareHandles(IProgramElement.Kind.POINTCUT, "p(java.lang.Integer)",
-                               "*A6.aj}A6+p+QInteger;");
+               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,
-                               "afterReturning(java.lang.Integer): p..",
+               compareHandles(IProgramElement.Kind.ADVICE, "afterReturning(java.lang.Integer): p..",
                                "<pkg*A8.aj}A8&afterReturning&QInteger;");
        }
 
        public void testFieldITD() {
                runTest("field itd handle");
-               compareHandles(IProgramElement.Kind.INTER_TYPE_FIELD, "C.x",
-                               "<pkg*A9.aj}A9)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()",
-                               "<pkg*A9.aj}A9)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");
+               compareHandles(IProgramElement.Kind.INTER_TYPE_METHOD, "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;");
+               compareHandles(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR, "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");
+               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");
+               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())");
+               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");
-               compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE,
-                               "declare @type: pkg.C : @MyAnnotation",
+               compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE, "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",
+               compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, "declare @field: int pkg.C.someField : @MyAnnotation",
                                "<pkg*A12.aj}A`declare @field!2");
        }
 
@@ -158,15 +141,13 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                // 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");
+                               "declare @method: public void pkg.C.method1() : @MyAnnotation", "<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",
+               compareHandles(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, "declare @constructor: pkg.C.new() : @MyAnnotation",
                                "<pkg*A12.aj}A`declare @constructor!4");
        }
 
@@ -175,8 +156,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        public void testTwoPiecesOfAdviceWithSameSignatureAndPointcut() {
                runTest("two pieces of advice with the same signature and pointcut");
                IHierarchy top = AsmManager.getDefault().getHierarchy();
-               IProgramElement parent = top.findElementForLabel(top.getRoot(),
-                               IProgramElement.Kind.ASPECT, "A5");
+               IProgramElement parent = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ASPECT, "A5");
                List children = parent.getChildren();
                String handle1 = null;
                String handle2 = null;
@@ -194,28 +174,22 @@ 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.\"",
+               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");
+               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
@@ -223,12 +197,10 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        // want one with count 10.
        public void testTenDeclareWarningHandles() {
                runTest("ten declare warning handles");
-               compareHandles(IProgramElement.Kind.DECLARE_WARNING,
-                               "declare warning: \"warning 1\"",
-                               "*DeclareWarnings.aj}DeclareWarnings`declare warning");
-               compareHandles(IProgramElement.Kind.DECLARE_WARNING,
-                               "declare warning: \"warning 10\"",
-                               "*DeclareWarnings.aj}DeclareWarnings`declare warning!10");
+               compareHandles(IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"warning 1\"",
+                               "<*DeclareWarnings.aj}DeclareWarnings`declare warning");
+               compareHandles(IProgramElement.Kind.DECLARE_WARNING, "declare warning: \"warning 10\"",
+                               "<*DeclareWarnings.aj}DeclareWarnings`declare warning!10");
 
        }
 
@@ -237,20 +209,17 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        public void testIPEsWithSameNameHaveUniqueHandles_methodCall() {
                runTest("ipes with same name have unique handles - method-call");
                IHierarchy top = AsmManager.getDefault().getHierarchy();
-               String handle1 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call("
+               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));
+               assertNotNull("expected to find node with handle " + handle1 + ", but did not", top.getElement(handle1));
 
-               String handle2 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call("
+               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));
+               assertNotNull("expected to find node with handle " + handle2 + ", but did not", top.getElement(handle2));
 
-               String handle3 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call("
+               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));
+               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
@@ -258,69 +227,54 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        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("
+               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));
+               assertNotNull("expected to find node with handle " + handle1 + ", but did not", top.getElement(handle1));
 
-               String handle2 = "*TwoDiffMethodCalls.aj[Main~method~\\[QString;?method-call("
+               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));
+               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));
+               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<tjp{Demo.java
                runTest("compilation unit same as jdt");
-               compareHandles(IProgramElement.Kind.FILE_JAVA, "Demo.java",
-                               "<tjp{Demo.java");
+               compareHandles(IProgramElement.Kind.FILE_JAVA, "Demo.java", "<tjp{Demo.java");
        }
 
        public void testClassSameAsJDT() {
@@ -413,22 +354,19 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        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;");
+               compareHandles(IProgramElement.Kind.CONSTRUCTOR, "C(java.lang.String)", "<pkg{C.java[C~C~QString;");
        }
 
        // public void testPackageDeclarationSameAsJDT() {
@@ -443,8 +381,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
        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.*",
-                               "<tjp{Demo.java#java.io.*");
+               compareHandles(IProgramElement.Kind.IMPORT_REFERENCE, "java.io.*", "<tjp{Demo.java#java.io.*");
        }
 
        public void testTypeSameAsJDT() {
@@ -454,8 +391,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                IProgramElement pe = top.findElementForType("tjp", "Demo");
                String expected = "<tjp{Demo.java[Demo";
                String found = pe.getHandleIdentifier();
-               assertEquals("handleIdentifier - expected " + expected + ", but found "
-                               + found, expected, found);
+               assertEquals("handleIdentifier - expected " + expected + ", but found " + found, expected, found);
        }
 
        public void testFieldSameAsJDT() {
@@ -469,8 +405,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                // and =TJP Example/src<tjp{Demo.java[Demo|2
                runTest("initialization same as jdt");
                IHierarchy top = AsmManager.getDefault().getHierarchy();
-               IProgramElement parent = top.findElementForLabel(top.getRoot(),
-                               IProgramElement.Kind.CLASS, "Demo");
+               IProgramElement parent = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CLASS, "Demo");
                List children = parent.getChildren();
                String handle1 = null;
                String handle2 = null;
@@ -490,50 +425,41 @@ 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[])",
-                               "<tjp{Demo.java[Demo~main~\\[QString;");
+               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[])",
-                               "<tjp{Demo.java[Demo~m~\\[I");
+               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()",
-                               "<tjp{Demo.java[Demo~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;");
+               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)",
+               compareHandles(IProgramElement.Kind.METHOD, "m2(java.lang.String,java.lang.String)",
                                "<tjp{Demo.java[Demo~m2~QString;~QString;");
        }
 
@@ -544,8 +470,7 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                IProgramElement pe = top.findElementForType("pkg", "E");
                String expected = "<pkg{E.java[E";
                String found = pe.getHandleIdentifier();
-               assertEquals("handleIdentifier - expected " + expected + ", but found "
-                               + found, expected, found);
+               assertEquals("handleIdentifier - expected " + expected + ", but found " + found, expected, found);
        }
 
        public void testEnumValueSameAsJDT() {
@@ -561,23 +486,20 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                IProgramElement pe = top.findElementForType("pkg", "MyAnnotation");
                String expected = "<pkg{MyAnnotation.java[MyAnnotation";
                String found = pe.getHandleIdentifier();
-               assertEquals("handleIdentifier - expected " + expected + ", but found "
-                               + found, expected, found);
+               assertEquals("handleIdentifier - expected " + expected + ", but 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)",
-                               "<pkg{Java5Class.java[Java5Class~method2~QList;");
+               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;>;
                runTest("method with generic arg same as jdt");
-               compareHandles(IProgramElement.Kind.METHOD,
-                               "genericMethod1(java.util.List<java.lang.String>)",
+               compareHandles(IProgramElement.Kind.METHOD, "genericMethod1(java.util.List<java.lang.String>)",
                                "<pkg{Java5Class.java[Java5Class~genericMethod1~QList\\<QString;>;");
        }
 
@@ -585,49 +507,39 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
                // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class
                // ~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{Java5Class.java[Java5Class~genericMethod2~QList"
-                                               + "\\<QString;>;~QMyGenericClass\\<QInteger;>;");
+               compareHandles(IProgramElement.Kind.METHOD, "genericMethod2(java.util.List<java.lang.String>,"
+                               + "pkg.MyGenericClass<java.lang.Integer>)", "<pkg{Java5Class.java[Java5Class~genericMethod2~QList"
+                               + "\\<QString;>;~QMyGenericClass\\<QInteger;>;");
        }
 
        public void testMethodWithTwoTypeParametersSameAsJDT() {
                // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class~genericMethod4
                // ~QMyGenericClass2\<QString;QInteger;>;
                runTest("method with two type parameters same as jdt");
-               compareHandles(
-                               IProgramElement.Kind.METHOD,
-                               "genericMethod4(pkg.MyGenericClass2<java.lang.String,java.lang.Integer>)",
-                               "<pkg{Java5Class.java[Java5Class~genericMethod4"
-                                               + "~QMyGenericClass2\\<QString;QInteger;>;");
+               compareHandles(IProgramElement.Kind.METHOD, "genericMethod4(pkg.MyGenericClass2<java.lang.String,java.lang.Integer>)",
+                               "<pkg{Java5Class.java[Java5Class~genericMethod4" + "~QMyGenericClass2\\<QString;QInteger;>;");
        }
 
        public void testMethodWithTwoArgsSameAsJDT_2() {
                // JDT: =Java5 Handles/src<pkg{Java5Class.java[Java5Class
                // ~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>)",
+               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);
        }
 
        // ///////////////////////////////////////
@@ -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");
        }
 
 }
index c2b302c05e7ae3731f6c13664b80a78c0cf00b93..69edd6bdfa00bd76ee2e97b1b990087dd6ae4fdc 100644 (file)
@@ -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<p{GetInfo.java}GetInfo`declare warning", ipe.getHandleIdentifier());
+               ipe = findElementAtLine(root, 5);
+               assertEquals("=BrokenHandles<p{GetInfo.java}GetInfo`declare warning!2", ipe.getHandleIdentifier());
+               ipe = findElementAtLine(root, 6);
+               assertEquals("=BrokenHandles<p{GetInfo.java}GetInfo`declare parents!3", ipe.getHandleIdentifier());
+       }
+
        public void testSpacewarHandles() {
                // String p = "SpaceWar";
                String p = "Simpler";
@@ -211,6 +230,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
 
        }
 
+       // Testing code handles - should they included positional information? seems to be what AJDT wants but we
+       // only have the declaration start position in the programelement
+       // public void testHandlesForCodeElements() {
+       // String p = "CodeHandles";
+       // initialiseProject(p);
+       // addSourceFolderForSourceFile(p, getProjectRelativePath(p, "src/Handles.aj"), "src");
+       // build(p);
+       // IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot();
+       // IProgramElement typeDecl = findElementAtLine(root, 3);
+       // assertEquals("=CodeHandles/src<spacewar*Handles.aj[C", typeDecl.getHandleIdentifier());
+       //
+       // IProgramElement code = findElementAtLine(root, 6);
+       // assertEquals("=CodeHandles/src<spacewar*Handles.aj[C~m?method-call(void spacewar.C.foo(int))", code.getHandleIdentifier());
+       // code = findElementAtLine(root, 7);
+       // assertEquals("=CodeHandles/src<spacewar*Handles.aj[C~m?method-call(void spacewar.C.foo(int))!2", code.getHandleIdentifier());
+       //
+       // }
+
        private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) {
                if (whereToLook == null) {
                        return null;
@@ -317,7 +354,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                build(bug2);
        }
 
-       // 
+       public void testAspectPath_pr247742_c16() throws IOException {
+               String bug = "AspectPathOne";
+               String bug2 = "AspectPathTwo";
+               addSourceFolderForSourceFile(bug2, getProjectRelativePath(bug2, "src/C.java"), "src");
+               initialiseProject(bug);
+               initialiseProject(bug2);
+               configureAspectPath(bug2, getProjectRelativePath(bug, "bin"));
+               build(bug);
+               build(bug2);
+//             dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0);
+//             PrintWriter pw = new PrintWriter(System.out);
+//             AsmManager.getDefault().dumprels(pw);
+//             pw.flush();
+               IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot();
+               assertEquals("=AspectPathTwo/binaries<pkg(Asp.class}Asp&before", findElementAtLine(root, 5).getHandleIdentifier());
+               assertEquals("=AspectPathTwo/binaries<(Asp2.class}Asp2&before", findElementAtLine(root, 16).getHandleIdentifier());
+       }
+
        // public void testAspectPath_pr242797_c41() {
        // String bug = "pr242797_3";
        // String bug2 = "pr242797_4";
index bdd16f3c05213eccb9706d52cbbe8302494599b3..edfb853e9888ea009065b736612d7a579ef28d89 100644 (file)
@@ -19,7 +19,8 @@ import org.aspectj.weaver.World;
 
 /**
  * Tests the model when there is a requirement on Java5 features.
- * @see org.aspectj.systemtest.model.ModelTestCase 
+ * 
+ * @see org.aspectj.systemtest.model.ModelTestCase
  */
 public class Model5Tests extends ModelTestCase {
 
@@ -30,13 +31,30 @@ public class Model5Tests extends ModelTestCase {
                // Switch this to true if you want to debug the comparison
                debugTest = false;
        }
-       
-       public void testDeclareAtTypeInStructureModel_pr115607() {runModelTest("declare at type appears correctly in structure model","pr115607");}
-       public void testStructureModelForGenericITD_pr131932() {runModelTest("structure model for generic itd","pr131932");}
-       public void testDeclareAnnotationAppearsInStructureModel_pr132130() {runModelTest("declare annotation appears in structure model when in same file","pr132130");}
-       public void testAtAspectDEOWInStructureModel_pr120356() {runModelTest("@AJ deow appear correctly when structure model is generated","pr120356");}
-       public void testDeclareAtMethodRelationship_pr143924() {runModelTest("declare @method relationship","pr143924");}
-       public void testNewIProgramElementMethodsForGenerics_pr141730() {runModelTest("new iprogramelement methods for generics","pr141730_2");}
+
+       public void testDeclareAtTypeInStructureModel_pr115607() {
+               runModelTest("declare at type appears correctly in structure model", "pr115607");
+       }
+
+       public void testStructureModelForGenericITD_pr131932() {
+               runModelTest("structure model for generic itd", "pr131932");
+       }
+
+       public void testDeclareAnnotationAppearsInStructureModel_pr132130() {
+               runModelTest("declare annotation appears in structure model when in same file", "pr132130");
+       }
+
+       public void testAtAspectDEOWInStructureModel_pr120356() {
+               runModelTest("@AJ deow appear correctly when structure model is generated", "pr120356");
+       }
+
+       public void testDeclareAtMethodRelationship_pr143924() {
+               runModelTest("declare @method relationship", "pr143924");
+       }
+
+       public void testNewIProgramElementMethodsForGenerics_pr141730() {
+               runModelTest("new iprogramelement methods for generics", "pr141730_2");
+       }
 
        // if not filling in the model for classes contained in jar files then
        // want to ensure that the relationship map is correct and has nodes
@@ -57,12 +75,12 @@ public class Model5Tests extends ModelTestCase {
                        // are added against the file node. Before change to using ipe's to create handles
                        // we also had the deow relationship, however, now we don't because this also
                        // uses findElementForType to find the targetNode which in the inpath case is null.
-                       runModelTest("ensure inpath injar relationships are correct when not filling in model","pr141730_4");
+                       runModelTest("ensure inpath injar relationships are correct when not filling in model", "pr141730_4");
                } finally {
                        World.createInjarHierarchy = true;
                }
        }
-       
+
        // ///////////////////////////////////////
        public static Test suite() {
                return XMLBasedAjcTestCase.loadSuite(Model5Tests.class);