This is an automated email from the ASF dual-hosted git repository.
jamesnetherton 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 9512ba2 Make camel-quarkus-rest depend on camel-quarkus-platform-http
#1244
9512ba2 is described below
commit 9512ba20acf82243887fec272b3725be95692ebc
Author: lburgazzoli <[email protected]>
AuthorDate: Mon May 25 10:57:04 2020 +0200
Make camel-quarkus-rest depend on camel-quarkus-platform-http #1244
---
docs/modules/ROOT/pages/extensions/rest.adoc | 5 +++
extensions/rest/deployment/pom.xml | 4 ++
.../component/rest/deployment/RestProcessor.java | 10 +++++
extensions/rest/runtime/pom.xml | 4 ++
.../rest/runtime/src/main/doc/configuration.adoc | 1 +
.../camel/quarkus/component/rest/RestRecorder.java | 44 ++++++++++++++++++++
integration-tests/pom.xml | 1 +
integration-tests/rest-binding-mode-xml/pom.xml | 4 --
.../{rest-binding-mode-xml => rest}/pom.xml | 23 +++--------
.../quarkus/component/rest/it/RestResource.java} | 48 ++++++++++------------
.../camel/quarkus/component/rest/it/RestIT.java | 23 +++++++++++
.../camel/quarkus/component/rest/it/RestTest.java | 36 ++++++++++++++++
.../quarkus/component/servlet/CamelRoute.java | 5 +++
tooling/scripts/test-categories.yaml | 1 +
14 files changed, 160 insertions(+), 49 deletions(-)
diff --git a/docs/modules/ROOT/pages/extensions/rest.adoc
b/docs/modules/ROOT/pages/extensions/rest.adoc
index 524f6a9..2c3589e 100644
--- a/docs/modules/ROOT/pages/extensions/rest.adoc
+++ b/docs/modules/ROOT/pages/extensions/rest.adoc
@@ -27,3 +27,8 @@ Please refer to the above links for usage and configuration
details.
----
Check the xref:user-guide/index.adoc[User guide] for more information about
writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+This extension configures the xref:extensions/platform-http.adoc as the
component that provides the REST transport.
+
diff --git a/extensions/rest/deployment/pom.xml
b/extensions/rest/deployment/pom.xml
index e18c9b7..56b7ee1 100644
--- a/extensions/rest/deployment/pom.xml
+++ b/extensions/rest/deployment/pom.xml
@@ -36,6 +36,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
</dependencies>
diff --git
a/extensions/rest/deployment/src/main/java/org/apache/camel/quarkus/component/rest/deployment/RestProcessor.java
b/extensions/rest/deployment/src/main/java/org/apache/camel/quarkus/component/rest/deployment/RestProcessor.java
index 3f8409a..b17fc2f 100644
---
a/extensions/rest/deployment/src/main/java/org/apache/camel/quarkus/component/rest/deployment/RestProcessor.java
+++
b/extensions/rest/deployment/src/main/java/org/apache/camel/quarkus/component/rest/deployment/RestProcessor.java
@@ -17,7 +17,11 @@
package org.apache.camel.quarkus.component.rest.deployment;
import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
+import org.apache.camel.quarkus.component.rest.RestRecorder;
+import
org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
import
org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
@@ -37,4 +41,10 @@ class RestProcessor {
"META-INF/services/org/apache/camel/rest/*",
"META-INF/services/org/apache/camel/restapi/*");
}
+
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ CamelContextCustomizerBuildItem customizeCamelContext(RestRecorder
recorder) {
+ return new
CamelContextCustomizerBuildItem(recorder.customizeCamelContext());
+ }
}
diff --git a/extensions/rest/runtime/pom.xml b/extensions/rest/runtime/pom.xml
index 4ef1e2f..7799e0f 100644
--- a/extensions/rest/runtime/pom.xml
+++ b/extensions/rest/runtime/pom.xml
@@ -51,6 +51,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ </dependency>
<!-- camel -->
<dependency>
diff --git a/extensions/rest/runtime/src/main/doc/configuration.adoc
b/extensions/rest/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000..05a6646
--- /dev/null
+++ b/extensions/rest/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1 @@
+This extension configures the xref:extensions/platform-http.adoc as the
component that provides the REST transport.
\ No newline at end of file
diff --git
a/extensions/rest/runtime/src/main/java/org/apache/camel/quarkus/component/rest/RestRecorder.java
b/extensions/rest/runtime/src/main/java/org/apache/camel/quarkus/component/rest/RestRecorder.java
new file mode 100644
index 0000000..db3dd82
--- /dev/null
+++
b/extensions/rest/runtime/src/main/java/org/apache/camel/quarkus/component/rest/RestRecorder.java
@@ -0,0 +1,44 @@
+/*
+ * 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.quarkus.component.rest;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.platform.http.PlatformHttpConstants;
+import org.apache.camel.quarkus.core.CamelContextCustomizer;
+import org.jboss.logging.Logger;
+
+@Recorder
+public class RestRecorder {
+ public RuntimeValue<CamelContextCustomizer> customizeCamelContext() {
+ return new RuntimeValue<>(new RestCamelContextCustomizer());
+ }
+
+ private static class RestCamelContextCustomizer implements
CamelContextCustomizer {
+ @Override
+ public void customize(CamelContext context) {
+ String component = context.getRestConfiguration().getComponent();
+ if (component == null) {
+ Logger.getLogger(RestCamelContextCustomizer.class).debugf(
+ "Set %s as default component for Camel REST DSL",
PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);
+
+
context.getRestConfiguration().setComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);
+ }
+ }
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index b9a3835..a3fc1c8 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -125,6 +125,7 @@
<module>qute</module>
<module>reactive-streams</module>
<module>ref</module>
+ <module>rest</module>
<module>rest-binding-mode-xml</module>
<module>rest-openapi</module>
<module>salesforce</module>
diff --git a/integration-tests/rest-binding-mode-xml/pom.xml
b/integration-tests/rest-binding-mode-xml/pom.xml
index ac54620..792641f 100644
--- a/integration-tests/rest-binding-mode-xml/pom.xml
+++ b/integration-tests/rest-binding-mode-xml/pom.xml
@@ -42,10 +42,6 @@
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
<dependency>
diff --git a/integration-tests/rest-binding-mode-xml/pom.xml
b/integration-tests/rest/pom.xml
similarity index 84%
copy from integration-tests/rest-binding-mode-xml/pom.xml
copy to integration-tests/rest/pom.xml
index ac54620..feae05f 100644
--- a/integration-tests/rest-binding-mode-xml/pom.xml
+++ b/integration-tests/rest/pom.xml
@@ -25,9 +25,9 @@
<version>1.1.0-SNAPSHOT</version>
</parent>
-
<artifactId>camel-quarkus-integration-test-rest-binding-mode-xml</artifactId>
- <name>Camel Quarkus :: Integration Tests :: Rest :: Binding Mode XML</name>
- <description>Integration tests for Camel Quarkus Rest extension with XML
binding mode</description>
+ <artifactId>camel-quarkus-integration-test-rest</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Rest</name>
+ <description>Integration tests for Camel Quarkus Rest
extension</description>
<properties>
<!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
@@ -42,19 +42,11 @@
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-xml-jaxb</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jaxb</artifactId>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<!-- test dependencies -->
@@ -68,11 +60,6 @@
<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/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java
similarity index 51%
copy from
integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
copy to
integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java
index 8ba1c13..90f8c63 100644
---
a/integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
+++
b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java
@@ -14,37 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.servlet;
+package org.apache.camel.quarkus.component.rest.it;
import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.json.Json;
+import javax.json.JsonObject;
+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.builder.RouteBuilder;
+import org.apache.camel.CamelContext;
+@Path("/rest")
@ApplicationScoped
-public class CamelRoute extends RouteBuilder {
-
- @Override
- public void configure() {
-
- rest()
- .get("/rest-get")
- .route()
- .setBody(constant("GET: /rest-get"))
- .endRest()
- .post("/rest-post")
- .route()
- .setBody(constant("POST: /rest-post"))
- .endRest();
-
- from("servlet://hello?matchOnUriPrefix=true")
- .setBody(constant("GET: /hello"));
-
- from("servlet://custom?servletName=my-named-servlet")
- .setBody(constant("GET: /custom"));
-
- from("servlet://favorite?servletName=my-favorite-servlet")
- .setBody(constant("GET: /favorite"));
-
+public class RestResource {
+ @Inject
+ CamelContext camelContext;
+
+ @Path("/inspect/configuration")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public JsonObject inspectConfiguration() {
+ return Json.createObjectBuilder()
+ .add("component",
camelContext.getRestConfiguration().getComponent())
+ .build();
}
-
}
diff --git
a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestIT.java
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestIT.java
new file mode 100644
index 0000000..a46a79e
--- /dev/null
+++
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.quarkus.component.rest.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class RestIT extends RestTest {
+}
diff --git
a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
new file mode 100644
index 0000000..1deb123
--- /dev/null
+++
b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.quarkus.component.rest.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.component.platform.http.PlatformHttpConstants;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+class RestTest {
+ @Test
+ public void inspectConfiguration() {
+ RestAssured.when()
+ .get("/rest/inspect/configuration")
+ .then()
+ .statusCode(200)
+ .body("component",
is(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME));
+ }
+}
diff --git
a/integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
b/integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
index 8ba1c13..0730289 100644
---
a/integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
+++
b/integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/CamelRoute.java
@@ -25,6 +25,11 @@ public class CamelRoute extends RouteBuilder {
@Override
public void configure() {
+ // by default the camel-quarkus-rest component sets platform-http
+ // as the component that provides the transport and since here we
+ // are testing the servlet component. we have to force it
+ restConfiguration()
+ .component("servlet");
rest()
.get("/rest-get")
diff --git a/tooling/scripts/test-categories.yaml
b/tooling/scripts/test-categories.yaml
index 375ea1f..c8a6d9a 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -106,6 +106,7 @@ platform:
- platform-http
- platform-http-engine
- reactive-streams
+ - rest
- rest-openapi
saas:
- box