Repository: camel
Updated Branches:
  refs/heads/camel-2.17.x 77e417c27 -> b6424e7b0
  refs/heads/master 8129b1a78 -> 6024c9f27


CAMEL-10064: Extra request parameter sent by the camel-jetty component when 
using bridge mode.


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

Branch: refs/heads/master
Commit: 6024c9f2740a1b2e8277a4a3d25510ef9ee9946d
Parents: 8129b1a
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Sep 6 10:48:20 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Sep 6 10:48:20 2016 +0200

----------------------------------------------------------------------
 .../component/jetty/JettyHttpComponent.java     |  5 +++
 .../JettyHttpProducerBridgeTest.java            | 39 ++++++++++++++++++++
 2 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6024c9f2/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 9da1ffe..70583c8 100644
--- 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -298,6 +298,11 @@ public abstract class JettyHttpComponent extends 
HttpCommonComponent implements
         endpoint.setSendServerVersion(isSendServerVersion());
 
         setProperties(endpoint, parameters);
+
+        // re-create http uri after all parameters has been set on the 
endpoint, as the remainders are for http uri
+        httpUri = URISupport.createRemainingURI(addressUri, parameters);
+        endpoint.setHttpUri(httpUri);
+
         return endpoint;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6024c9f2/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java
 
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java
index 8c784e4..64e592e 100644
--- 
a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java
+++ 
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerBridgeTest.java
@@ -33,8 +33,46 @@ public class JettyHttpProducerBridgeTest extends 
BaseJettyTest {
         // give Jetty time to startup properly
         Thread.sleep(2000);
 
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        
getMockEndpoint("mock:bar").message(0).header("bridgeEndpoint").isNull();
+        
getMockEndpoint("mock:bar").message(0).header("throwExceptionOnFailure").isNull();
+
         String reply = template.requestBody("jetty:http://127.0.0.1:"; + port1 
+ "/foo", "World", String.class);
         assertEquals("Bye World", reply);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testProxyWithHeader() throws Exception {
+        // give Jetty time to startup properly
+        Thread.sleep(2000);
+
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").expectedHeaderReceived("beer", 
"Carlsberg");
+        
getMockEndpoint("mock:bar").message(0).header("bridgeEndpoint").isNull();
+        
getMockEndpoint("mock:bar").message(0).header("throwExceptionOnFailure").isNull();
+
+        String reply = template.requestBodyAndHeader("jetty:http://127.0.0.1:"; 
+ port1 + "/foo", "Camel", "beer", "Carlsberg", String.class);
+        assertEquals("Bye Camel", reply);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testProxyWithQueryParameter() throws Exception {
+        // give Jetty time to startup properly
+        Thread.sleep(2000);
+
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").expectedHeaderReceived("beer", 
"Carlsberg");
+        
getMockEndpoint("mock:bar").message(0).header("bridgeEndpoint").isNull();
+        
getMockEndpoint("mock:bar").message(0).header("throwExceptionOnFailure").isNull();
+
+        String reply = template.requestBody("jetty:http://127.0.0.1:"; + port1 
+ "/foo?beer=Carlsberg", "Apache", String.class);
+        assertEquals("Bye Apache", reply);
+
+        assertMockEndpointsSatisfied();
     }
 
     @Override
@@ -49,6 +87,7 @@ public class JettyHttpProducerBridgeTest extends 
BaseJettyTest {
                     .to("jetty:http://127.0.0.1:"; + port2 + 
"/bar?bridgeEndpoint=true&throwExceptionOnFailure=false");
 
                 from("jetty:http://127.0.0.1:"; + port2 + "/bar")
+                    .to("mock:bar")
                     .transform().simple("Bye ${body}");
             }
         };

Reply via email to