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 2013/10/31 11:14:50 UTC
[3/3] git commit: CAMEL-6915: jetty producer misses a colon in the
getUrl of HttpOperationFailedException
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/73a66bca
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/73a66bca
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/73a66bca
Branch: refs/heads/camel-2.11.x
Commit: 73a66bcab14a6e365e770bcc81b0a4dea38f3fb5
Parents: ff3221d
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 31 11:14:55 2013 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 31 11:15:23 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/73a66bca/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 43aaa6c..4d6145f 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
@@ -159,7 +159,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/73a66bca/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/73a66bca/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/73a66bca/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());
}