You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2017/04/12 20:37:20 UTC
camel git commit: CAMEL-11046 camel-undertow - Allow to consume f...
Repository: camel
Updated Branches:
refs/heads/master a313e4213 -> a2d861e1d
CAMEL-11046 camel-undertow - Allow to consume f...
...rom root path more without ending slash
Modifies the given `httpURI` passed via the setter `setHttpURI`, if it
does not contain path, path is explicitly set to `/`, so
`http://0.0.0.0:8080` becomes `http://0.0.0.0:8080/`.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a2d861e1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a2d861e1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a2d861e1
Branch: refs/heads/master
Commit: a2d861e1d080691edf1d81485fb881f0699626d5
Parents: a313e42
Author: Zoran Regvart <zr...@apache.org>
Authored: Wed Apr 12 22:34:21 2017 +0200
Committer: Zoran Regvart <zr...@apache.org>
Committed: Wed Apr 12 22:34:21 2017 +0200
----------------------------------------------------------------------
.../component/undertow/UndertowEndpoint.java | 12 ++++-
.../undertow/UndertowEndpointTest.java | 52 ++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a2d861e1/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index 6e59caf..2b4e75a 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -38,6 +38,7 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.jsse.SSLContextParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -148,7 +149,16 @@ public class UndertowEndpoint extends DefaultEndpoint implements AsyncEndpoint,
* The url of the HTTP endpoint to use.
*/
public void setHttpURI(URI httpURI) {
- this.httpURI = httpURI;
+ if (ObjectHelper.isEmpty(httpURI.getPath())) {
+ try {
+ this.httpURI = new URI(httpURI.getScheme(), httpURI.getUserInfo(), httpURI.getHost(), httpURI.getPort(),
+ "/", httpURI.getQuery(), httpURI.getFragment());
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ this.httpURI = httpURI;
+ }
}
public String getHttpMethodRestrict() {
http://git-wip-us.apache.org/repos/asf/camel/blob/a2d861e1/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowEndpointTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowEndpointTest.java
new file mode 100644
index 0000000..4562742
--- /dev/null
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowEndpointTest.java
@@ -0,0 +1,52 @@
+/**
+ * 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.undertow;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class UndertowEndpointTest {
+
+ UndertowEndpoint endpoint;
+
+ final URI withSlash = URI.create("http://0.0.0.0:8080/");
+
+ final URI withoutSlash = URI.create("http://0.0.0.0:8080");
+
+ @Before
+ public void createEndpoint() throws URISyntaxException {
+ endpoint = new UndertowEndpoint(null, null);
+ }
+
+ @Test
+ public void emptyPathShouldBeReplacedWithSlash() {
+ endpoint.setHttpURI(withoutSlash);
+ assertEquals(withSlash, endpoint.getHttpURI());
+ }
+
+ @Test
+ public void nonEmptyPathShouldBeKeptSame() {
+ endpoint.setHttpURI(withSlash);
+ assertEquals(withSlash, endpoint.getHttpURI());
+ }
+}