This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.11.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1b42c902a0ec41b94f2679455054b0ccdbaaf49c Author: James Netherton <jamesnether...@users.noreply.github.com> AuthorDate: Fri Jun 25 05:45:30 2021 +0100 CAMEL-16756: Improve handling of Vert.x Buffer payloads in platform-http-vertx (#5746) --- components/camel-platform-http-vertx/pom.xml | 5 ++++ .../http/vertx/VertxPlatformHttpSupport.java | 3 ++- .../http/vertx/VertxPlatformHttpEngineTest.java | 30 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/components/camel-platform-http-vertx/pom.xml b/components/camel-platform-http-vertx/pom.xml index a40d77e..ecc4368 100644 --- a/components/camel-platform-http-vertx/pom.xml +++ b/components/camel-platform-http-vertx/pom.xml @@ -69,6 +69,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-log</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <scope>test</scope> diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java index 133953b..97cd2a1 100644 --- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java +++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java @@ -176,6 +176,8 @@ public final class VertxPlatformHttpSupport { } } response.end(); + } else if (body instanceof Buffer) { + response.end((Buffer) body); } else { final TypeConverter tc = camelExchange.getContext().getTypeConverter(); final ByteBuffer bb = tc.mandatoryConvertTo(ByteBuffer.class, body); @@ -184,7 +186,6 @@ public final class VertxPlatformHttpSupport { b.setBytes(0, bb); response.end(b); } - } static void populateCamelHeaders( diff --git a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java index 3d0b2d2..877da29 100644 --- a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java +++ b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; import javax.activation.DataHandler; import io.restassured.RestAssured; +import io.restassured.http.ContentType; import io.vertx.core.VertxOptions; import org.apache.camel.CamelContext; import org.apache.camel.attachment.AttachmentMessage; @@ -408,6 +409,35 @@ public class VertxPlatformHttpEngineTest { } @Test + public void testTextContentPost() throws Exception { + final CamelContext context = createCamelContext(); + + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("platform-http:/text/post") + .log("POST:/test/post has body ${body}"); + } + }); + + context.start(); + + String payload = "Hello World"; + given() + .contentType(ContentType.TEXT) + .body(payload) + .when() + .post("/text/post") + .then() + .statusCode(200) + .body(is(payload)); + } finally { + context.stop(); + } + } + + @Test public void testBodyClientRequestValidation() throws Exception { final CamelContext context = createCamelContext();