Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 771f06c59 -> 5295407e9
  refs/heads/camel-2.17.x a33609091 -> d23a5ceee


CAMEL-9779: Fixed camel-netty http components to work when no port number has 
been configured.


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

Branch: refs/heads/camel-2.17.x
Commit: d23a5ceee69c05ee7c51b119721ee2a6e91b36ff
Parents: a336090
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Mar 30 17:33:53 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Mar 30 17:34:14 2016 +0200

----------------------------------------------------------------------
 .../netty/http/NettyHttpComponent.java          |  2 +-
 .../netty/http/NettyHttpConfiguration.java      |  4 +-
 .../netty/http/NettyCamelWebsiteTest.java       | 51 ++++++++++++++++++++
 .../component/netty/NettyConfiguration.java     |  4 +-
 .../netty4/http/NettyHttpComponent.java         |  2 +-
 .../netty4/http/NettyHttpConfiguration.java     |  4 +-
 .../netty4/http/NettyCamelWebsiteTest.java      | 51 ++++++++++++++++++++
 .../component/netty4/NettyConfiguration.java    |  4 +-
 8 files changed, 114 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 029d290..07324e6 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -121,7 +121,7 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
         // set port on configuration which is either shared or using default 
values
         if (sharedPort != -1) {
             config.setPort(sharedPort);
-        } else if (config.getPort() == -1) {
+        } else if (config.getPort() == -1 || config.getPort() == 0) {
             if (remaining.startsWith("http:")) {
                 config.setPort(80);
             } else if (remaining.startsWith("https:")) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
index 05999d3..3cd223d 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
@@ -38,8 +38,8 @@ public class NettyHttpConfiguration extends 
NettyConfiguration {
     private String protocol;
     @UriPath @Metadata(required = "true")
     private String host;
-    @UriPath
-    private int port;
+    @UriPath(name = "port")
+    private int dummy;
     @UriPath
     private String path;
     @UriParam(label = "consumer,advanced")

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyCamelWebsiteTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyCamelWebsiteTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyCamelWebsiteTest.java
new file mode 100644
index 0000000..b40e37c
--- /dev/null
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyCamelWebsiteTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.netty.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("For manual testing")
+public class NettyCamelWebsiteTest extends CamelTestSupport {
+
+    @Test
+    public void testCamel() throws Exception {
+        getMockEndpoint("mock:test").expectedMessageCount(1);
+
+        template.sendBody("direct:in", null);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:in")
+                        .setHeader(Exchange.HTTP_METHOD, constant("GET"))
+                        .to("netty-http:http://camel.apache.org/";)
+                        .to("log:test")
+                        .to("mock:test");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
index ddbc2b7..c1d7d79 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
@@ -173,7 +173,9 @@ public class NettyConfiguration extends 
NettyServerBootstrapConfiguration implem
         }
 
         setHost(uri.getHost());
-        setPort(uri.getPort());
+        if (uri.getPort() != -1) {
+            setPort(uri.getPort());
+        }
 
         ssl = component.getAndRemoveOrResolveReferenceParameter(parameters, 
"ssl", boolean.class, false);
         sslHandler = 
component.getAndRemoveOrResolveReferenceParameter(parameters, "sslHandler", 
SslHandler.class, sslHandler);

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 04ef4f3..4f6de0d 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -123,7 +123,7 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
         // set port on configuration which is either shared or using default 
values
         if (sharedPort != -1) {
             config.setPort(sharedPort);
-        } else if (config.getPort() == -1) {
+        } else if (config.getPort() == -1 || config.getPort() == 0) {
             if (remaining.startsWith("http:")) {
                 config.setPort(80);
             } else if (remaining.startsWith("https:")) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index 9f6c9bb..97c3a7f 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -37,8 +37,8 @@ public class NettyHttpConfiguration extends 
NettyConfiguration {
     private String protocol;
     @UriPath @Metadata(required = "true")
     private String host;
-    @UriPath
-    private int port;
+    @UriPath(name = "port")
+    private int dummy;
     @UriPath
     private String path;
     @UriParam(label = "consumer,advanced")

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyCamelWebsiteTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyCamelWebsiteTest.java
 
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyCamelWebsiteTest.java
new file mode 100644
index 0000000..62edbc0
--- /dev/null
+++ 
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyCamelWebsiteTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.netty4.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("For manual testing")
+public class NettyCamelWebsiteTest extends CamelTestSupport {
+
+    @Test
+    public void testCamel() throws Exception {
+        getMockEndpoint("mock:test").expectedMessageCount(1);
+
+        template.sendBody("direct:in", null);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:in")
+                    .setHeader(Exchange.HTTP_METHOD, constant("GET"))
+                    .to("netty4-http:http://camel.apache.org/";)
+                    .to("log:test")
+                    .to("mock:test");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d23a5cee/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
index 69f9cf9..bc2523d 100644
--- 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
+++ 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
@@ -174,7 +174,9 @@ public class NettyConfiguration extends 
NettyServerBootstrapConfiguration implem
         }
 
         setHost(uri.getHost());
-        setPort(uri.getPort());
+        if (uri.getPort() != -1) {
+            setPort(uri.getPort());
+        }
 
         ssl = component.getAndRemoveOrResolveReferenceParameter(parameters, 
"ssl", boolean.class, false);
         sslHandler = 
component.getAndRemoveOrResolveReferenceParameter(parameters, "sslHandler", 
SslHandler.class, sslHandler);

Reply via email to