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 2022/09/23 08:25:57 UTC
[camel] branch camel-3.18.x updated (5fc22b79f2d -> 11597263947)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
from 5fc22b79f2d (chores) camel-atmos: fixed invalid link in documentation (#8414) (#8417)
new a5ed5183781 Adds tests to demonstrate bug within the toD optimisation (#8396)
new 3b0ef2fc102 CAMEL-18544: Ignore test until bug fixed
new 11597263947 CAMEL-18544: camel-http - ToD optimized context-path with spaces problem
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/http/base/HttpSendDynamicAware.java | 4 ++-
... => HttpSendDynamicAwareUriWithSpacesTest.java} | 30 +++-------------------
2 files changed, 7 insertions(+), 27 deletions(-)
copy components/camel-http/src/test/java/org/apache/camel/component/http/{HttpSendDynamicAwareUriWithoutSlashTest.java => HttpSendDynamicAwareUriWithSpacesTest.java} (68%)
[camel] 01/03: Adds tests to demonstrate bug within the toD optimisation (#8396)
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a5ed51837814036eec4b978bd91b4a4b6b325d66
Author: Jeroen Bellen <be...@gmail.com>
AuthorDate: Fri Sep 23 09:16:41 2022 +0200
Adds tests to demonstrate bug within the toD optimisation (#8396)
Co-authored-by: Jeroen Bellen <je...@aviobook.aero>
---
.../HttpSendDynamicAwareUriWithSpacesTest.java | 91 ++++++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
new file mode 100644
index 00000000000..6f8735ab24c
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.http;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.ExchangeBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
+
+ private HttpServer localServer;
+
+ @BeforeEach
+ @Override
+ public void setUp() throws Exception {
+ localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
+ .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
+ .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
+ .registerHandler("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
+ localServer.start();
+
+ super.setUp();
+ }
+
+ @AfterEach
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (localServer != null) {
+ localServer.stop();
+ }
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:usersDrink")
+ .toD("http:localhost:" + localServer.getLocalPort()
+ + "/users/${exchangeProperty.user}");
+ }
+ };
+ }
+
+ @Test
+ public void testDynamicAware() throws Exception {
+ Exchange out = fluentTemplate.to("direct:usersDrink")
+ .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "joes moes").build()).send();
+ assertEquals("a user", out.getMessage().getBody(String.class));
+
+ out = fluentTemplate.to("direct:usersDrink")
+ .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "moes joes").build()).send();
+ assertEquals("a user", out.getMessage().getBody(String.class));
+
+ // and there should only be one http endpoint as they are both on same host
+ Map<String, Endpoint> endpointMap = context.getEndpointMap();
+ assertEquals(2, endpointMap.size());
+ assertTrue(endpointMap.containsKey("http://localhost:" + localServer.getLocalPort()), "Should find static uri");
+ assertTrue(endpointMap.containsKey("direct://usersDrink"), "Should find direct");
+ }
+
+}
[camel] 03/03: CAMEL-18544: camel-http - ToD optimized context-path with spaces problem
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 115972639478994e39e5d2fb5f5a2c4d22b8c2ac
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Sep 23 10:22:26 2022 +0200
CAMEL-18544: camel-http - ToD optimized context-path with spaces problem
---
.../main/java/org/apache/camel/http/base/HttpSendDynamicAware.java | 4 +++-
.../camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java | 2 --
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
index e476bc923c7..97efdc2934c 100644
--- a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
+++ b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java
@@ -28,6 +28,7 @@ import org.apache.camel.support.component.SendDynamicAwareSupport;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StringHelper;
import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
/**
* HTTP based {@link org.apache.camel.spi.SendDynamicAware} which allows to optimise HTTP components with the toD
@@ -163,8 +164,9 @@ public class HttpSendDynamicAware extends SendDynamicAwareSupport {
}
}
- // favour using java.net.URI for parsing into host, context-path and authority
try {
+ // favour using java.net.URI for parsing into host, context-path and authority
+ u = UnsafeUriCharactersEncoder.encode(u);
URI parse = new URI(u);
String host = parse.getHost();
String path = parse.getPath();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
index c6b42f34ed1..e5c49143887 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
@@ -28,13 +28,11 @@ import org.apache.http.impl.bootstrap.HttpServer;
import org.apache.http.impl.bootstrap.ServerBootstrap;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@Disabled("https://issues.apache.org/jira/browse/CAMEL-18544")
public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
private HttpServer localServer;
[camel] 02/03: CAMEL-18544: Ignore test until bug fixed
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3b0ef2fc102d7ef0ce559f3b53f1ce18e2124d7d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Sep 23 09:20:04 2022 +0200
CAMEL-18544: Ignore test until bug fixed
---
.../http/HttpSendDynamicAwareUriWithSpacesTest.java | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
index 6f8735ab24c..c6b42f34ed1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
@@ -28,11 +28,13 @@ import org.apache.http.impl.bootstrap.HttpServer;
import org.apache.http.impl.bootstrap.ServerBootstrap;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@Disabled("https://issues.apache.org/jira/browse/CAMEL-18544")
public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
private HttpServer localServer;
@@ -41,9 +43,9 @@ public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
- .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
- .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
- .registerHandler("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
+ .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
+ .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
+ .registerHandler("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
localServer.start();
super.setUp();
@@ -65,20 +67,20 @@ public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
@Override
public void configure() throws Exception {
from("direct:usersDrink")
- .toD("http:localhost:" + localServer.getLocalPort()
- + "/users/${exchangeProperty.user}");
+ .toD("http:localhost:" + localServer.getLocalPort()
+ + "/users/${exchangeProperty.user}");
}
};
}
-
+
@Test
public void testDynamicAware() throws Exception {
Exchange out = fluentTemplate.to("direct:usersDrink")
- .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "joes moes").build()).send();
+ .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "joes moes").build()).send();
assertEquals("a user", out.getMessage().getBody(String.class));
out = fluentTemplate.to("direct:usersDrink")
- .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "moes joes").build()).send();
+ .withExchange(ExchangeBuilder.anExchange(context).withProperty("user", "moes joes").build()).send();
assertEquals("a user", out.getMessage().getBody(String.class));
// and there should only be one http endpoint as they are both on same host
@@ -87,5 +89,5 @@ public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
assertTrue(endpointMap.containsKey("http://localhost:" + localServer.getLocalPort()), "Should find static uri");
assertTrue(endpointMap.containsKey("direct://usersDrink"), "Should find direct");
}
-
+
}