camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r832723 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java test/java/org/apache/camel/converter/ConverterTest.java
Date Wed, 04 Nov 2009 12:26:46 GMT
Author: ningjiang
Date: Wed Nov  4 12:26:45 2009
New Revision: 832723

URL: http://svn.apache.org/viewvc?rev=832723&view=rev
Log:
CAMEL-2133 mandatoryConverterTo method should through exception when the value is null

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java?rev=832723&r1=832722&r2=832723&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
Wed Nov  4 12:26:45 2009
@@ -114,7 +114,7 @@
         } catch (Exception e) {
             throw new NoTypeConversionAvailableException(value, type, e);
         }
-        if (answer == Void.TYPE) {
+        if (answer == Void.TYPE || value == null) {
             // Could not find suitable conversion
             throw new NoTypeConversionAvailableException(value, type);
         } else {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java?rev=832723&r1=832722&r2=832723&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java Wed
Nov  4 12:26:45 2009
@@ -29,6 +29,7 @@
 import junit.framework.TestCase;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultClassResolver;
@@ -214,4 +215,17 @@
         assertEquals("converted using exchange", 5, bean.getFoo(), 5);
         assertEquals("converted using exchange", "foo-bar", bean.getBar());
     }
+    
+    public void testMandatoryConvertTo() {
+        
+        CamelContext camel = new DefaultCamelContext();
+        Exchange e = new DefaultExchange(camel);
+        try {
+            converter.mandatoryConvertTo(InputStream.class, null);
+            fail("Expect exception here");
+        } catch (Exception ex) {
+            assertTrue("Expect to get a NoTypeConversionAvailableException here", ex instanceof
NoTypeConversionAvailableException); 
+        }
+        
+    }
 }



Mime
View raw message