aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/org
diff options
context:
space:
mode:
authoraclement <aclement>2006-05-30 09:59:53 +0000
committeraclement <aclement>2006-05-30 09:59:53 +0000
commit26a8a862994acefb10a57d561b18c94ffeba41a4 (patch)
tree49791e4148a73d090e0c34fd22ab8ad9951ca137 /tests/src/org
parent9eb7fa0bc21878bfd2c0251afb4001b5eb55e346 (diff)
downloadaspectj-26a8a862994acefb10a57d561b18c94ffeba41a4.tar.gz
aspectj-26a8a862994acefb10a57d561b18c94ffeba41a4.zip
test and fixes for 143930, 143924
Diffstat (limited to 'tests/src/org')
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java41
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/ajc152.xml6
3 files changed, 48 insertions, 1 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
index 3a76b645c..443418a78 100644
--- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
@@ -232,7 +232,7 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,"declare @constructor: BankAccount+.new(..) : @Secured(role = \"supervisor\")");
assertNotNull("Couldn't find 'declare @constructor' element in the tree",decac);
IProgramElement ctr = top.findElementForLabel(top.getRoot(),
- IProgramElement.Kind.CONSTRUCTOR,"BankAccount(String,int)");
+ IProgramElement.Kind.CONSTRUCTOR,"BankAccount(java.lang.String,int)");
assertNotNull("Couldn't find the 'BankAccount(String,int)' constructor element in the tree",ctr);
diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
index 405f56250..67cb7c1db 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
@@ -11,9 +11,15 @@
package org.aspectj.systemtest.ajc152;
import java.io.File;
+import java.util.List;
+
import junit.framework.Test;
//import org.aspectj.systemtest.ajc150.GenericsTests;
+import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.internal.Relationship;
import org.aspectj.testing.XMLBasedAjcTestCase;
public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
@@ -68,6 +74,41 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testSuperCallsInAtAspectJAdvice_pr139749() { runTest("Super calls in @AspectJ advice");}
public void testNoClassCastExceptionWithPerThis_pr138286() { runTest("No ClassCastException with perThis");}
+ public void testDeclareAtMethodRelationship_pr143924() {
+ //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("declare @method relationship");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ // get the IProgramElements corresponding to the different code entries
+ IProgramElement decam = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
+ "declare @method: * debit(..) : @Secured(role = \"supervisor\")");
+ assertNotNull("Couldn't find 'declare @method' element in the tree",decam);
+ IProgramElement method = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.METHOD,"debit(java.lang.String,long)");
+ assertNotNull("Couldn't find the 'debit(String,long)' method element in the tree",method);
+
+ List matches = AsmManager.getDefault().getRelationshipMap().get(decam);
+ assertNotNull("'declare @method' should have some relationships but does not",matches);
+ assertTrue("'declare @method' should have one relationships but has " + matches.size(),matches.size()==1);
+ List matchesTargets = ((Relationship)matches.get(0)).getTargets();
+ assertTrue("'declare @method' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1);
+ IProgramElement target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0));
+ assertEquals("target of relationship should be the 'debit(java.lang.String,long)' method but is IPE with label "
+ + target.toLabelString(),method,target);
+
+ // check that the debit method has an annotated by relationship with the declare @method
+ matches = AsmManager.getDefault().getRelationshipMap().get(method);
+ assertNotNull("'debit(java.lang.String,long)' should have some relationships but does not",matches);
+ assertTrue("'debit(java.lang.String,long)' should have one relationships but has " + matches.size(),matches.size()==1);
+ matchesTargets = ((Relationship)matches.get(0)).getTargets();
+ assertTrue("'debit(java.lang.String,long)' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1);
+ target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0));
+ assertEquals("target of relationship should be the 'declare @method' ipe but is IPE with label "
+ + target.toLabelString(),decam,target);
+
+ }
+
// this next one reported as a bug by Rob Harrop, but I can't reproduce the failure yet...
//public void testAtAspectWithReferencePCPerClause_pr138220() { runTest("@Aspect with reference pointcut in perclause");}
diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
index 4230c07f9..5741576b1 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
+++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
@@ -527,6 +527,12 @@
<compile files="Covariance.java" options="-1.5"/>
</ajc-test>
+ <ajc-test dir="bugs152" title="declare @method relationship">
+ <compile files="pr143924.aj" options="-1.5 -showWeaveInfo -emacssym">
+ <message kind="weave" text="'public void BankAccount.debit(String,long)' (pr143924.aj:7) is annotated with @Secured"/>
+ </compile>
+ </ajc-test>
+
<!-- wont work whilst the compiler BuildArgParser.setDebugOptions is always switching debug on -->
<ajc-test dir="bugs152/pr129408" title="long winded ataj messages">
<compile files="AtAj.java" options="-XterminateAfterCompilation -g:none -1.5"/>