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/b6424e7b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b6424e7b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b6424e7b Branch: refs/heads/camel-2.17.x Commit: b6424e7b04f51b52d3eadd12c9adc446686ed463 Parents: 77e417c 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:50 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/b6424e7b/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 b222d1c..33fe88c 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 @@ -287,6 +287,11 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements } 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/b6424e7b/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}"); } };