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:26 UTC
[camel-quarkus] branch master updated (e74950e -> f00b10b)
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git.
from e74950e [maven-release-plugin] prepare for next development iteration
new 90a9143 Fix #326 platform-http should return 415 for an unaccepted content type
new f00b10b platform-http should return 406 it it cannot satisfy the client accept header
The 2 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:
.../platform/http/PlatformHttpComponent.java | 2 +
.../platform/http/PlatformHttpEndpoint.java | 24 ++++++++++
.../http/runtime/QuarkusPlatformHttpConsumer.java | 11 ++++-
.../platform/http/it/PlatformHttpRouteBuilder.java | 6 +++
.../component/http/server/it/PlatformHttpTest.java | 55 ++++++++++++++++++++--
5 files changed, 93 insertions(+), 5 deletions(-)
[camel-quarkus] 01/02: Fix #326 platform-http should return 415 for
an unaccepted content type
Posted by lb...@apache.org.
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 90a9143a7c6b6aee1607b9453bdf772391155b82
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Oct 25 12:59:33 2019 +0200
Fix #326 platform-http should return 415 for an unaccepted content type
---
.../platform/http/PlatformHttpComponent.java | 2 ++
.../platform/http/PlatformHttpEndpoint.java | 24 ++++++++++++++++++++++
.../http/runtime/QuarkusPlatformHttpConsumer.java | 8 ++++++--
.../platform/http/it/PlatformHttpRouteBuilder.java | 3 +++
.../component/http/server/it/PlatformHttpTest.java | 24 +++++++++++++++++++---
5 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
index c9764ba..22565b7 100644
--- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
+++ b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java
@@ -143,6 +143,8 @@ public class PlatformHttpComponent extends DefaultComponent implements RestConsu
PlatformHttpEndpoint endpoint = camelContext.getEndpoint(url, PlatformHttpEndpoint.class);
setProperties(camelContext, endpoint, parameters);
+ endpoint.setConsumes(consumes);
+ endpoint.setProduces(produces);
// configure consumer properties
Consumer consumer = endpoint.createConsumer(processor);
diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
index f7d7c3a..5f8056d 100644
--- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
+++ b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
@@ -44,6 +44,14 @@ public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoi
+ " If no methods are specified, all methods will be served.")
private String httpMethodRestrict;
+ @UriParam(label = "consumer", description = "The content type this endpoint accepts as an input, such as"
+ + " application/xml or application/json. <code>null</code> or <code>*/*</code> mean no restriction.")
+ private String consumes;
+
+ @UriParam(label = "consumer", description = "The content type this endpoint produces, such as"
+ + " application/xml or application/json.")
+ private String produces;
+
@UriParam(label = "consumer,advanced", description = "A comma or whitespace separated list of file extensions."
+ " Uploads having these extensions will be stored locally."
+ " Null value or asterisk (*) will allow all files.")
@@ -108,6 +116,22 @@ public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoi
this.fileNameExtWhitelist = fileNameExtWhitelist;
}
+ public String getConsumes() {
+ return consumes;
+ }
+
+ public void setConsumes(String consumes) {
+ this.consumes = consumes;
+ }
+
+ public String getProduces() {
+ return produces;
+ }
+
+ public void setProduces(String produces) {
+ this.produces = produces;
+ }
+
@Override
protected void doStart() throws Exception {
super.doStart();
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 5f30a39..fd3beb8 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
@@ -92,13 +92,17 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
protected void doStart() throws Exception {
super.doStart();
- final String path = getEndpoint().getPath();
+ final PlatformHttpEndpoint endpoint = getEndpoint();
+ final String path = endpoint.getPath();
final Route newRoute = router.route(path);
- final Set<Method> methods = Method.parseList(getEndpoint().getHttpMethodRestrict());
+ final Set<Method> methods = Method.parseList(endpoint.getHttpMethodRestrict());
if (!methods.equals(Method.getAll())) {
methods.stream().forEach(m -> newRoute.method(HttpMethod.valueOf(m.name())));
}
+ if (endpoint.getConsumes() != null) {
+ newRoute.consumes(endpoint.getConsumes());
+ }
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 5ddf310..d6b6bd0 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
@@ -81,5 +81,8 @@ public class PlatformHttpRouteBuilder extends RouteBuilder {
.to("log:response-code")
.setHeader(Exchange.HTTP_RESPONSE_CODE).constant(299);
+ from("platform-http:/platform-http/consumes?httpMethodRestrict=POST&consumes=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 d1eba8f..ced99c7 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
@@ -62,13 +62,31 @@ class PlatformHttpTest {
.then().body(equalTo("POST: /rest-post"));
}
- @Disabled("See https://github.com/apache/camel-quarkus/issues/326")
@Test
- public void restConsumes() throws Throwable {
+ public void consumes() throws Throwable {
RestAssured.given()
.contentType("application/json")
.post("/platform-http/rest-post")
- .then().statusCode(415);
+ .then()
+ .statusCode(415);
+
+ RestAssured.given()
+ .contentType("text/plain")
+ .post("/platform-http/rest-post")
+ .then()
+ .statusCode(200);
+
+ RestAssured.given()
+ .contentType("application/json")
+ .post("/platform-http/consumes")
+ .then()
+ .statusCode(415);
+
+ RestAssured.given()
+ .contentType("text/plain")
+ .post("/platform-http/consumes")
+ .then()
+ .statusCode(200);
}
@Test
[camel-quarkus] 02/02: platform-http should return 406 it it cannot
satisfy the client accept header
Posted by lb...@apache.org.
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")