aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/org/aspectj
diff options
context:
space:
mode:
authoraclement <aclement>2006-10-06 16:29:03 +0000
committeraclement <aclement>2006-10-06 16:29:03 +0000
commitd532892d89865511ea39286e4ebd34fc20b96a5d (patch)
tree6c6eeb9ba24b7afe1686603984763a729bc7b32a /tests/src/org/aspectj
parent2883a55829716132efcf288acec08bf3ab6826a7 (diff)
downloadaspectj-d532892d89865511ea39286e4ebd34fc20b96a5d.tar.gz
aspectj-d532892d89865511ea39286e4ebd34fc20b96a5d.zip
tests and fixes for jdtlikehandleprovider, bug 159896
Diffstat (limited to 'tests/src/org/aspectj')
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java61
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml25
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
index 4dd33640e..eba17ef8b 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
@@ -316,6 +316,67 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
+ ", but did not",top.getElement(handle2));
}
+ public void testTwoPiecesOfBeforeAdviceInInjarAspectHaveUniqueHandles_pr159896() {
+ runTest("advice with same name in injar aspect should have unique handles");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"before(): p..").getHandleIdentifier();
+ 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));
+ }
+
+ 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));
+ }
+
+ // if have one declare warning and one declare error statement within an injar
+ // aspect, neither of them should have a counter (i.e. "!2") at the end of
+ // their handle
+ public void testOnlyIncrementSameDeclareTypeFromInjar_pr159896() {
+ runTest("dont increment counter for different declares");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String warning = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_WARNING,"declare warning: \"warning\"").getHandleIdentifier();
+ assertTrue("shouldn't have incremented counter for declare warning handle " +
+ "because only one declare warning statement",
+ warning.indexOf("!0") == -1 && warning.indexOf("!2") == -1);
+ String error = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ERROR,"declare error: \"error\"").getHandleIdentifier();
+ assertTrue("shouldn't have incremented counter for declare error handle " +
+ "because only one declare error statement",
+ error.indexOf("!0") == -1 && error.indexOf("!2") == -1);
+ }
+
+ public void testOnlyIncrementSameAdviceKindFromInjar_pr159896() {
+ runTest("dont increment counter for different advice kinds");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String before = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"before(): p..").getHandleIdentifier();
+ assertTrue("shouldn't have incremented counter for before handle " +
+ "because only one before advice",
+ before.indexOf("!0") == -1 && before.indexOf("!2") == -1 && before.indexOf("!3") == -1 );
+ String after = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"after(): p..").getHandleIdentifier();
+ assertTrue("shouldn't have incremented counter for after handle " +
+ "because only one after advice",
+ after.indexOf("!0") == -1 && after.indexOf("!2") == -1 && after.indexOf("!3") == -1 );
+ String around = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"around(): p1..").getHandleIdentifier();
+ assertTrue("shouldn't have incremented counter for around handle " +
+ "because only one around advice",
+ around.indexOf("!0") == -1 && around.indexOf("!2") == -1 && around.indexOf("!3") == -1 );
+
+ }
+
//---------- following tests ensure we produce the same handles as jdt -----//
//---------- (apart from the prefix)
diff --git a/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml b/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
index 3d0172e0a..fa4854194 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
@@ -228,4 +228,29 @@
<compile files="Set.aj" options="-emacssym"/>
</ajc-test>
+ <ajc-test dir="features153/jdtlikehandleprovider" title="advice with same name in injar aspect should have unique handles">
+ <compile files="ClassForAspectpath.java" options="-emacssym" aspectpath="jarForAspectPath.jar">
+ <message kind="warning" text="blah"/>
+ <message kind="warning" text="blah2"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="declare warnings in injar aspect should have unique handles">
+ <compile files="ClassForAspectpath.java" options="-emacssym" aspectpath="jarForAspectPath.jar">
+ <message kind="warning" text="blah"/>
+ <message kind="warning" text="blah2"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="dont increment counter for different declares">
+ <compile files="ClassForAspectpath.java" options="-emacssym" aspectpath="declare.jar">
+ <message kind="warning" text="warning"/>
+ <message kind="error" text="error"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="dont increment counter for different advice kinds">
+ <compile files="ClassForAspectpath.java" options="-emacssym" aspectpath="advice.jar"/>
+ </ajc-test>
+
</suite>