[jboss-cvs] JBossAS SVN: r68391 - in projects/microcontainer/trunk/container/src: tests/org/jboss/test/annotation/factory/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 18 18:54:19 EST 2007
Author: alesj
Date: 2007-12-18 18:54:19 -0500 (Tue, 18 Dec 2007)
New Revision: 68391
Added:
projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTestSuite.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/annotation/factory/AnnotationProxy.java
projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java
Log:
AnnotationProxy serializable fix.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/annotation/factory/AnnotationProxy.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/annotation/factory/AnnotationProxy.java 2007-12-18 23:27:05 UTC (rev 68390)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/annotation/factory/AnnotationProxy.java 2007-12-18 23:54:19 UTC (rev 68391)
@@ -49,23 +49,24 @@
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
- if (method.getName().equals("equals"))
+ String name = method.getName();
+ if ("equals".equals(name))
{
return doEquals(proxy, args[0]);
}
- else if (method.getName().equals("hashCode"))
+ else if ("hashCode".equals(name))
{
return doHashCode();
}
- else if (method.getName().equals("toString"))
+ else if ("toString".equals(name))
{
return map.toString();
}
- else if (method.getName().equals("annotationType"))
+ else if ("annotationType".equals(name))
{
return annotationType;
}
-
+
/*
Object obj = map.get(method.getName());
if (!method.getReturnType().equals(obj.getClass()))
@@ -74,14 +75,14 @@
}
return obj;
*/
- return map.get(method.getName());
+ return map.get(name);
}
public Object getValue(String name)
{
return map.get(name);
}
-
+
@SuppressWarnings("unchecked")
private Object doEquals(Object proxy, Object obj)
{
@@ -91,7 +92,7 @@
return Boolean.FALSE;
Class[] intfs = proxy.getClass().getInterfaces();
- if (!intfs[0].isAssignableFrom(obj.getClass()))
+ if (intfs[0].isAssignableFrom(obj.getClass()) == false)
{
return Boolean.FALSE;
}
@@ -114,9 +115,9 @@
/**
* Create a proxy implementation for the annotation class.
* @param map - map of the annotation values
- * @param annotation - the annotation class
- * @return an instance implementing the annotation
- * @throws Exception
+ * @param annotation - the annotation class
+ * @return an instance implementing the annotation
+ * @throws Exception for any error
*/
public static Object createProxy(Map map, Class annotation) throws Exception
{
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java 2007-12-18 23:27:05 UTC (rev 68390)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java 2007-12-18 23:54:19 UTC (rev 68391)
@@ -22,6 +22,7 @@
package org.jboss.test.annotation.factory.test;
import java.lang.annotation.Annotation;
+import java.io.Serializable;
import org.jboss.annotation.factory.AnnotationCreator;
import org.jboss.annotation.factory.AnnotationValidationException;
@@ -77,7 +78,17 @@
assertEquals(new String[]{"Test", "123"}, complex.array());
assertEquals(MyEnum.TWO, complex.enumVal());
}
-
+
+ public void testSerializable() throws Exception
+ {
+ String expr = "@org.jboss.test.annotation.factory.support.Complex(ch='a', string=\"Test123\", flt=9.9, dbl=123456789.99, shrt=1, lng=987654321, integer=123, bool=true, annotation=@org.jboss.test.annotation.factory.support.SimpleValue(\"Yes\"), array={\"Test\", \"123\"}, clazz=java.lang.Long.class, enumVal=org.jboss.test.annotation.factory.support.MyEnum.TWO)";
+ Annotation annotation = (Annotation)AnnotationCreator.createAnnotation(expr, Complex.class);
+ assertInstanceOf(annotation, Serializable.class);
+ byte[] bytes = serialize((Serializable)annotation);
+ Object desAnn = deserialize(bytes);
+ assertEquals(annotation, desAnn);
+ }
+
public void testMissingAttributeAndNoDefault() throws Exception
{
try
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/annotation/factory/test/AnnotationCreatorTestSuite.java 2007-12-18 23:54:19 UTC (rev 68391)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.annotation.factory.test;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.textui.TestRunner;
+
+/**
+ * Annotation creator tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationCreatorTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Annotation Creator tests");
+
+ suite.addTest(JavassistAnnotationCreatorTestCase.suite());
+ suite.addTest(NoJavassistAnnotationCreatorTestCase.suite());
+
+ return suite;
+ }
+}
+
More information about the jboss-cvs-commits
mailing list