camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [33/50] [abbrv] git commit: CAMEL-7036 Fixed the issue of Camel XSD validation not working with apache xerces
Date Mon, 09 Dec 2013 02:11:37 GMT
CAMEL-7036 Fixed the issue of Camel XSD validation not working with apache xerces


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5dafb14
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5dafb14
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5dafb14

Branch: refs/heads/camel-gora
Commit: f5dafb1495fe307f6a5aeb4a4adbc85d478d77a9
Parents: 1c1d3a8
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Dec 4 12:51:50 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Dec 4 12:52:18 2013 +0800

----------------------------------------------------------------------
 .../processor/validation/ValidatingProcessor.java   |  5 ++---
 .../camel/processor/ValidatingProcessorTest.java    | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5dafb14/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
b/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
index bd9f783..200d0fe 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
@@ -130,13 +130,12 @@ public class ValidatingProcessor implements AsyncProcessor {
                 }
             }
 
+            //CAMEL-7036 We don't need to set the result if the source is an instance of
StreamSource
             if (source instanceof DOMSource) {
                 result = new DOMResult();
-            } else if (source instanceof StreamSource) {
-                result = new StreamResult(new StringWriter());
             } else if (source instanceof SAXSource) {
                 result = new SAXResult();
-            } else if (source instanceof StAXSource) {
+            } else if (source instanceof StAXSource || source instanceof StreamSource) {
                 result = null;
             }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f5dafb14/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
index 2b2175e..0726e2b 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
@@ -20,6 +20,7 @@ import java.io.File;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.StringSource;
 import org.apache.camel.ValidationException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -56,6 +57,21 @@ public class ValidatingProcessorTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
     }
+    
+    public void testStringSourceMessage() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:valid");
+        mock.expectedMessageCount(1);
+
+        String xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
+            + "<user xmlns=\"http://foo.com/bar\">"
+            + "  <id>1</id>"
+            + "  <username>davsclaus</username>"
+            + "</user>";
+
+        template.sendBody("direct:start", new StringSource(xml));
+
+        assertMockEndpointsSatisfied();
+    }
 
     public void testValidMessageTwice() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:valid");


Mime
View raw message