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 2020/08/23 16:35:24 UTC

[camel] branch camel-3.4.x updated (33f9de7 -> 7702e7b)

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

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


    from 33f9de7  CAMEL-15445: component lifecycle is differen when endpoints are created using endpointdsl
     new e14c9c4  CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head… (#4105)
     new 7702e7b  CAMEL-15420: Improved test

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:
 .../camel/http/base/HttpSendDynamicAware.java      |  5 +++
 ...t.java => HttpSendDynamicAwareHeadersTest.java} | 40 +++++++++++++---------
 2 files changed, 29 insertions(+), 16 deletions(-)
 copy components/camel-http/src/test/java/org/apache/camel/component/http/{HttpsSslContextParametersGetTest.java => HttpSendDynamicAwareHeadersTest.java} (52%)


[camel] 01/02: CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head… (#4105)

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.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e14c9c4db1a8bf8c1e366c571fc3b4f96a863dd9
Author: Chandrakant Hardahe <ch...@gmail.com>
AuthorDate: Sun Aug 23 20:47:05 2020 +0530

    CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY head… (#4105)
    
    * CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY header if Exchange.HTTP_PATH header not specified
    
    * CAMEL-15420 camel-http dynamic aware removes Exchange.HTTP_QUERY header if Exchange.HTTP_PATH header not specified
    
    Using ObjectHelper
    
    Checking HTTP_PATH and HTTP_QUERY headers
    
    Checking HTTP_PATH and HTTP_QUERY headers
    
    Co-authored-by: Chandrakant Hardahe <ch...@chardahe.pnq.csb>
---
 .../camel/http/base/HttpSendDynamicAware.java      |  5 ++
 .../http/HttpSendDynamicAwareHeadersTest.java      | 76 ++++++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
index 0822ffc..b053dd3 100644
--- a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
+++ b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
@@ -26,6 +26,7 @@ import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.catalog.RuntimeCamelCatalog;
 import org.apache.camel.spi.SendDynamicAware;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.URISupport;
 
@@ -101,6 +102,10 @@ public class HttpSendDynamicAware implements SendDynamicAware {
             query = URISupport.createQueryString(new LinkedHashMap<>(entry.getLenientProperties()));
         }
 
+        if (query == null && ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Exchange.HTTP_QUERY))) {
+            query = (String) exchange.getIn().getHeader(Exchange.HTTP_QUERY);
+        }
+
         if (path != null || query != null) {
             return new HttpSendDynamicPreProcessor(path, query);
         } else {
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
new file mode 100644
index 0000000..fdb80ca
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.component.http.HttpMethods.GET;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest {
+
+    private HttpServer localServer;
+
+    @BeforeEach
+    @Override
+    public void setUp() throws Exception {
+        localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
+                .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
+                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
+                .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), null, null, null)).create();
+        localServer.start();
+
+        super.setUp();
+    }
+
+    @AfterEach
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        if (localServer != null) {
+            localServer.stop();
+        }
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:dynamicAwareWithoutPathHeader")
+                        .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2"))
+                        .toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware");
+            }
+        };
+    }
+
+    @Test
+    public void testDynamicAwareHeadersQuery() throws Exception {
+        Exchange e = fluentTemplate.to("direct:dynamicAwareWithoutPathHeader").send();
+        assertEquals("/dynamicAware", e.getIn().getHeader(Exchange.HTTP_PATH));
+        assertEquals("par1=val1&par2=val2", e.getIn().getHeader(Exchange.HTTP_QUERY));
+    }
+}


[camel] 02/02: CAMEL-15420: Improved test

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.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7702e7bdb6ea1efb7aaf8f49487c14f27cc04f76
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 23 17:20:42 2020 +0200

    CAMEL-15420: Improved test
---
 .../apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
index fdb80ca..bec5de6 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
@@ -39,7 +39,8 @@ public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
                 .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), null, null, null)).create();
+                .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), "par1=val1&par2=val2", null, null))
+                .create();
         localServer.start();
 
         super.setUp();