[jboss-cvs] JBossAS SVN: r104938 - in projects/jboss-reflect/branches/Branch_2_0/src: test/java/org/jboss/test/classinfo/support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 18 12:23:34 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-05-18 12:23:33 -0400 (Tue, 18 May 2010)
New Revision: 104938

Added:
   projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/support/CustomValueOf.java
   projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/CustomValueValueOfTest.java
   projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/IntrospectionCustomValueValueOfTestCase.java
   projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/JavassistCustomValueValueOfTestCase.java
Modified:
   projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ValueConvertor.java
Log:
[JBREFLECT-88] Port to Branch_2_0

Modified: projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ValueConvertor.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ValueConvertor.java	2010-05-18 16:06:50 UTC (rev 104937)
+++ projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ValueConvertor.java	2010-05-18 16:23:33 UTC (rev 104938)
@@ -148,7 +148,7 @@
          int modifiers = method.getModifiers();
          if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)
                && clazz.isAssignableFrom(method.getReturnType()))
-            return ReflectionUtils.invoke(null, method, new Object[]{value});
+            return ReflectionUtils.invoke(method, null, new Object[]{value});
       }
       catch (Exception ignored)
       {

Copied: projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/support/CustomValueOf.java (from rev 98934, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/CustomValueOf.java)
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/support/CustomValueOf.java	                        (rev 0)
+++ projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/support/CustomValueOf.java	2010-05-18 16:23:33 UTC (rev 104938)
@@ -0,0 +1,48 @@
+/*
+* 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 CustomValueOf
+{
+   String string;
+   
+   private CustomValueOf(String string)
+   {
+      super();
+      this.string = string;
+   }
+
+   public static CustomValueOf valueOf(String string)
+   {
+      return new CustomValueOf(string);
+   }
+
+   public String getString()
+   {
+      return string;
+   }
+}

Copied: projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/CustomValueValueOfTest.java (from rev 98934, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/CustomValueValueOfTest.java)
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/CustomValueValueOfTest.java	                        (rev 0)
+++ projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/CustomValueValueOfTest.java	2010-05-18 16:23:33 UTC (rev 104938)
@@ -0,0 +1,50 @@
+/*
+* 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.test;
+
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.classinfo.support.CustomValueOf;
+
+
+/**
+ * Tests that public static XXX.valueOf(Object o) is called when calling ClassInfo.convertValue()
+ *  
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CustomValueValueOfTest extends AbstractClassInfoTest
+{
+   public CustomValueValueOfTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testCustomValueOf() throws Throwable
+   {
+      TypeInfo info = getTypeInfoFactory().getTypeInfo(CustomValueOf.class);
+      Object value = info.convertValue("1234");
+      assertNotNull(value);
+      assertInstanceOf(value, CustomValueOf.class);
+      assertEquals("1234", ((CustomValueOf)value).getString());
+   }
+
+}

Added: projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/IntrospectionCustomValueValueOfTestCase.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/IntrospectionCustomValueValueOfTestCase.java	                        (rev 0)
+++ projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/IntrospectionCustomValueValueOfTestCase.java	2010-05-18 16:23:33 UTC (rev 104938)
@@ -0,0 +1,44 @@
+/*
+* 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.test;
+
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class IntrospectionCustomValueValueOfTestCase extends CustomValueValueOfTest
+{
+   public IntrospectionCustomValueValueOfTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected TypeInfoFactory getTypeInfoFactory()
+   {
+      return new IntrospectionTypeInfoFactory();
+   }
+}

Added: projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/JavassistCustomValueValueOfTestCase.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/JavassistCustomValueValueOfTestCase.java	                        (rev 0)
+++ projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/classinfo/test/JavassistCustomValueValueOfTestCase.java	2010-05-18 16:23:33 UTC (rev 104938)
@@ -0,0 +1,44 @@
+/*
+* 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.test;
+
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistCustomValueValueOfTestCase extends CustomValueValueOfTest
+{
+   public JavassistCustomValueValueOfTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected TypeInfoFactory getTypeInfoFactory()
+   {
+      return new JavassistTypeInfoFactory();
+   }
+}




More information about the jboss-cvs-commits mailing list