[jboss-cvs] JBossAS SVN: r103453 - in projects/jboss-reflect/trunk/src: main/java/org/jboss/reflect/plugins/javassist and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 1 14:11:21 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-04-01 14:11:20 -0400 (Thu, 01 Apr 2010)
New Revision: 103453

Added:
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithInheritedAnnotations.java
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations.java
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations2.java
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/NoAnnotationsBean.java
Modified:
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHolder.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/AnnotatedInfo.java
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
Log:
[JBREFLECT-114][JBREFLECT-115] Fix annotation issues in Javassist implementation

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHolder.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHolder.java	2010-04-01 17:25:40 UTC (rev 103452)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHolder.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -37,6 +37,10 @@
    /** serialVersionUID */
    private static final long serialVersionUID = 3546645408219542832L;
    
+   private static final AnnotationValue[] EMPTY_ANNOTATIONS_ARRAY = new AnnotationValue[0];
+   
+   private static final HashMap<String, AnnotationValue> EMPTY_ANNOTATION_MAP = new HashMap<String, AnnotationValue>();
+   
    /** The annotations */
    protected AnnotationValue[] annotationsArray;
 
@@ -94,5 +98,10 @@
             annotationMap.put(type.getName(), annotations[i]);
          }
       }
+      else
+      {
+         annotationMap = EMPTY_ANNOTATION_MAP;
+         annotationsArray = EMPTY_ANNOTATIONS_ARRAY;
+      }
    }
 }

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java	2010-04-01 17:25:40 UTC (rev 103452)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotatedInfo.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -41,6 +41,10 @@
 
    final static AnnotationValue[] NOT_CONFIGURED = new AnnotationValue[0];
 
+   private static final AnnotationValue[] EMPTY_ANNOTATIONS_ARRAY = new AnnotationValue[0];
+   
+   private static final HashMap<String, AnnotationValue> EMPTY_ANNOTATION_MAP = new HashMap<String, AnnotationValue>();
+
    /** The annotations */
    protected AnnotationValue[] annotationsArray = NOT_CONFIGURED;
 
@@ -70,6 +74,8 @@
    public AnnotationValue getAnnotation(String name)
    {
       getAnnotations();
+      if (annotationMap == null)
+         return null;
       return annotationMap.get(name);
    }
 
@@ -96,6 +102,11 @@
             annotationMap.put(type.getName(), annotations[i]);
          }
       }
+      else
+      {
+         annotationMap = EMPTY_ANNOTATION_MAP;
+         annotationsArray = EMPTY_ANNOTATIONS_ARRAY;
+      }
    }
    
 }

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java	2010-04-01 17:25:40 UTC (rev 103452)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistInheritableAnnotationHolder.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -104,6 +104,7 @@
    {
       JavassistInheritableAnnotationHolder superHolder = getSuperHolder();
       AnnotationValue[] superAllAnnotations = (superHolder != null) ? superHolder.getAnnotations() : null;
+      allAnnotations = new HashMap<String, AnnotationValue>();
 
       if (annotations != null && annotations.length > 0)
       {
@@ -113,7 +114,6 @@
          {
             annotationMap.put(annotations[i].getAnnotationType().getName(), annotations[i]);
          }
-         allAnnotations = new HashMap<String, AnnotationValue>();
 
          if (superHolder != null && superAllAnnotations != null && superAllAnnotations.length != 0)
          {
@@ -132,21 +132,24 @@
          for (int i = 0; i < annotations.length; i++)
             allAnnotations.put(annotations[i].getAnnotationType().getName(), annotations[i]);
 
-         allAnnotationsArray = allAnnotations.values().toArray(new AnnotationValue[allAnnotations.size()]);
       }
       else
       {
-         if (superHolder != null)
+         if (superHolder != null && superAllAnnotations.length > 0)
          {
-            allAnnotations = superHolder.getAllAnnotations();
-            allAnnotationsArray = superAllAnnotations;
+            for (int i = 0 ; i < superAllAnnotations.length ; i++)
+            {
+               AnnotationValue av = superAllAnnotations[i];
+               if (av.getAnnotationType().isAnnotationPresent(INHERITED_NAME))
+               {
+                  allAnnotations.put(av.getAnnotationType().getName(), av);
+               }
+            }
          }
-         else
-         {
-            allAnnotations = new HashMap<String, AnnotationValue>();
-         }
       }
+      allAnnotationsArray = allAnnotations.values().toArray(new AnnotationValue[allAnnotations.size()]);
    }
+   
 
    /**
     * Get all the annotations as a map

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/AnnotatedInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/AnnotatedInfo.java	2010-04-01 17:25:40 UTC (rev 103452)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/spi/AnnotatedInfo.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -36,7 +36,7 @@
    /**
     * Get the annotations
     * 
-    * @return the annotations
+    * @return the annotations. If there are no annotations a zero length array is returned
     */
    AnnotationValue[] getAnnotations();
    
@@ -44,7 +44,7 @@
     * Get an annotation
     * 
     * @param name the name
-    * @return the annotation
+    * @return the annotation or null if it is not there
     */
    AnnotationValue getAnnotation(String name);
    
@@ -59,7 +59,7 @@
    /**
     * Get the underlying annotations
     * 
-    * @return the annotations
+    * @return the annotations. If there are no annotations a zero length array is returned
     */
    Annotation[] getUnderlyingAnnotations();
    
@@ -68,7 +68,7 @@
     *
     * @param <T> the annotation type
     * @param annotationType the annotationType
-    * @return the annotation
+    * @return the annotation or null if it is not there
     */
    <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType);
    

Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithInheritedAnnotations.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithInheritedAnnotations.java	                        (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithInheritedAnnotations.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classinfo.support;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedClassHierarchyWithInheritedAnnotations
+{
+   @Test1
+   public static class A
+   {
+      
+   }
+   
+   public static class B extends A
+   {
+      
+   }
+   
+   @Test2
+   public static class C extends B
+   {
+      
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   @Inherited
+   public @interface Test1
+   {
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   public @interface Test2
+   {
+   }
+   
+}

Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations.java	                        (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classinfo.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedClassHierarchyWithNotInheritedAnnotations
+{
+   @Test
+   public static class A
+   {
+      
+   }
+   
+   public static class B extends A
+   {
+      
+   }
+   
+   @Test
+   public static class C extends B
+   {
+      
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   public @interface Test
+   {
+      
+   }
+}

Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations2.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations2.java	                        (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/AnnotatedClassHierarchyWithNotInheritedAnnotations2.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classinfo.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedClassHierarchyWithNotInheritedAnnotations2
+{
+   @Test1
+   public static class A
+   {
+      
+   }
+   
+   @Test2
+   public static class B extends A
+   {
+      
+   }
+   
+   @Test3
+   public static class C extends B
+   {
+      
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   public @interface Test1
+   {
+      
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   public @interface Test2
+   {
+      
+   }
+   
+   @Retention(RetentionPolicy.RUNTIME)
+   public @interface Test3
+   {
+      
+   }
+}

Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/NoAnnotationsBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/NoAnnotationsBean.java	                        (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/NoAnnotationsBean.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classinfo.support;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoAnnotationsBean
+{
+   int field;
+   
+   public NoAnnotationsBean()
+   {
+      
+   }
+   
+   public void method()
+   {
+      
+   }
+}

Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java	2010-04-01 17:25:40 UTC (rev 103452)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java	2010-04-01 18:11:20 UTC (rev 103453)
@@ -22,6 +22,7 @@
 package org.jboss.test.classinfo.test;
 
 import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
 import java.util.HashSet;
 
 import org.jboss.reflect.spi.AnnotatedInfo;
@@ -44,6 +45,9 @@
 import org.jboss.reflect.spi.Value;
 import org.jboss.test.ContainerTest;
 import org.jboss.test.classinfo.support.AnnotatedClass;
+import org.jboss.test.classinfo.support.AnnotatedClassHierarchyWithInheritedAnnotations;
+import org.jboss.test.classinfo.support.AnnotatedClassHierarchyWithNotInheritedAnnotations;
+import org.jboss.test.classinfo.support.AnnotatedClassHierarchyWithNotInheritedAnnotations2;
 import org.jboss.test.classinfo.support.AnnotatedSubClass;
 import org.jboss.test.classinfo.support.AnnotationWithClass;
 import org.jboss.test.classinfo.support.AnotherAnnotation;
@@ -54,6 +58,7 @@
 import org.jboss.test.classinfo.support.ExpectedAnnotations;
 import org.jboss.test.classinfo.support.JDK14ExpectedAnnotations;
 import org.jboss.test.classinfo.support.JDK50ExpectedAnnotations;
+import org.jboss.test.classinfo.support.NoAnnotationsBean;
 import org.jboss.test.classinfo.support.SimpleAnnotation;
 import org.jboss.test.classinfo.support.TestEnum;
 import org.jboss.test.classinfo.support.ValueAnnotation;
@@ -323,6 +328,117 @@
       checkAnnotationWithClassAnnotation(info, Comparable[][].class);
    }
 
+   public void testNoAnnotations() throws Throwable
+   {
+      ClassInfo info = assertInstanceOf(getTypeInfoFactory().getTypeInfo(NoAnnotationsBean.class), ClassInfo.class);
+      checkNoAnnotations(info);
+      
+      for (FieldInfo finfo : info.getDeclaredFields())
+         checkNoAnnotations(finfo);
+      for (ConstructorInfo cinfo : info.getDeclaredConstructors())
+         checkNoAnnotations(cinfo);
+      for (MethodInfo minfo : info.getDeclaredMethods())
+         checkNoAnnotations(minfo);
+   }
+   
+   public void testAnnotatedHierarchyNotInheritedNoAnnotationsMiddle() throws Throwable
+   {
+      ClassInfo infoA = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations.A.class), ClassInfo.class);
+      checkAnnotations(infoA, AnnotatedClassHierarchyWithNotInheritedAnnotations.Test.class);
+      
+      ClassInfo infoB =  assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations.B.class), ClassInfo.class);
+      checkNoAnnotations(infoB);
+      
+      ClassInfo infoC = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations.C.class), ClassInfo.class);
+      checkAnnotations(infoC, AnnotatedClassHierarchyWithNotInheritedAnnotations.Test.class);
+   }
+
+   public void testAnnotatedHierarchyNotInheritedAnnotationsAllLevels() throws Throwable
+   {
+      ClassInfo infoA = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations2.A.class), ClassInfo.class);
+      checkAnnotations(infoA, AnnotatedClassHierarchyWithNotInheritedAnnotations2.Test1.class);
+      
+      ClassInfo infoB =  assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations2.B.class), ClassInfo.class);
+      checkAnnotations(infoB, AnnotatedClassHierarchyWithNotInheritedAnnotations2.Test2.class);
+      
+      ClassInfo infoC = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithNotInheritedAnnotations2.C.class), ClassInfo.class);
+      checkAnnotations(infoC, AnnotatedClassHierarchyWithNotInheritedAnnotations2.Test3.class);
+   }
+
+   public void testAnnotatedHierarchyInherited() throws Throwable
+   {
+      ClassInfo infoA = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithInheritedAnnotations.A.class), ClassInfo.class);
+      checkAnnotations(infoA, AnnotatedClassHierarchyWithInheritedAnnotations.Test1.class);
+      
+      ClassInfo infoB =  assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithInheritedAnnotations.B.class), ClassInfo.class);
+      checkAnnotations(infoB, AnnotatedClassHierarchyWithInheritedAnnotations.Test1.class);
+      
+      ClassInfo infoC = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithInheritedAnnotations.C.class), ClassInfo.class);
+      checkAnnotations(infoC, AnnotatedClassHierarchyWithInheritedAnnotations.Test1.class, AnnotatedClassHierarchyWithInheritedAnnotations.Test2.class);
+   }
+
+   private void checkNoAnnotations(AnnotatedInfo info)
+   {
+      assertNull(info.getAnnotation("x"));
+      
+      assertNotNull(info.getAnnotations());
+      assertEquals(0, info.getAnnotations().length);
+      
+      assertFalse(info.isAnnotationPresent("x"));
+      assertFalse(info.isAnnotationPresent(Documented.class));
+      
+      assertNull(info.getUnderlyingAnnotation(Documented.class));
+      assertNotNull(info.getUnderlyingAnnotations());
+      assertEquals(0, info.getUnderlyingAnnotations().length);
+   }
+   
+   private void checkAnnotations(AnnotatedInfo info, Class<? extends Annotation>...expectedAnnotations)
+   {
+      AnnotationValue[] values = info.getAnnotations();
+      Annotation[] anns = info.getUnderlyingAnnotations();
+      assertEquals(expectedAnnotations.length, values.length);
+      assertEquals(expectedAnnotations.length, anns.length);
+      
+      for (Class<? extends Annotation> expected : expectedAnnotations)
+      {
+         AnnotationValue annVal = info.getAnnotation(expected.getName());
+         assertNotNull(annVal);
+         assertEquals(annVal.getAnnotationType().getName(), expected.getName());
+         
+         assertTrue(info.isAnnotationPresent(expected.getName()));
+         assertTrue(info.isAnnotationPresent(expected));
+         
+         assertNotNull(values);
+         assertTrue(values.length > 0);
+         boolean found = false;
+         for (AnnotationValue value : values)
+         {
+            if (value.getAnnotationType().getName().equals(expected.getName()))
+            {
+               found = true;
+               break;
+            }
+         }
+         assertTrue("Could not find @" + expected.getSimpleName(), found);
+         
+         assertNotNull(info.getUnderlyingAnnotation(expected));
+         assertInstanceOf(info.getUnderlyingAnnotation(expected), expected);
+         
+         assertNotNull(anns);
+         assertTrue(anns.length > 0);
+         found = false;
+         for (Annotation ann : anns)
+         {
+            if (ann.annotationType() == expected)
+            {
+               found = true;
+               break;
+            }
+         }
+         assertTrue("Could not find @" + expected.getSimpleName(), found);
+      }
+   }
+   
    private void checkAnnotationWithClassAnnotation(ClassInfo info, Class<?> clazz) throws Exception
    {
       AnnotationValue[] annotations = info.getAnnotations();




More information about the jboss-cvs-commits mailing list