You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/01/30 09:10:51 UTC

[camel] branch master updated (9aec78c -> 29605cd)

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

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


    from 9aec78c  Sync deps
     new f53b7ad  Upgrade maven format plugin
     new 3cfb84e  CAMEL-16112: Fix camel-rest should create new instance of data formats. Thanks to Krzysztof Jamroz for reporting and unit test.
     new 29605cd  Upgrade impsort maven plugin

The 3 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:
 camel-dependencies/pom.xml                         |   2 +-
 .../http/rest/RestProducerOutTypeBindingTest.java  | 123 +++++++++++++++++++++
 .../apache/camel/component/rest/RestProducer.java  |   8 +-
 parent/pom.xml                                     |   2 +-
 pom.xml                                            |   2 +-
 5 files changed, 130 insertions(+), 7 deletions(-)
 create mode 100644 components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestProducerOutTypeBindingTest.java


[camel] 02/03: CAMEL-16112: Fix camel-rest should create new instance of data formats. Thanks to Krzysztof Jamroz for reporting and unit test.

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

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

commit 3cfb84e905279390382d059fb0f520e716610a07
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 30 09:59:19 2021 +0100

    CAMEL-16112: Fix camel-rest should create new instance of data formats. Thanks to Krzysztof Jamroz for reporting and unit test.
---
 .../http/rest/RestProducerOutTypeBindingTest.java  | 123 +++++++++++++++++++++
 .../apache/camel/component/rest/RestProducer.java  |   8 +-
 2 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestProducerOutTypeBindingTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestProducerOutTypeBindingTest.java
new file mode 100644
index 0000000..ea967fb
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/rest/RestProducerOutTypeBindingTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.netty.http.rest;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty.http.BaseNettyTest;
+import org.apache.camel.model.rest.RestBindingMode;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RestProducerOutTypeBindingTest extends BaseNettyTest {
+
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    public static class Resp1 {
+        private String value1;
+
+        public Resp1() {
+        }
+
+        public Resp1(String value1) {
+            this.value1 = value1;
+        }
+
+        public String getValue1() {
+            return value1;
+        }
+
+        public void setValue1(String value1) {
+            this.value1 = value1;
+        }
+
+    }
+
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    public static class Resp2 {
+        private String value1;
+        private String value2;
+
+        public Resp2() {
+        }
+
+        public Resp2(String value1, String value2) {
+            this.value1 = value1;
+            this.value2 = value2;
+        }
+
+        public String getValue1() {
+            return value1;
+        }
+
+        public void setValue1(String value1) {
+            this.value1 = value1;
+        }
+
+        public String getValue2() {
+            return value2;
+        }
+
+        public void setValue2(String value2) {
+            this.value2 = value2;
+        }
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                // mock server
+                restConfiguration().component("netty-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);
+
+                rest()
+                    .get("/req1").route()
+                        .log("Got req1")
+                        .setBody(constant(new Resp1("1")))
+                    .endRest()
+                    .get("/req2").route()
+                        .log("Got req2")
+                        .setBody(constant(new Resp2(null, "2")))
+                    .end();
+
+                // faulty client
+                from("direct:req1")
+                        .toF("rest:get:/req1?host=localhost:%d&outType=%s", getPort(), Resp1.class.getName());
+                from("direct:req2")
+                        .toF("rest:get:/req2?host=localhost:%d&outType=%s", getPort(), Resp2.class.getName());
+            }
+        };
+    }
+
+    @Test
+    public void type1Test() {
+        assertThat(template.requestBody("direct:req1", ""))
+                .isInstanceOfSatisfying(Resp1.class, resp -> assertThat(resp.getValue1()).isEqualTo("1"));
+    }
+
+    @Test
+    public void type2Test() {
+        assertThat(template.requestBody("direct:req2", ""))
+                .isInstanceOfSatisfying(Resp2.class, resp -> {
+                    assertThat(resp.getValue1()).isNull();
+                    assertThat(resp.getValue2()).isEqualTo("2");
+                });
+    }
+}
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
index 833eaa5..df2e2e6 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
@@ -296,8 +296,8 @@ public class RestProducer extends DefaultAsyncProducer {
             name = "json-jackson";
         }
         // this will create a new instance as the name was not already pre-created
-        DataFormat json = camelContext.resolveDataFormat(name);
-        DataFormat outJson = camelContext.resolveDataFormat(name);
+        DataFormat json = camelContext.createDataFormat(name);
+        DataFormat outJson = camelContext.createDataFormat(name);
 
         // is json binding required?
         if (mode.contains("json") && json == null) {
@@ -350,8 +350,8 @@ public class RestProducer extends DefaultAsyncProducer {
             name = "jaxb";
         }
         // this will create a new instance as the name was not already pre-created
-        DataFormat jaxb = camelContext.resolveDataFormat(name);
-        DataFormat outJaxb = camelContext.resolveDataFormat(name);
+        DataFormat jaxb = camelContext.createDataFormat(name);
+        DataFormat outJaxb = camelContext.createDataFormat(name);
 
         // is xml binding required?
         if (mode.contains("xml") && jaxb == null) {


[camel] 03/03: Upgrade impsort maven plugin

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

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

commit 29605cdda5214058418fb59a99ba6f4ec3eb36b7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 30 10:02:08 2021 +0100

    Upgrade impsort maven plugin
---
 camel-dependencies/pom.xml | 2 +-
 parent/pom.xml             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index aaf1c2a..c9b1da0 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -273,7 +273,7 @@
     <ical4j-version>1.0.7</ical4j-version>
     <icu4j-version>65.1</icu4j-version>
     <ignite-version>2.9.1</ignite-version>
-    <impsort-maven-plugin-version>1.4.1</impsort-maven-plugin-version>
+    <impsort-maven-plugin-version>1.5.0</impsort-maven-plugin-version>
     <infinispan-version>12.0.0.Final</infinispan-version>
     <influx-guava-version>20.0</influx-guava-version>
     <influx-java-driver-version>2.21</influx-java-driver-version>
diff --git a/parent/pom.xml b/parent/pom.xml
index 641bbd9..fd28cd3 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -253,7 +253,7 @@
         <ical4j-version>1.0.7</ical4j-version>
         <icu4j-version>65.1</icu4j-version>
         <ignite-version>2.9.1</ignite-version>
-        <impsort-maven-plugin-version>1.4.1</impsort-maven-plugin-version>
+        <impsort-maven-plugin-version>1.5.0</impsort-maven-plugin-version>
         <infinispan-version>12.0.0.Final</infinispan-version>
         <influx-java-driver-version>2.21</influx-java-driver-version>
         <influx-guava-version>20.0</influx-guava-version>


[camel] 01/03: Upgrade maven format plugin

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

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

commit f53b7ad6ece036e8913923182ed95271aaf6f5ed
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 30 09:14:36 2021 +0100

    Upgrade maven format plugin
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 63bbdd8..86df0a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,7 +116,7 @@
         <maven-surefire-plugin-version>3.0.0-M5</maven-surefire-plugin-version>
         <!-- we need to override the version inherited from Apache POM for modules that use this POM as parent -->
         <surefire.version>${maven-surefire-plugin-version}</surefire.version>
-        <formatter-maven-plugin.version>2.12.1</formatter-maven-plugin.version>
+        <formatter-maven-plugin.version>2.13.0</formatter-maven-plugin.version>
         <java-diff-utils-version>4.7</java-diff-utils-version>
         <maven-bundle-plugin-version>4.2.1</maven-bundle-plugin-version>