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 2016/03/30 17:35:05 UTC
[2/2] camel git commit: CAMEL-9779: Fixed camel-netty http components
to work when no port number has been configured.
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/5295407e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5295407e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5295407e
Branch: refs/heads/camel-2.16.x
Commit: 5295407e99f283bfa0d5ea2da171a69b47286513
Parents: 771f06c
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Mar 30 17:33:53 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Mar 30 17:34:27 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/5295407e/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 8bc0aea..b29bc24 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/5295407e/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/5295407e/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/5295407e/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/5295407e/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 42e4792..e47bcf4 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/5295407e/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/5295407e/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/5295407e/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 cf8dac1..623c2b7 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
@@ -170,7 +170,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);