camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1443644 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/util/ObjectHelper.java test/java/org/apache/camel/impl/DefaultClassResolverTest.java
Date Thu, 07 Feb 2013 18:30:56 GMT
Author: davsclaus
Date: Thu Feb  7 18:30:56 2013
New Revision: 1443644

URL: http://svn.apache.org/r1443644
Log:
CAMEL-6051: Added more simple type converters to array types to default class resolver, so
you can convert to Object[] etc.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1443644&r1=1443643&r2=1443644&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Thu Feb 
7 18:30:56 2013
@@ -799,9 +799,15 @@ public final class ObjectHelper {
      * @return the class or <tt>null</tt> if it could not be loaded
      */
     public static Class<?> loadSimpleType(String name) {
-        // special for byte[] as its common to use
+        // special for byte[] or Object[] as its common to use
         if ("java.lang.byte[]".equals(name) || "byte[]".equals(name)) {
             return byte[].class;
+        } else if ("java.lang.Byte[]".equals(name) || "Byte[]".equals(name)) {
+            return Byte[].class;
+        } else if ("java.lang.Object[]".equals(name) || "Object[]".equals(name)) {
+            return Object[].class;
+        } else if ("java.lang.String[]".equals(name) || "String[]".equals(name)) {
+            return String[].class;
         // and these is common as well
         } else if ("java.lang.String".equals(name) || "String".equals(name)) {
             return String.class;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java?rev=1443644&r1=1443643&r2=1443644&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
Thu Feb  7 18:30:56 2013
@@ -62,6 +62,40 @@ public class DefaultClassResolverTest ex
         assertNotNull(clazz);
     }
 
+    public void testResolveMandatorySimpleClassType()throws Exception {
+        DefaultClassResolver resolver = new DefaultClassResolver();
+
+        Class<Byte> clazz = resolver.resolveMandatoryClass("Byte", Byte.class);
+        assertNotNull(clazz);
+        clazz = resolver.resolveMandatoryClass("java.lang.Byte", Byte.class);
+        assertNotNull(clazz);
+
+        Class<Long> clazz2 = resolver.resolveMandatoryClass("Long", Long.class);
+        assertNotNull(clazz2);
+        clazz2 = resolver.resolveMandatoryClass("java.lang.Long", Long.class);
+        assertNotNull(clazz2);
+
+        Class<String> clazz3 = resolver.resolveMandatoryClass("String", String.class);
+        assertNotNull(clazz3);
+        clazz3 = resolver.resolveMandatoryClass("java.lang.String", String.class);
+        assertNotNull(clazz3);
+
+        Class<Byte[]> clazz4 = resolver.resolveMandatoryClass("Byte[]", Byte[].class);
+        assertNotNull(clazz4);
+        clazz4 = resolver.resolveMandatoryClass("java.lang.Byte[]", Byte[].class);
+        assertNotNull(clazz4);
+
+        Class<Object[]> clazz5 = resolver.resolveMandatoryClass("Object[]", Object[].class);
+        assertNotNull(clazz5);
+        clazz5 = resolver.resolveMandatoryClass("java.lang.Object[]", Object[].class);
+        assertNotNull(clazz5);
+
+        Class<String[]> clazz6 = resolver.resolveMandatoryClass("String[]", String[].class);
+        assertNotNull(clazz6);
+        clazz6 = resolver.resolveMandatoryClass("java.lang.String[]", String[].class);
+        assertNotNull(clazz6);
+    }
+
     public void testResolveMandatoryClassClassLoader() throws Exception {
         DefaultClassResolver resolver = new DefaultClassResolver();
         Class<?> clazz = resolver.resolveMandatoryClass("java.lang.Integer", DefaultClassResolverTest.class.getClassLoader());



Mime
View raw message