Updated Branches: refs/heads/camel-2.11.x ff3221da2 -> 73a66bcab refs/heads/camel-2.12.x 379ca058a -> c2358e5cc refs/heads/master 94ed5c48d -> 8c64f07f6
CAMEL-6915: jetty producer misses a colon in the getUrl of HttpOperationFailedException Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8c64f07f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8c64f07f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8c64f07f Branch: refs/heads/master Commit: 8c64f07f6aa18efb034dcbe7c45b077199c846c1 Parents: 94ed5c4 Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Oct 31 11:14:55 2013 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Oct 31 11:14:55 2013 +0100 ---------------------------------------------------------------------- .../component/jetty/JettyContentExchange.java | 2 +- .../camel/component/jetty/HttpRedirectTest.java | 1 + .../JettyHttpProducerRedirectTest.java | 62 ++++++++++++++++++++ .../JettyHttpProducerSimulate404ErrorTest.java | 2 +- 4 files changed, 65 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8c64f07f/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java index 2440bea..32081eb 100644 --- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java +++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java @@ -168,7 +168,7 @@ public class JettyContentExchange extends ContentExchange { public String getUrl() { String params = getRequestFields().getStringField(HttpHeaders.CONTENT_ENCODING); - return getScheme() + "//" + getAddress().toString() + getRequestURI() + (params != null ? "?" + params : ""); + return getScheme() + "://" + getAddress().toString() + getRequestURI() + (params != null ? "?" + params : ""); } protected void closeRequestContentSource() { http://git-wip-us.apache.org/repos/asf/camel/blob/8c64f07f/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java index 6231ede..e139e47 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java @@ -38,6 +38,7 @@ public class HttpRedirectTest extends BaseJettyTest { assertEquals(301, cause.getStatusCode()); assertEquals(true, cause.isRedirectError()); assertEquals(true, cause.hasRedirectLocation()); + assertEquals("http://localhost:" + getPort() + "/test", cause.getUri()); assertEquals("http://localhost:" + getPort() + "/newtest", cause.getRedirectLocation()); } } http://git-wip-us.apache.org/repos/asf/camel/blob/8c64f07f/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java new file mode 100644 index 0000000..7f4bcf7 --- /dev/null +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java @@ -0,0 +1,62 @@ +/** + * 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.jetty.jettyproducer; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.http.HttpOperationFailedException; +import org.apache.camel.component.jetty.BaseJettyTest; +import org.junit.Test; + +/** + * @version + */ +public class JettyHttpProducerRedirectTest extends BaseJettyTest { + + @Test + public void testHttpRedirect() throws Exception { + try { + template.requestBody("jetty:http://localhost:{{port}}/test", "Hello World", String.class); + fail("Should have thrown an exception"); + } catch (RuntimeCamelException e) { + HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause()); + assertEquals(301, cause.getStatusCode()); + assertEquals(true, cause.isRedirectError()); + assertEquals(true, cause.hasRedirectLocation()); + assertEquals("http://localhost:" + getPort() + "/test", cause.getUri()); + assertEquals("http://localhost:" + getPort() + "/newtest", cause.getRedirectLocation()); + } + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("jetty://http://localhost:{{port}}/test") + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 301); + exchange.getOut().setHeader("location", "http://localhost:" + getPort() + "/newtest"); + } + }); + } + }; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/8c64f07f/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java index 14c385a..72a3edd 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java @@ -46,7 +46,7 @@ public class JettyHttpProducerSimulate404ErrorTest extends BaseJettyTest { } catch (Exception e) { HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause()); assertEquals(404, cause.getStatusCode()); - assertEquals("http//0.0.0.0:" + getPort() + "/bar", cause.getUri()); + assertEquals("http://0.0.0.0:" + getPort() + "/bar", cause.getUri()); assertEquals("Page not found", cause.getResponseBody()); assertNotNull(cause.getResponseHeaders()); }