From: aclement Date: Thu, 24 Mar 2005 13:10:26 +0000 (+0000) Subject: new tests for ASM testing of declare annotation targetting ITDs X-Git-Tag: V1_5_0M2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=68eda4e35b8725c478216a13da5d81a562fb9e0f;p=aspectj.git new tests for ASM testing of declare annotation targetting ITDs --- 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 @@ - + @@ -2088,7 +2088,7 @@ - + @@ -2102,7 +2102,7 @@ - + @@ -2113,7 +2113,7 @@ - + @@ -2123,7 +2123,7 @@ - +