This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch camel-master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 37265024d6dd5dcd8ad0c72efe439bc27eb651d4 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Fri Dec 11 18:12:33 2020 +0100 Test with camel.main.lightweight=true #2063 --- integration-tests/rest/pom.xml | 19 ++++++++++++++ .../quarkus/component/rest/it/RestResource.java | 8 ++++++ .../quarkus/component/rest/it/RestRoutes.java} | 30 ++++++++++++---------- .../rest/src/main/resources/application.properties | 17 ++++++++++++ .../camel/quarkus/component/rest/it/RestTest.java | 21 +++++++++++++++ 5 files changed, 81 insertions(+), 14 deletions(-) diff --git a/integration-tests/rest/pom.xml b/integration-tests/rest/pom.xml index e7889a4..b314b58 100644 --- a/integration-tests/rest/pom.xml +++ b/integration-tests/rest/pom.xml @@ -32,6 +32,10 @@ <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-main</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest</artifactId> </dependency> <dependency> @@ -54,6 +58,21 @@ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-main-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest-deployment</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java index 90f8c63..b0e8f05 100644 --- a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java +++ b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestResource.java @@ -26,6 +26,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.apache.camel.CamelContext; +import org.apache.camel.ExtendedCamelContext; @Path("/rest") @ApplicationScoped @@ -41,4 +42,11 @@ public class RestResource { .add("component", camelContext.getRestConfiguration().getComponent()) .build(); } + + @Path("/inspect/camel-context/lightweight") + @GET + @Produces(MediaType.TEXT_PLAIN) + public boolean lightweight() { + return camelContext.adapt(ExtendedCamelContext.class).isLightweight(); + } } diff --git a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java similarity index 62% copy from integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java copy to integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java index 1deb123..f001379 100644 --- a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java +++ b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java @@ -16,21 +16,23 @@ */ 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 org.apache.camel.builder.RouteBuilder; -import static org.hamcrest.Matchers.is; +public class RestRoutes extends RouteBuilder { -@QuarkusTest -class RestTest { - @Test - public void inspectConfiguration() { - RestAssured.when() - .get("/rest/inspect/configuration") - .then() - .statusCode(200) - .body("component", is(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)); + @Override + public void configure() { + rest() + + .get("/rest/get") + .route() + .setBody(constant("GET: /rest/get")) + .endRest() + + .post("/rest/post") + .consumes("text/plain").produces("text/plain") + .route() + .setBody(constant("POST: /rest/post")) + .endRest(); } } diff --git a/integration-tests/rest/src/main/resources/application.properties b/integration-tests/rest/src/main/resources/application.properties new file mode 100644 index 0000000..32eeb16 --- /dev/null +++ b/integration-tests/rest/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +camel.main.lightweight=true \ No newline at end of file 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 index 1deb123..f149919 100644 --- 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 @@ -21,6 +21,7 @@ import io.restassured.RestAssured; import org.apache.camel.component.platform.http.PlatformHttpConstants; import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.is; @QuarkusTest @@ -33,4 +34,24 @@ class RestTest { .statusCode(200) .body("component", is(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)); } + + @Test + public void rest() throws Throwable { + RestAssured.get("/rest/get") + .then().body(equalTo("GET: /rest/get")); + RestAssured.given() + .contentType("text/plain") + .post("/rest/post") + .then().body(equalTo("POST: /rest/post")); + } + + @Test + public void lightweight() throws Throwable { + RestAssured.when() + .get("/rest/inspect/camel-context/lightweight") + .then() + .statusCode(200) + .body(is("true")); + } + }