You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/27 17:22:28 UTC

[camel-quarkus] 02/02: platform-http should return 406 it it cannot satisfy the client accept header

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

commit f00b10b21d241b5a56e26d0eb5c9f4126babf0b2
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Oct 25 13:37:40 2019 +0200

    platform-http should return 406 it it cannot satisfy the client accept
    header
---
 .../http/runtime/QuarkusPlatformHttpConsumer.java  |  3 +++
 .../platform/http/it/PlatformHttpRouteBuilder.java |  3 +++
 .../component/http/server/it/PlatformHttpTest.java | 31 ++++++++++++++++++++++
 3 files changed, 37 insertions(+)

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 fd3beb8..46886d1 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
@@ -103,6 +103,9 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
         if (endpoint.getConsumes() != null) {
             newRoute.consumes(endpoint.getConsumes());
         }
+        if (endpoint.getProduces() != null) {
+            newRoute.produces(endpoint.getProduces());
+        }
 
         handlers.forEach(newRoute::handler);
 
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 d6b6bd0..e023020 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
@@ -84,5 +84,8 @@ public class PlatformHttpRouteBuilder extends RouteBuilder {
         from("platform-http:/platform-http/consumes?httpMethodRestrict=POST&consumes=text/plain")
             .setBody(simple("Hello ${body}"));
 
+        from("platform-http:/platform-http/produces?httpMethodRestrict=POST&produces=text/plain")
+            .setBody(simple("Hello ${body}"));
+
     }
 }
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 ced99c7..e95747c 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
@@ -89,6 +89,37 @@ class PlatformHttpTest {
             .statusCode(200);
     }
 
+
+    @Test
+    public void produces() throws Throwable {
+        RestAssured.given()
+            .accept("application/json")
+            .contentType("text/plain")
+            .post("/platform-http/rest-post")
+            .then()
+            .statusCode(406);
+
+        RestAssured.given()
+            .accept("text/plain")
+            .contentType("text/plain")
+            .post("/platform-http/rest-post")
+            .then()
+            .statusCode(200);
+
+        RestAssured.given()
+            .accept("application/json")
+            .contentType("text/plain")
+            .post("/platform-http/produces")
+            .then()
+            .statusCode(406);
+
+        RestAssured.given()
+            .accept("text/plain")
+            .contentType("text/plain")
+            .post("/platform-http/produces")
+            .then()
+            .statusCode(200);
+    }
     @Test
     public void invalidMethod() {
         RestAssured.post("/platform-http/hello")