This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 8e2e7a7 Add workarounds for
https://github.com/quarkusio/quarkus/issues/4407
8e2e7a7 is described below
commit 8e2e7a709643b61ddc920efb15eeef8e896749b6
Author: lburgazzoli <[email protected]>
AuthorDate: Mon Oct 7 11:45:42 2019 +0200
Add workarounds for https://github.com/quarkusio/quarkus/issues/4407
---
.../http/runtime/QuarkusPlatformHttpConsumer.java | 16 ++++++++++--
integration-tests/platform-http/pom.xml | 13 ++++++++++
.../platform/http/it/PlatformHttpResource.java | 24 ++++++++++++-----
.../platform/http/it/PlatformHttpRouteBuilder.java | 21 ---------------
.../component/http/server/it/PlatformHttpTest.java | 30 ++++++++++------------
5 files changed, 57 insertions(+), 47 deletions(-)
diff --git
a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
index ce4656c..7fa7f90 100644
---
a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
+++
b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
@@ -93,8 +93,12 @@ public class QuarkusPlatformHttpConsumer extends
DefaultConsumer {
Config cfg = ConfigProvider.getConfig();
final BodyHandler bodyHandler = BodyHandler.create();
- /* Keep in sync with how the BodyHandler is configured in
io.quarkus.vertx.web.runtime.VertxWebRecorder
- * Eventually, VertxWebRecorder should have a method to do this for
us. */
+ /*
+ * Keep in sync with how the BodyHandler is configured in
io.quarkus.vertx.web.runtime.VertxWebRecorder
+ * Eventually, VertxWebRecorder should have a method to do this for us.
+ *
+ * TODO: remove this code when moving to quarkus 0.24.x, see
https://github.com/quarkusio/quarkus/pull/4314
+ */
cfg.getOptionalValue("quarkus.http.body.handle-file-uploads",
boolean.class).ifPresent(bodyHandler::setHandleFileUploads);
cfg.getOptionalValue("quarkus.http.body.uploads-directory",
String.class).ifPresent(bodyHandler::setUploadsDirectory);
cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end",
boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd);
@@ -102,6 +106,14 @@ public class QuarkusPlatformHttpConsumer extends
DefaultConsumer {
cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer",
boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer);
newRoute
+ //
+ // This should not be needed but because the default route added
by quarkus (i.e. in case
+ // the quarkus-resteasy extension is in the classpath) is a catch
all, it is required to
+ // configure the route to be evaluated before the default one.
+ //
+ // TODO: remove this after
https://github.com/quarkusio/quarkus/issues/4407 is fixed.
+ //
+ .order(-1)
.handler(bodyHandler)
.handler(ctx -> {
try {
diff --git a/integration-tests/platform-http/pom.xml
b/integration-tests/platform-http/pom.xml
index fb9e5ee..fb30c28 100644
--- a/integration-tests/platform-http/pom.xml
+++ b/integration-tests/platform-http/pom.xml
@@ -36,6 +36,14 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -48,6 +56,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpResource.java
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpResource.java
index b16d616..288e1c6 100644
---
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpResource.java
+++
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpResource.java
@@ -16,11 +16,22 @@
*/
package org.apache.camel.quarkus.component.platform.http.it;
-// TODO: investigate why adding resteasy break the platform http component
-//@Path("/test")
-//@ApplicationScoped
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.component.platform.http.PlatformHttpConstants;
+import org.apache.camel.spi.Registry;
+
+@Path("/test")
+@ApplicationScoped
public class PlatformHttpResource {
- /*
@Inject
Registry registry;
@@ -36,12 +47,11 @@ public class PlatformHttpResource {
if (engine != null) {
builder.add(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME,
engine.getClass().getName());
- }if (component != null) {
+ }
+ if (component != null) {
builder.add(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME,
component.getClass().getName());
-
}
return builder.build();
}
- */
}
diff --git
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
index 943745f..894deee 100644
---
a/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
+++
b/integration-tests/platform-http/src/main/java/org/apache/camel/quarkus/component/platform/http/it/PlatformHttpRouteBuilder.java
@@ -17,33 +17,12 @@
package org.apache.camel.quarkus.component.platform.http.it;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.platform.http.PlatformHttpConstants;
-import org.apache.camel.spi.Registry;
public class PlatformHttpRouteBuilder extends RouteBuilder {
-
@Override
public void configure() {
from("platform-http:/platform-http/hello?httpMethodRestrict=GET").setBody(simple("Hello
${header.name}"));
from("platform-http:/platform-http/get-post?httpMethodRestrict=GET,POST").setBody(simple("Hello
${body}"));
from("platform-http:/platform-http/multipart?httpMethodRestrict=POST").setBody(simple("Hello
${body}"));
-
- fromF("platform-http:/platform-http/registry/%s",
PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME).process().message(m -> {
- Registry registry = m.getExchange().getContext().getRegistry();
- Object answer =
registry.lookupByName(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME);
-
- if (answer != null) {
- m.setBody(answer.getClass().getName());
- }
- });
-
- fromF("platform-http:/platform-http/registry/%s",
PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME).process().message(m -> {
- Registry registry = m.getExchange().getContext().getRegistry();
- Object answer =
registry.lookupByName(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);
-
- if (answer != null) {
- m.setBody(answer.getClass().getName());
- }
- });
}
}
diff --git
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
index 56bd8ef..c08eaba 100644
---
a/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
+++
b/integration-tests/platform-http/src/test/java/org/apache/camel/quarkus/component/http/server/it/PlatformHttpTest.java
@@ -25,24 +25,23 @@ import
org.apache.camel.quarkus.component.platform.http.runtime.QuarkusPlatformH
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
@QuarkusTest
class PlatformHttpTest {
- @Disabled("looks like adding resteasy break the component")
@Test
public void testRegistrySetUp() {
-
JsonPath p = RestAssured.given()
.get("/test/registry/inspect")
.then()
.statusCode(200)
.extract()
- .body()
- .jsonPath();
+ .body()
+ .jsonPath();
-
//assertThat(p.getString(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME)).isEqualTo(QuarkusPlatformHttpEngine.class.getName());
-
//assertThat(p.getString(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)).isEqualTo(PlatformHttpComponent.class.getName());
+
assertThat(p.getString(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME)).isEqualTo(QuarkusPlatformHttpEngine.class.getName());
+
assertThat(p.getString(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)).isEqualTo(PlatformHttpComponent.class.getName());
}
@Test
@@ -54,27 +53,24 @@ class PlatformHttpTest {
.statusCode(200)
.body(equalTo("Hello Kermit"));
- RestAssured.post("/platform-http/hello").then().statusCode(405);
-
RestAssured.given()
.body("Camel")
.post("/platform-http/get-post")
.then()
.statusCode(200)
- .body(equalTo("Hello Camel"));
+ .body(equalTo("Hello Camel"));
+
RestAssured.given()
.get("/platform-http/get-post")
.then()
.statusCode(200)
.body(equalTo("Hello ")); // there is no body for get
+ }
- RestAssured.given().get("/platform-http/registry/" +
PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME)
- .then()
- .statusCode(200)
- .body(equalTo(QuarkusPlatformHttpEngine.class.getName()));
- RestAssured.given().get("/platform-http/registry/" +
PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)
- .then()
- .statusCode(200)
- .body(equalTo(PlatformHttpComponent.class.getName()));
+ @Disabled("See https://github.com/quarkusio/quarkus/issues/4408")
+ @Test
+ public void testInvalidMethod() {
+ RestAssured.post("/platform-http/hello")
+ .then().statusCode(405);
}
}