[jboss-cvs] container/src/tests/org/jboss/test/classinfo/test ...
Kabir Khan
kkhan at jboss.com
Tue Jul 18 07:23:49 EDT 2006
User: kkhan
Date: 06/07/18 07:23:49
Modified: src/tests/org/jboss/test/classinfo/test
AnnotatedClassInfoTest.java
Added: src/tests/org/jboss/test/classinfo/test
JDK50ExpectedAnnotations.java
ExpectedAnnotations.java
JDK14ExpectedAnnotations.java
Log:
Move annotation creator into container from aop module
Use jboss retro to create a JDK 1.4 dist and test under JDK 1,4.
Revision Changes Path
1.4 +31 -9 container/src/tests/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AnnotatedClassInfoTest.java
===================================================================
RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- AnnotatedClassInfoTest.java 23 Jun 2006 10:07:22 -0000 1.3
+++ AnnotatedClassInfoTest.java 18 Jul 2006 11:23:49 -0000 1.4
@@ -21,9 +21,6 @@
*/
package org.jboss.test.classinfo.test;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
import java.util.HashSet;
import org.jboss.reflect.spi.AnnotatedInfo;
@@ -56,15 +53,39 @@
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public abstract class AnnotatedClassInfoTest extends ContainerTest
{
- final static Class[] EXPECTED_ANNOTATIONS = {SimpleAnnotation.class, ComplexAnnotation.class};
- final static Class[] ANNOTATION_EXPECTED_ANNOTATIONS = {Target.class, Retention.class, Inherited.class};
- final static Class[] COMPLEXANNOTATION_EXPECTED_ANNOTATIONS = {Target.class, Retention.class, SimpleAnnotation.class, ValueAnnotation.class};
- final static Class[] FIRST_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, ComplexAnnotation.class};
- final static Class[] SECOND_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, SimpleAnnotation.class};
+ /** <code>@Retention</code> and <code>@Target</code> are ignored for JDK 1.4 */
+ final static ExpectedAnnotations expected;
+ static
+ {
+ boolean haveJDK5 = false;
+ try
+ {
+ Class.forName("java.lang.annotation.Target");
+ haveJDK5 = true;
+ }
+ catch(Exception e)
+ {
+ }
+
+ if (haveJDK5)
+ {
+ expected = new JDK50ExpectedAnnotations();
+ }
+ else
+ {
+ expected = new JDK14ExpectedAnnotations();
+ }
+ }
+ final static Class[] EXPECTED_ANNOTATIONS = expected.getEspectedAnnotations();
+ final static Class[] ANNOTATION_EXPECTED_ANNOTATIONS = expected.getAnnotationExpectedAnnotations();
+ final static Class[] COMPLEXANNOTATION_EXPECTED_ANNOTATIONS = expected.getComplexExpectedAnnotations();
+ final static Class[] FIRST_PARAM_EXPECTED_ANNOTATIONS = expected.getFirstParamExpectedAnnotations();
+ final static Class[] SECOND_PARAM_EXPECTED_ANNOTATIONS = expected.getSecondParamExpectedAnnotations();
+
final static ExpectedComplexAnnotationData CLASS_DATA =
new ExpectedComplexAnnotationData(
@@ -147,6 +168,7 @@
{
ClassInfo info = getClassInfo(AnnotatedSubClass.class);
+ System.out.println("---> Getting annotations");
AnnotationValue[] annotations = info.getAnnotations();
assertEquals(2, annotations.length);
AnnotationValue anotherAnnotation = getAnnotationCheckTypeAndName(info, AnotherAnnotation.class.getName());
1.1 date: 2006/07/18 11:23:49; author: kkhan; state: Exp;container/src/tests/org/jboss/test/classinfo/test/JDK50ExpectedAnnotations.java
Index: JDK50ExpectedAnnotations.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.test;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.jboss.test.classinfo.support.ComplexAnnotation;
import org.jboss.test.classinfo.support.SimpleAnnotation;
import org.jboss.test.classinfo.support.ValueAnnotation;
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class JDK50ExpectedAnnotations extends ExpectedAnnotations
{
final static Class[] EXPECTED_ANNOTATIONS = {SimpleAnnotation.class, ComplexAnnotation.class};
final static Class[] ANNOTATION_EXPECTED_ANNOTATIONS = {Target.class, Retention.class, Inherited.class};
final static Class[] COMPLEXANNOTATION_EXPECTED_ANNOTATIONS = {Target.class, Retention.class, SimpleAnnotation.class, ValueAnnotation.class};
final static Class[] FIRST_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, ComplexAnnotation.class};
final static Class[] SECOND_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, SimpleAnnotation.class};
public Class[] getAnnotationExpectedAnnotations()
{
return ANNOTATION_EXPECTED_ANNOTATIONS;
}
public Class[] getComplexExpectedAnnotations()
{
return COMPLEXANNOTATION_EXPECTED_ANNOTATIONS;
}
public Class[] getEspectedAnnotations()
{
return EXPECTED_ANNOTATIONS;
}
public Class[] getFirstParamExpectedAnnotations()
{
return FIRST_PARAM_EXPECTED_ANNOTATIONS;
}
public Class[] getSecondParamExpectedAnnotations()
{
return SECOND_PARAM_EXPECTED_ANNOTATIONS;
}
}
1.1 date: 2006/07/18 11:23:49; author: kkhan; state: Exp;container/src/tests/org/jboss/test/classinfo/test/ExpectedAnnotations.java
Index: ExpectedAnnotations.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.test;
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public abstract class ExpectedAnnotations
{
public abstract Class[] getAnnotationExpectedAnnotations();
public abstract Class[] getComplexExpectedAnnotations();
public abstract Class[] getEspectedAnnotations();
public abstract Class[] getFirstParamExpectedAnnotations();
public abstract Class[] getSecondParamExpectedAnnotations();
}
1.1 date: 2006/07/18 11:23:49; author: kkhan; state: Exp;container/src/tests/org/jboss/test/classinfo/test/JDK14ExpectedAnnotations.java
Index: JDK14ExpectedAnnotations.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.test;
import java.lang.annotation.Inherited;
import org.jboss.test.classinfo.support.ComplexAnnotation;
import org.jboss.test.classinfo.support.SimpleAnnotation;
import org.jboss.test.classinfo.support.ValueAnnotation;
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class JDK14ExpectedAnnotations extends ExpectedAnnotations
{
final static Class[] EXPECTED_ANNOTATIONS = {SimpleAnnotation.class, ComplexAnnotation.class};
final static Class[] ANNOTATION_EXPECTED_ANNOTATIONS = {Inherited.class};
final static Class[] COMPLEXANNOTATION_EXPECTED_ANNOTATIONS = {SimpleAnnotation.class, ValueAnnotation.class};
final static Class[] FIRST_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, ComplexAnnotation.class};
final static Class[] SECOND_PARAM_EXPECTED_ANNOTATIONS = {ValueAnnotation.class, SimpleAnnotation.class};
public Class[] getAnnotationExpectedAnnotations()
{
return ANNOTATION_EXPECTED_ANNOTATIONS;
}
public Class[] getComplexExpectedAnnotations()
{
return COMPLEXANNOTATION_EXPECTED_ANNOTATIONS;
}
public Class[] getEspectedAnnotations()
{
return EXPECTED_ANNOTATIONS;
}
public Class[] getFirstParamExpectedAnnotations()
{
return FIRST_PARAM_EXPECTED_ANNOTATIONS;
}
public Class[] getSecondParamExpectedAnnotations()
{
return SECOND_PARAM_EXPECTED_ANNOTATIONS;
}
}
More information about the jboss-cvs-commits
mailing list