package org.aspectj.systemtest.ajc150;
import java.io.File;
+import java.util.List;
import junit.framework.Test;
+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 AnnotationBinding extends XMLBasedAjcTestCase {
runTest("simple binding annotation values where itd ctor is annotated via declare");
}
+ public void testAnnotationBindingAndITDs4_asmtest() {
+ //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("simple binding annotation values where itd method is annotated via declare");
+
+ if (getCurrentTest().canRunOnThisVM()) {
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ IProgramElement ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
+ "declare @method: int A.m() : @Fruit(\"orange\")");
+ assertTrue("Couldn't find 'declare @method' element in the tree",ipe!=null);
+
+ List l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
+ "declare @method: int A.n() : @Fruit(\"banana\")");
+ assertTrue("Couldn't find 'declare @method element in the tree",ipe!=null);
+
+ l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ Relationship rel = (Relationship)l.get(0);
+ assertTrue("Should have 1 target but has "+rel.getTargets().size(),rel.getTargets().size()==1);
+ String tgt = (String)rel.getTargets().get(0);
+ assertTrue("Should point to line 10 but doesnt: "+tgt,tgt.indexOf("|10|")!=-1);
+ }
+ }
+
+ public void testAnnotationBindingAndITDs5_asmtest() {
+ // AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("simple binding annotation values where itd field is annotated via declare");
+
+ if (getCurrentTest().canRunOnThisVM()) {
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ IProgramElement ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD,
+ "declare @field: int A.i : @Fruit(\"orange\")");
+ assertTrue("Couldn't find 'declare @type' element in the tree",ipe!=null);
+
+ List l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD,
+ "declare @field: java.lang.String A.j : @Fruit(\"banana\")");
+ assertTrue("Couldn't find 'declare @field element in the tree",ipe!=null);
+
+ l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ Relationship rel = (Relationship)l.get(0);
+ assertTrue("Should have 1 target but has "+rel.getTargets().size(),rel.getTargets().size()==1);
+ String tgt = (String)rel.getTargets().get(0);
+ assertTrue("Should point to line 10 but doesnt: "+tgt,tgt.indexOf("|10|")!=-1);
+ }
+ }
+
+ public void testAnnotationBindingAndITDs7_asmtest() {
+ // AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("simple binding annotation values where itd ctor is annotated via declare");
+
+ if (getCurrentTest().canRunOnThisVM()) {
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ IProgramElement ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,
+ "declare @constructor: A.new(java.lang.String) : @Fruit(\"pear\")");
+ assertTrue("Couldn't find 'declare @constructor' element in the tree",ipe!=null);
+
+ List l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ ipe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,
+ "declare @constructor: A.new(int) : @Fruit(\"orange\")");
+ assertTrue("Couldn't find 'declare @constructor element in the tree",ipe!=null);
+
+ l = AsmManager.getDefault().getRelationshipMap().get(ipe);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+
+ Relationship rel = (Relationship)l.get(0);
+ assertTrue("Should have 1 target but has "+rel.getTargets().size(),rel.getTargets().size()==1);
+ String tgt = (String)rel.getTargets().get(0);
+ assertTrue("Should point to line 10 but doesnt: "+tgt,tgt.indexOf("|10|")!=-1);
+ }
+ }
+
}
\ No newline at end of file
IProgramElement ipe = top.findElementForLabel(top.getRoot(),
IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE,
- "declare at_type: p.q.DeathByAnnotations : @Colored(\"red\")");
+ "declare @type: p.q.DeathByAnnotations : @Colored(\"red\")");
assertTrue("Couldn't find 'declare @type' element in the tree",ipe!=null);
List l = AsmManager.getDefault().getRelationshipMap().get(ipe);
ipe = top.findElementForLabel(top.getRoot(),
IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
- "declare at_method: * m*(..) : @Fruit(\"tomato\")");
+ "declare @method: * m*(..) : @Fruit(\"tomato\")");
assertTrue("Couldn't find 'declare @method element in the tree",ipe!=null);
l = AsmManager.getDefault().getRelationshipMap().get(ipe);
ipe = top.findElementForLabel(top.getRoot(),
IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,
- "declare at_constructor: p.q.DeathByAnnotations.new(..) : @Fruit(\"tomato\")");
+ "declare @constructor: p.q.DeathByAnnotations.new(..) : @Fruit(\"tomato\")");
assertTrue("Couldn't find 'declare @constructor element in the tree",ipe!=null);
l = AsmManager.getDefault().getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ",l.size()>0);
ipe = top.findElementForLabel(top.getRoot(),
IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD,
- "declare at_field: * p.q.DeathByAnnotations.* : @Material(\"wood\")");
+ "declare @field: * p.q.DeathByAnnotations.* : @Material(\"wood\")");
assertTrue("Couldn't find 'declare @field element in the tree",ipe!=null);
l = AsmManager.getDefault().getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ",l.size()>0);
</ajc-test>
<ajc-test dir="bugs150" pr="83645" title="pertypewithin({interface}) illegal field modifier">
- <compile files="PR83645.aj"/>
+ <compile files="PR83645.java"/>
<run class="PR83645"/>
</ajc-test>
<ajc-test dir="java5/annotations/binding" title="simple binding annotation values where itd method is annotated via declare">
- <compile files="BindingWithDeclaredAnnotationItds1.aj" options="-1.5"/>
+ <compile files="BindingWithDeclaredAnnotationItds1.aj" options="-1.5,-emacssym"/>
<run class="BindingWithDeclaredAnnotationItds1">
<stderr>
<line text="Found orange at jp call(int A.m()) (BindingWithDeclaredAnnotationItds1.aj:16)"/>
</ajc-test>
<ajc-test dir="java5/annotations/binding" title="simple binding annotation values where itd field is annotated via declare">
- <compile files="BindingWithDeclaredAnnotationItds2.aj" options="-1.5"/>
+ <compile files="BindingWithDeclaredAnnotationItds2.aj" options="-1.5,-emacssym"/>
<run class="BindingWithDeclaredAnnotationItds2">
<stderr>
<line text="Found orange at jp set(int A.i) (BindingWithDeclaredAnnotationItds2.aj:16)"/>
</ajc-test>
<ajc-test dir="java5/annotations/binding" title="simple binding annotation values where itd field is annotated multiple times via declare">
- <compile files="BindingWithDeclaredAnnotationItds3.aj" options="-1.5"/>
+ <compile files="BindingWithDeclaredAnnotationItds3.aj" options="-1.5,-emacssym"/>
<run class="BindingWithDeclaredAnnotationItds3">
<stderr>
<line text="Found fruit orange at jp set(int A.i) (BindingWithDeclaredAnnotationItds3.aj:13)"/>
</ajc-test>
<ajc-test dir="java5/annotations/binding" title="simple binding annotation values where itd ctor is annotated via declare">
- <compile files="BindingWithDeclaredAnnotationItds4.aj" options="-1.5"/>
+ <compile files="BindingWithDeclaredAnnotationItds4.aj" options="-1.5,-emacssym"/>
<run class="BindingWithDeclaredAnnotationItds4">
<stderr>
<line text="Found pear at jp execution(A(String)) (BindingWithDeclaredAnnotationItds4.aj:8)"/>