Updated Branches:
  refs/heads/camel-2.11.x 8ea81d59b -> f01b416fd
  refs/heads/camel-2.12.x 738defda3 -> da00bb6f1
  refs/heads/master 86565f0d6 -> 38a4ed8b7


CAMEL-6953: CamelHttpUrl header should be a String type.


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

Branch: refs/heads/master
Commit: 38a4ed8b72b3a44df0a1e67564097229bd3abba8
Parents: 86565f0
Author: Claus Ibsen <[email protected]>
Authored: Mon Nov 11 12:58:29 2013 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Mon Nov 11 12:58:29 2013 +0100

----------------------------------------------------------------------
 .../component/http/DefaultHttpBinding.java      |  6 +--
 .../jetty/JettyCamelHttpUrlCBRTest.java         | 55 ++++++++++++++++++++
 2 files changed, 58 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/38a4ed8b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index d44bef3..dd74c43 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -117,10 +117,10 @@ public class DefaultHttpBinding implements HttpBinding {
             ((StreamCache)body).reset();
         }
 
-        // store the method and query and other info in headers
+        // store the method and query and other info in headers as String types
         headers.put(Exchange.HTTP_METHOD, request.getMethod());
         headers.put(Exchange.HTTP_QUERY, request.getQueryString());
-        headers.put(Exchange.HTTP_URL, request.getRequestURL());
+        headers.put(Exchange.HTTP_URL, request.getRequestURL().toString());
         headers.put(Exchange.HTTP_URI, request.getRequestURI());
         headers.put(Exchange.HTTP_PATH, request.getPathInfo());
         headers.put(Exchange.CONTENT_TYPE, request.getContentType());
@@ -129,7 +129,7 @@ public class DefaultHttpBinding implements HttpBinding {
             LOG.trace("HTTP method {}", request.getMethod());
             LOG.trace("HTTP query {}", request.getQueryString());
             LOG.trace("HTTP url {}", request.getRequestURL());
-            LOG.trace("HTTP uri {}", request.getRequestURI());
+            LOG.trace("HTTP uri {}", request.getRequestURI().toString());
             LOG.trace("HTTP path {}", request.getPathInfo());
             LOG.trace("HTTP content-type {}", request.getContentType());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/38a4ed8b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyCamelHttpUrlCBRTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyCamelHttpUrlCBRTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyCamelHttpUrlCBRTest.java
new file mode 100644
index 0000000..7e48c9f
--- /dev/null
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyCamelHttpUrlCBRTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class JettyCamelHttpUrlCBRTest extends BaseJettyTest {
+
+    @Test
+    public void testCamelHttpUrl() throws Exception {
+        getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:foo").expectedHeaderReceived("beer", "yes");
+        
getMockEndpoint("mock:foo").expectedHeaderReceived(Exchange.HTTP_METHOD, 
"POST");
+        getMockEndpoint("mock:foo").expectedHeaderReceived(Exchange.HTTP_URL, 
"http://localhost:"; + getPort() + "/foo");
+        getMockEndpoint("mock:foo").expectedHeaderReceived(Exchange.HTTP_URI, 
"/foo");
+        
getMockEndpoint("mock:foo").expectedHeaderReceived(Exchange.HTTP_QUERY, 
"beer=yes");
+        getMockEndpoint("mock:foo").expectedHeaderReceived(Exchange.HTTP_PATH, 
"");
+
+        String out = 
template.requestBody("http://localhost:{{port}}/foo?beer=yes";, "Hello World", 
String.class);
+        assertEquals("Bye World", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jetty:http://0.0.0.0:{{port}}/foo";)
+                        .filter().simple("${header.CamelHttpUrl} contains 
'foo'")
+                            .to("mock:foo")
+                        .end()
+                        .transform().constant("Bye World");
+            }
+        };
+    }
+
+}

Reply via email to