diff options
author | aclement <aclement> | 2005-03-24 13:10:26 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-03-24 13:10:26 +0000 |
commit | 68eda4e35b8725c478216a13da5d81a562fb9e0f (patch) | |
tree | 42ce060df9f3d53018125b1ab1146b9c00893ea4 | |
parent | 381de4c97d686dbbf52b297e8dac6dc5236f4e28 (diff) | |
download | aspectj-68eda4e35b8725c478216a13da5d81a562fb9e0f.tar.gz aspectj-68eda4e35b8725c478216a13da5d81a562fb9e0f.zip |
new tests for ASM testing of declare annotation targetting ITDs
4 files changed, 104 insertions, 13 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java index b8055c706..14cfbc008 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java @@ -11,9 +11,14 @@ 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 { @@ -299,4 +304,94 @@ 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 diff --git a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java index b0efd8949..3a099a2ab 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Annotations.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Annotations.java @@ -76,11 +76,7 @@ public class Annotations extends XMLBasedAjcTestCase { // more implementation work needed before this test passes public void testAnnotatedITDs() { - try { runTest("annotated itds"); - } finally { - System.err.println(ajc.getLastCompilationResult().getStandardError()); - } } public void testAnnotatedITDsWithWrongAnnotationType() { diff --git a/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java b/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java index 856dfad31..2aa7ded4b 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java @@ -293,7 +293,7 @@ public class DeclareAnnotationTests extends XMLBasedAjcTestCase { 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); @@ -301,7 +301,7 @@ public class DeclareAnnotationTests extends XMLBasedAjcTestCase { 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); @@ -309,14 +309,14 @@ public class DeclareAnnotationTests extends XMLBasedAjcTestCase { 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); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 36b2e029f..07562c2c4 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -127,7 +127,7 @@ </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> @@ -2088,7 +2088,7 @@ <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)"/> @@ -2102,7 +2102,7 @@ </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)"/> @@ -2113,7 +2113,7 @@ </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)"/> @@ -2123,7 +2123,7 @@ </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)"/> |