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 2022/06/01 04:37:31 UTC

[camel] branch camel-3.14.x updated (afcfc8f5871 -> ee80b051f53)

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

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


    from afcfc8f5871 CAMEL-16287 - camel-aws2-sqs should use pagination for deciding which aws sqs queues it should create
     new 79320543225 CAMEL-18157: fix settings provided by the query parameter "parameters… (#7701)
     new ee80b051f53 CAMEL-18157: fix CS

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:
 .../apache/camel/component/jdbc/JdbcProducer.java  | 14 +++++++++----
 ...{JdbcFix9491Test.java => JdbcFix18157Test.java} | 24 ++++++++++------------
 2 files changed, 21 insertions(+), 17 deletions(-)
 copy components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/{JdbcFix9491Test.java => JdbcFix18157Test.java} (66%)


[camel] 01/02: CAMEL-18157: fix settings provided by the query parameter "parameters… (#7701)

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

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

commit 7932054322539f10d11fc1529787ecf32096b79b
Author: Andrea Evangelista <96...@users.noreply.github.com>
AuthorDate: Wed Jun 1 06:18:39 2022 +0200

    CAMEL-18157: fix settings provided by the query parameter "parameters… (#7701)
    
    * CAMEL-18157: fix settings provided by the query parameter "parameters" are ignored when useHeadersAsParameters=true
    
    * CAMEL-18157: fix settings provided by the query parameter "parameters" are ignored when useHeadersAsParameters=true
    Added unit test
    
    Co-authored-by: Andrea Evangelista <an...@graphaware.com>
---
 .../apache/camel/component/jdbc/JdbcProducer.java  | 14 ++++--
 .../camel/component/jdbc/JdbcFix18157Test.java     | 58 ++++++++++++++++++++++
 2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index 1b9d189ac39..e1cea75b295 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -159,6 +159,8 @@ public class JdbcProducer extends DefaultProducer {
                 ps = conn.prepareStatement(preparedQuery);
             }
 
+            bindParameters(exchange,ps);
+
             int expectedCount = ps.getParameterMetaData().getParameterCount();
 
             if (expectedCount > 0) {
@@ -208,10 +210,7 @@ public class JdbcProducer extends DefaultProducer {
                 }
             });
 
-            if (parameters != null && !parameters.isEmpty()) {
-                Map<String, Object> copy = new HashMap<>(parameters);
-                PropertyBindingSupport.bindProperties(exchange.getContext(), stmt, copy);
-            }
+            bindParameters(exchange, stmt);
 
             LOG.debug("Executing JDBC Statement: {}", sql);
 
@@ -256,6 +255,13 @@ public class JdbcProducer extends DefaultProducer {
         return shouldCloseResources;
     }
 
+    private void bindParameters(Exchange exchange, Statement stmt) {
+        if (parameters != null && !parameters.isEmpty()) {
+            Map<String, Object> copy = new HashMap<>(parameters);
+            PropertyBindingSupport.bindProperties(exchange.getContext(), stmt, copy);
+        }
+    }
+
     private void closeQuietly(ResultSet rs) {
         if (rs != null) {
             try {
diff --git a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java
new file mode 100644
index 00000000000..7ab86f51080
--- /dev/null
+++ b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java
@@ -0,0 +1,58 @@
+/*
+ * 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.jdbc;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit test based on user forum request about this component
+ */
+public class JdbcFix18157Test extends AbstractJdbcTestSupport {
+
+    @EndpointInject("mock:result")
+    private MockEndpoint mock;
+
+
+    @Test
+
+    public void whenUseHeadersAsParametersOthersParametersShouldNotBeIgnored() throws Exception {
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:useHeadersAsParameters", "select * from customer");
+
+        assertMockEndpointsSatisfied();
+        assertEquals(1, mock.getReceivedExchanges().get(0).getIn().getBody(List.class).size());
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                //statement.maxRows=1 is provided as additional parameter in combination with useHeadersAsParameters=true
+                from("direct:useHeadersAsParameters").to("jdbc:testdb?statement.maxRows=1&useHeadersAsParameters=true").to("mock:result");
+            }
+        };
+    }
+}


[camel] 02/02: CAMEL-18157: fix CS

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

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

commit ee80b051f53eac2f949a9bf252b05806a1970959
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 1 06:24:25 2022 +0200

    CAMEL-18157: fix CS
---
 .../main/java/org/apache/camel/component/jdbc/JdbcProducer.java   | 2 +-
 .../java/org/apache/camel/component/jdbc/JdbcFix18157Test.java    | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
index e1cea75b295..6ad8aaec7d4 100644
--- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
+++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
@@ -159,7 +159,7 @@ public class JdbcProducer extends DefaultProducer {
                 ps = conn.prepareStatement(preparedQuery);
             }
 
-            bindParameters(exchange,ps);
+            bindParameters(exchange, ps);
 
             int expectedCount = ps.getParameterMetaData().getParameterCount();
 
diff --git a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java
index 7ab86f51080..628254ddd44 100644
--- a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java
+++ b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcFix18157Test.java
@@ -16,13 +16,13 @@
  */
 package org.apache.camel.component.jdbc;
 
+import java.util.List;
+
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 
-import java.util.List;
-
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
@@ -33,7 +33,6 @@ public class JdbcFix18157Test extends AbstractJdbcTestSupport {
     @EndpointInject("mock:result")
     private MockEndpoint mock;
 
-
     @Test
 
     public void whenUseHeadersAsParametersOthersParametersShouldNotBeIgnored() throws Exception {
@@ -51,7 +50,8 @@ public class JdbcFix18157Test extends AbstractJdbcTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 //statement.maxRows=1 is provided as additional parameter in combination with useHeadersAsParameters=true
-                from("direct:useHeadersAsParameters").to("jdbc:testdb?statement.maxRows=1&useHeadersAsParameters=true").to("mock:result");
+                from("direct:useHeadersAsParameters").to("jdbc:testdb?statement.maxRows=1&useHeadersAsParameters=true")
+                        .to("mock:result");
             }
         };
     }