]> source.dussan.org Git - aspectj.git/commitdiff
new tests for ASM testing of declare annotation targetting ITDs
authoraclement <aclement>
Thu, 24 Mar 2005 13:10:26 +0000 (13:10 +0000)
committeraclement <aclement>
Thu, 24 Mar 2005 13:10:26 +0000 (13:10 +0000)
tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
tests/src/org/aspectj/systemtest/ajc150/Annotations.java
tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

index b8055c706c5294f938050d2e0368f73a6d757ac1..14cfbc0088ae6f876ea02cd76ab0237862578363 100644 (file)
 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
index b0efd89490d7ea964780f54c4d2e69c5eefd2bcf..3a099a2ab60f0879b9dba9fe21ad66b5e268c808 100644 (file)
@@ -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() {
index 856dfad319cacbb6d59be26a0174118b51ef92bb..2aa7ded4b904e6a89efe8c144b16c7276b0b1e4d 100644 (file)
@@ -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);
index 36b2e029fd02e83c7e6b9ce6fc5546c58ccc602e..07562c2c4e297b5aa39300bb053035f5b1e05749 100644 (file)
     </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)"/>