camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r996050 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/file/ main/java/org/apache/camel/converter/ main/java/org/apache/camel/model/ test/java/org/apache/camel/processor/
Date Sat, 11 Sep 2010 03:22:00 GMT
Author: ningjiang
Date: Sat Sep 11 03:21:58 2010
New Revision: 996050

URL: http://svn.apache.org/viewvc?rev=996050&view=rev
Log:
CAMEL-3116 Validate the charset of the ConvertBodyTo DSL

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=996050&r1=996049&r2=996050&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
Sat Sep 11 03:21:58 2010
@@ -286,7 +286,7 @@ public abstract class GenericFileEndpoin
     }
     
     public void setCharset(String charset) {
-        IOConverter.isValidateCharset(charset);
+        IOConverter.validateCharset(charset);
         this.charset = charset;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java?rev=996050&r1=996049&r2=996050&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java Sat Sep
11 03:21:58 2010
@@ -409,7 +409,7 @@ public final class IOConverter {
         }
     }
     
-    public static void isValidateCharset(String charset) throws UnsupportedCharsetException
{
+    public static void validateCharset(String charset) throws UnsupportedCharsetException
{
         if (charset != null) {
             if (Charset.isSupported(charset)) {
                 Charset.forName(charset);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyDefinition.java?rev=996050&r1=996049&r2=996050&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyDefinition.java
Sat Sep 11 03:21:58 2010
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlTran
 
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.converter.IOConverter;
 import org.apache.camel.processor.ConvertBodyProcessor;
 import org.apache.camel.spi.RouteContext;
 
@@ -110,6 +111,7 @@ public class ConvertBodyDefinition exten
     }
 
     public void setCharset(String charset) {
+        IOConverter.validateCharset(charset);
         this.charset = charset;
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java?rev=996050&r1=996049&r2=996050&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java Sat
Sep 11 03:21:58 2010
@@ -17,6 +17,7 @@
 package org.apache.camel.processor;
 
 import java.io.ByteArrayInputStream;
+import java.nio.charset.UnsupportedCharsetException;
 import java.util.Date;
 import java.util.Locale;
 
@@ -28,6 +29,21 @@ import org.apache.camel.component.mock.M
 import org.apache.camel.util.ObjectHelper;
 
 public class ConvertBodyTest extends ContextTestSupport {
+    
+    public void testConvertBodyTo() {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                public void configure() {
+                    // set an invalid charset
+                    from("direct:invalid").convertBodyTo(String.class, "ASSI").to("mock:endpoint");
+                }
+            });
+            fail("Except an exception here ");
+        } catch (Exception ex) {
+            assertTrue("Get a wrong exception", ex instanceof UnsupportedCharsetException);
+        }
+        
+    }
 
     public void testConvertToInteger() throws Exception {
         MockEndpoint result = getMockEndpoint("mock:result");



Mime
View raw message