[jboss-cvs] JBossAS SVN: r106929 - in projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 20 12:21:19 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-07-20 12:21:18 -0400 (Tue, 20 Jul 2010)
New Revision: 106929

Added:
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoParameterAnnotationsNotAllParametersAnnotated.java
Modified:
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
Log:
[JBREFLECT-135] Test parameter annotations when not all parameters for a method/constructor are annotated

Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoParameterAnnotationsNotAllParametersAnnotated.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoParameterAnnotationsNotAllParametersAnnotated.java	                        (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoParameterAnnotationsNotAllParametersAnnotated.java	2010-07-20 16:21:18 UTC (rev 106929)
@@ -0,0 +1,40 @@
+/*
+* 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 ClassInfoParameterAnnotationsNotAllParametersAnnotated
+{
+   public ClassInfoParameterAnnotationsNotAllParametersAnnotated(@SimpleAnnotation int i, int j)
+   {
+      
+   }
+   
+   public void method(@SimpleAnnotation int i, int j)
+   {
+      
+   }
+}

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-07-20 16:19:35 UTC (rev 106928)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java	2010-07-20 16:21:18 UTC (rev 106929)
@@ -51,6 +51,7 @@
 import org.jboss.test.classinfo.support.AnnotatedSubClass;
 import org.jboss.test.classinfo.support.AnnotationWithClass;
 import org.jboss.test.classinfo.support.AnotherAnnotation;
+import org.jboss.test.classinfo.support.ClassInfoParameterAnnotationsNotAllParametersAnnotated;
 import org.jboss.test.classinfo.support.ClassWithAnnotationWithClass;
 import org.jboss.test.classinfo.support.ClassWithAnnotationWithClassArray;
 import org.jboss.test.classinfo.support.ClassWithAnnotationWithInterfaceArray;
@@ -384,6 +385,28 @@
       ClassInfo infoC = assertInstanceOf(getTypeInfoFactory().getTypeInfo(AnnotatedClassHierarchyWithInheritedAnnotations.C.class), ClassInfo.class);
       checkAnnotations(infoC, AnnotatedClassHierarchyWithInheritedAnnotations.Test1.class, AnnotatedClassHierarchyWithInheritedAnnotations.Test2.class);
    }
+   
+   public void testParameterAnnotationsNotAllParametersAnnotated() throws Throwable
+   {
+      ClassInfo info = assertInstanceOf(getTypeInfoFactory().getTypeInfo(ClassInfoParameterAnnotationsNotAllParametersAnnotated.class), ClassInfo.class);
+      
+      ConstructorInfo[] constructors = info.getDeclaredConstructors();
+      assertEquals(1, constructors.length);
+      ParameterInfo[] constructorParams = constructors[0].getParameters();
+      assertEquals(2, constructorParams.length);
+      assertEquals(0, constructorParams[1].getAnnotations().length);
+      assertEquals(1, constructorParams[0].getAnnotations().length);
+      assertSame(getTypeInfoFactory().getTypeInfo(SimpleAnnotation.class), constructorParams[0].getAnnotations()[0].getAnnotationType());
+      
+      
+      MethodInfo[] methods = info.getDeclaredMethods();
+      assertEquals(1, methods.length);
+      ParameterInfo[] methodParams = methods[0].getParameters();
+      assertEquals(2, methodParams.length);
+      assertEquals(0, methodParams[1].getAnnotations().length);
+      assertEquals(1, methodParams[0].getAnnotations().length);
+      assertSame(getTypeInfoFactory().getTypeInfo(SimpleAnnotation.class), methodParams[0].getAnnotations()[0].getAnnotationType());
+   }
 
    private void checkNoAnnotations(AnnotatedInfo info)
    {



More information about the jboss-cvs-commits mailing list