camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r583081 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java test/java/org/apache/camel/converter/ConverterTest.java
Date Tue, 09 Oct 2007 09:05:25 GMT
Author: jstrachan
Date: Tue Oct  9 02:05:24 2007
New Revision: 583081

URL: http://svn.apache.org/viewvc?rev=583081&view=rev
Log:
patch to resolve the String to Boolean issue raised by this discussion: http://www.nabble.com/Patch-to-convert-from-String-to-Boolean-tf4585300s22882.html

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java?rev=583081&r1=583080&r2=583081&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
Tue Oct  9 02:05:24 2007
@@ -178,6 +178,14 @@
                     }
                 }
             }
+
+            // lets test for Object based converters
+            if (!fromType.equals(Object.class)) {
+                TypeConverter converter = getTypeConverter(toType, Object.class);
+                if (converter != null) {
+                    return converter;
+                }
+            }
         }
 
         // lets try classes derived from this toType

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java?rev=583081&r1=583080&r2=583081&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
Tue Oct  9 02:05:24 2007
@@ -162,6 +162,17 @@
         assertEquals("bean.foo", 4, bean.getFoo());
     }
 
+    public void testStringToBoolean() throws Exception {
+        Boolean value = converter.convertTo(Boolean.class, "true");
+        assertEquals("converted boolean value", Boolean.TRUE, value);
+
+        value = converter.convertTo(Boolean.class, "false");
+        assertEquals("converted boolean value", Boolean.FALSE, value);
+
+        value = converter.convertTo(Boolean.class, null);
+        assertEquals("converted boolean value", null, value);
+    }
+
     public static class MyBean {
         private int foo;
 



Mime
View raw message