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-k-runtime.git
commit 16070e564ee4aca1e05366f5fad1859f62d4754a Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Mon Aug 17 14:16:12 2020 +0200 [quarkus] add tests for jvm only loaders #215 --- .../src/main/resources/application.properties | 8 +- .../src/main/resources/application.properties | 11 +-- .../src/main/resources/application.properties | 11 +-- .../pom.xml | 22 +----- .../camel/k/loader/yaml/quarkus/Application.java | 45 +++++++++++ .../src/main/resources/application.properties | 8 +- .../k/loader/yaml/quarkus}/ExtensionTest.java | 10 ++- .../src/test/resources/routes.groovy} | 9 +-- .../pom.xml | 22 +----- .../camel/k/loader/java/quarkus/Application.java | 45 +++++++++++ .../src/main/resources/application.properties | 8 +- .../camel/k/loader/java/java}/ExtensionTest.java | 12 +-- .../src/test/resources/MyRoutes.java} | 13 ++-- .../camel-k-quarkus-itests-loader-js/pom.xml | 18 +---- .../camel/k/loader/js/quarkus/Application.java | 45 +++++++++++ .../loader/js/quarkus/deployment/Application.java | 89 ---------------------- .../src/main/resources/application.properties | 11 +-- .../js/quarkus/{deployment => }/ExtensionIT.java | 2 +- .../js/quarkus/{deployment => }/ExtensionTest.java | 2 +- .../pom.xml | 38 +++++---- .../camel/k/loader/support/LoaderSupport.java} | 45 +++++------ .../camel-k-quarkus-itests-loader-xml/pom.xml | 18 +---- .../camel/k/loader/xml/quarkus/Application.java | 45 +++++++++++ .../src/main/resources/application.properties | 7 +- .../xml/quarkus/{deployment => }/ExtensionIT.java | 2 +- .../quarkus/{deployment => }/ExtensionTest.java | 2 +- .../camel-k-quarkus-itests-loader-yaml/pom.xml | 18 +---- .../camel/k/loader/yaml/quarkus/Application.java | 45 +++++++++++ .../yaml/quarkus/deployment/Application.java | 87 --------------------- .../src/main/resources/application.properties | 11 +-- .../yaml/quarkus/{deployment => }/ExtensionIT.java | 2 +- .../quarkus/{deployment => }/ExtensionTest.java | 2 +- .../camel-k-quarkus-itests-polyglot/pom.xml | 14 +--- .../k/itests/polyglot/quarkus/Application.java | 43 +---------- .../src/main/resources/application.properties | 12 +-- camel-k-quarkus/camel-k-quarkus-itests/pom.xml | 3 + pom.xml | 10 ++- 37 files changed, 335 insertions(+), 460 deletions(-) diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/resources/application.properties index d43bc0b..73989eb 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/resources/application.properties @@ -14,14 +14,8 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false - -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/resources/application.properties index 2958915..a775e51 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/resources/application.properties @@ -14,11 +14,10 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = true quarkus.banner.enabled = false # @@ -26,11 +25,3 @@ quarkus.banner.enabled = false # quarkus.camel.main.routes-discovery.enabled = false -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx - -# -# Integration -# diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties index b4cc6d4..a775e51 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties @@ -14,11 +14,10 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # @@ -26,11 +25,3 @@ quarkus.banner.enabled = false # quarkus.camel.main.routes-discovery.enabled = false -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx - -# -# Integration -# diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/pom.xml similarity index 89% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/pom.xml index 82284c4..4c2ce66 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/pom.xml @@ -25,12 +25,12 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-k-quarkus-itests-loader-js</artifactId> + <artifactId>camel-k-quarkus-itests-loader-groovy</artifactId> <dependencies> <dependency> <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-quarkus-loader-js</artifactId> + <artifactId>camel-k-quarkus-loader-groovy</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> @@ -40,23 +40,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> - - <!-- quarkus dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-undertow</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java new file mode 100644 index 0000000..f2d4ea5 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.k.loader.yaml.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "groovy", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/resources/application.properties similarity index 89% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/resources/application.properties index 73b0e70..9af8787 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/main/resources/application.properties @@ -14,19 +14,13 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # # Quarkus :: Camel # quarkus.camel.main.routes-discovery.enabled = false - -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java similarity index 90% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java index 391e23f..0d27c28 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.js.quarkus.deployment; +package org.apache.camel.k.loader.yaml.quarkus; import java.io.IOException; import java.io.InputStream; import javax.ws.rs.core.MediaType; +import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.path.json.JsonPath; @@ -29,13 +30,14 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +@DisabledOnNativeImage @QuarkusTest public class ExtensionTest { @Test public void testLoadRoutes() throws IOException { String code; - try (InputStream is = ExtensionTest.class.getResourceAsStream("/routes.js")) { + try (InputStream is = ExtensionTest.class.getResourceAsStream("/routes.groovy")) { code = IOHelper.loadText(is); } @@ -51,7 +53,7 @@ public class ExtensionTest { .jsonPath(); assertThat(p.getList("components", String.class)).contains("direct", "log"); - assertThat(p.getList("routes", String.class)).contains("js"); - assertThat(p.getList("endpoints", String.class)).contains("direct://js", "log://js"); + assertThat(p.getList("routes", String.class)).contains("groovy"); + assertThat(p.getList("endpoints", String.class)).contains("direct://groovy", "log://groovy"); } } diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/resources/routes.groovy similarity index 82% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/resources/routes.groovy index 19ca084..a96deb2 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-groovy/src/test/resources/routes.groovy @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.js.quarkus.deployment; -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class ExtensionIT extends ExtensionTest { -} \ No newline at end of file +from('direct:groovy') + .routeId('groovy') + .to('log:groovy') \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/pom.xml similarity index 89% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/pom.xml index 82284c4..f70ea8b 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/pom.xml @@ -25,12 +25,12 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-k-quarkus-itests-loader-js</artifactId> + <artifactId>camel-k-quarkus-itests-loader-java</artifactId> <dependencies> <dependency> <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-quarkus-loader-js</artifactId> + <artifactId>camel-k-quarkus-loader-java</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> @@ -40,23 +40,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> - - <!-- quarkus dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-undertow</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java new file mode 100644 index 0000000..3cd6dce --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.k.loader.java.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "java", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/resources/application.properties similarity index 89% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/resources/application.properties index 73b0e70..9af8787 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/resources/application.properties @@ -14,19 +14,13 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # # Quarkus :: Camel # quarkus.camel.main.routes-discovery.enabled = false - -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/ExtensionTest.java similarity index 88% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/ExtensionTest.java index 391e23f..78f78f3 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/ExtensionTest.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.js.quarkus.deployment; +package org.apache.camel.k.loader.java.java; import java.io.IOException; import java.io.InputStream; import javax.ws.rs.core.MediaType; +import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.path.json.JsonPath; @@ -29,13 +30,14 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +@DisabledOnNativeImage @QuarkusTest public class ExtensionTest { @Test public void testLoadRoutes() throws IOException { String code; - try (InputStream is = ExtensionTest.class.getResourceAsStream("/routes.js")) { + try (InputStream is = ExtensionTest.class.getResourceAsStream("/MyRoutes.java")) { code = IOHelper.loadText(is); } @@ -43,7 +45,7 @@ public class ExtensionTest { .contentType(MediaType.TEXT_PLAIN) .accept(MediaType.APPLICATION_JSON) .body(code) - .post("/test/load-routes/MyRoute") + .post("/test/load-routes/MyRoutes") .then() .statusCode(200) .extract() @@ -51,7 +53,7 @@ public class ExtensionTest { .jsonPath(); assertThat(p.getList("components", String.class)).contains("direct", "log"); - assertThat(p.getList("routes", String.class)).contains("js"); - assertThat(p.getList("endpoints", String.class)).contains("direct://js", "log://js"); + assertThat(p.getList("routes", String.class)).contains("java"); + assertThat(p.getList("endpoints", String.class)).contains("direct://java", "log://java"); } } diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/resources/MyRoutes.java similarity index 76% copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/resources/MyRoutes.java index 80588b2..d305e3e 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/resources/MyRoutes.java @@ -14,10 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.quarkus.deployment; +import org.apache.camel.builder.RouteBuilder; -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class ExtensionIT extends ExtensionTest { +public class MyRoutes extends RouteBuilder { + @Override + public void configure() throws Exception { + from("direct:java") + .routeId("java") + .to("log:java"); + } } \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml index 82284c4..167c2ea 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/pom.xml @@ -40,23 +40,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> - - <!-- quarkus dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-undertow</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/Application.java new file mode 100644 index 0000000..7c3d6f0 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.k.loader.js.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "js", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/deployment/Application.java deleted file mode 100644 index aed2105..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/java/org/apache/camel/k/loader/js/quarkus/deployment/Application.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.k.loader.js.quarkus.deployment; - -import java.nio.charset.StandardCharsets; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.Json; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consume; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.SourceLoader; -import org.apache.camel.k.Sources; -import org.apache.camel.k.loader.js.JavaScriptSourceLoader; - -@Path("/test") -@ApplicationScoped -public class Application { - @Inject - CamelContext context; - - @POST - @Path("/load-routes/{name}") - @Consume(MediaType.TEXT_PLAIN) - @Produces(MediaType.APPLICATION_JSON) - public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { - final Runtime runtime = Runtime.on(context); - final Source source = Sources.fromBytes(name, "js", null, code.getBytes(StandardCharsets.UTF_8)); - final SourceLoader loader = new JavaScriptSourceLoader(); - final SourceLoader.Result result = loader.load(Runtime.on(context), source); - - result.builder().ifPresent(runtime::addRoutes); - result.configuration().ifPresent(runtime::addConfiguration); - - loader.load(Runtime.on(context), source); - - return Json.createObjectBuilder() - .add("components", extractComponents()) - .add("routes", extractRoutes()) - .add("endpoints", extractEndpoints()) - .build(); - } - - - private JsonArrayBuilder extractComponents() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getComponentNames().forEach(answer::add); - - return answer; - } - - private JsonArrayBuilder extractRoutes() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getRoutes().forEach(r -> answer.add(r.getId())); - - return answer; - } - - private JsonArrayBuilder extractEndpoints() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri())); - - return answer; - } -} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/resources/application.properties index b4cc6d4..a775e51 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/main/resources/application.properties @@ -14,11 +14,10 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # @@ -26,11 +25,3 @@ quarkus.banner.enabled = false # quarkus.camel.main.routes-discovery.enabled = false -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx - -# -# Integration -# diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionIT.java similarity index 94% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionIT.java index 19ca084..4045c21 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionIT.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionIT.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.js.quarkus.deployment; +package org.apache.camel.k.loader.js.quarkus; import io.quarkus.test.junit.NativeImageTest; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionTest.java similarity index 97% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionTest.java index 391e23f..9fb4022 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/deployment/ExtensionTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-js/src/test/java/org/apache/camel/k/loader/js/quarkus/ExtensionTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.js.quarkus.deployment; +package org.apache.camel.k.loader.js.quarkus; import java.io.IOException; import java.io.InputStream; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/pom.xml similarity index 61% copy from camel-k-quarkus/camel-k-quarkus-itests/pom.xml copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/pom.xml index 2fdcc1b..406d758 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/pom.xml @@ -20,22 +20,32 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-quarkus</artifactId> + <artifactId>camel-k-quarkus-itests</artifactId> <version>1.5.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <packaging>pom</packaging> - - <artifactId>camel-k-quarkus-itests</artifactId> - - <modules> - <module>camel-k-quarkus-itests-core</module> - <module>camel-k-quarkus-itests-cron</module> - <module>camel-k-quarkus-itests-knative</module> - <module>camel-k-quarkus-itests-loader-js</module> - <module>camel-k-quarkus-itests-loader-xml</module> - <module>camel-k-quarkus-itests-loader-yaml</module> - <module>camel-k-quarkus-itests-polyglot</module> - </modules> + + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-core</artifactId> + </dependency> + + <!-- quarkus dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jsonb</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jsonb</artifactId> + </dependency> + </dependencies> </project> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/src/main/java/org/apache/camel/k/loader/support/LoaderSupport.java similarity index 62% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/deployment/Application.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/src/main/java/org/apache/camel/k/loader/support/LoaderSupport.java index 3d1b521..7e36b83 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/deployment/Application.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-support/src/main/java/org/apache/camel/k/loader/support/LoaderSupport.java @@ -14,71 +14,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.xml.quarkus.deployment; +package org.apache.camel.k.loader.support; import java.nio.charset.StandardCharsets; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; import javax.json.Json; import javax.json.JsonArrayBuilder; import javax.json.JsonObject; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.apache.camel.CamelContext; -import org.apache.camel.Consume; import org.apache.camel.k.Runtime; import org.apache.camel.k.Source; import org.apache.camel.k.SourceLoader; import org.apache.camel.k.Sources; -import org.apache.camel.k.loader.xml.XmlSourceLoader; -@Path("/test") -@ApplicationScoped -public class Application { - @Inject - CamelContext context; +public final class LoaderSupport { + private LoaderSupport() { + } - @POST - @Path("/load-routes/{name}") - @Consume(MediaType.TEXT_PLAIN) - @Produces(MediaType.APPLICATION_JSON) - public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + public static JsonObject inspectSource(CamelContext context, String name, String loaderId, byte[] code) throws Exception { + final SourceLoader loader = context.getRegistry().lookupByNameAndType(loaderId, SourceLoader.class); final Runtime runtime = Runtime.on(context); - final Source source = Sources.fromBytes(name, "xml", null, code.getBytes(StandardCharsets.UTF_8)); - final SourceLoader loader = new XmlSourceLoader(); + final Source source = Sources.fromBytes(name, loaderId, null, code); final SourceLoader.Result result = loader.load(Runtime.on(context), source); result.builder().ifPresent(runtime::addRoutes); result.configuration().ifPresent(runtime::addConfiguration); return Json.createObjectBuilder() - .add("components", extractComponents()) - .add("routes", extractRoutes()) - .add("endpoints", extractEndpoints()) + .add("components", extractComponents(context)) + .add("routes", extractRoutes(context)) + .add("endpoints", extractEndpoints(context)) .build(); } + public static JsonObject inspectSource(CamelContext context, String name, String loaderId, String code) throws Exception { + return inspectSource(context, name, loaderId, code.getBytes(StandardCharsets.UTF_8)); + } + - private JsonArrayBuilder extractComponents() { + public static JsonArrayBuilder extractComponents(CamelContext context) { JsonArrayBuilder answer = Json.createArrayBuilder(); context.getComponentNames().forEach(answer::add); return answer; } - private JsonArrayBuilder extractRoutes() { + public static JsonArrayBuilder extractRoutes(CamelContext context) { JsonArrayBuilder answer = Json.createArrayBuilder(); context.getRoutes().forEach(r -> answer.add(r.getId())); return answer; } - private JsonArrayBuilder extractEndpoints() { + public static JsonArrayBuilder extractEndpoints(CamelContext context) { JsonArrayBuilder answer = Json.createArrayBuilder(); context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri())); diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/pom.xml index c8dee07..a3907d3 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/pom.xml @@ -40,23 +40,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> - - <!-- quarkus dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-undertow</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/Application.java new file mode 100644 index 0000000..8050166 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/java/org/apache/camel/k/loader/xml/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.k.loader.xml.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "xml", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties index 73b0e70..a775e51 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/main/resources/application.properties @@ -14,11 +14,10 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # @@ -26,7 +25,3 @@ quarkus.banner.enabled = false # quarkus.camel.main.routes-discovery.enabled = false -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionIT.java similarity index 93% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionIT.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionIT.java index c0fee9c..81146e8 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionIT.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionIT.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.xml.quarkus.deployment; +package org.apache.camel.k.loader.xml.quarkus; import io.quarkus.test.junit.NativeImageTest; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionTest.java similarity index 97% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionTest.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionTest.java index b3ab341..12ffd61 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/deployment/ExtensionTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-xml/src/test/java/org/apache/camel/k/loader/xml/quarkus/ExtensionTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.xml.quarkus.deployment; +package org.apache.camel.k.loader.xml.quarkus; import java.io.IOException; import java.io.InputStream; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/pom.xml index cc1c52f..fc107fd 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/pom.xml @@ -40,23 +40,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> - - <!-- quarkus dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-undertow</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java new file mode 100644 index 0000000..7419d2a --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.k.loader.yaml.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "yaml", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/Application.java deleted file mode 100644 index c270118..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/Application.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.k.loader.yaml.quarkus.deployment; - -import java.nio.charset.StandardCharsets; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.Json; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consume; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.SourceLoader; -import org.apache.camel.k.Sources; -import org.apache.camel.k.loader.yaml.YamlSourceLoader; - -@Path("/test") -@ApplicationScoped -public class Application { - @Inject - CamelContext context; - - @POST - @Path("/load-routes/{name}") - @Consume(MediaType.TEXT_PLAIN) - @Produces(MediaType.APPLICATION_JSON) - public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { - final Runtime runtime = Runtime.on(context); - final Source source = Sources.fromBytes(name, "yaml", null, code.getBytes(StandardCharsets.UTF_8)); - final SourceLoader loader = new YamlSourceLoader(); - final SourceLoader.Result result = loader.load(Runtime.on(context), source); - - result.builder().ifPresent(runtime::addRoutes); - result.configuration().ifPresent(runtime::addConfiguration); - - return Json.createObjectBuilder() - .add("components", extractComponents()) - .add("routes", extractRoutes()) - .add("endpoints", extractEndpoints()) - .build(); - } - - - private JsonArrayBuilder extractComponents() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getComponentNames().forEach(answer::add); - - return answer; - } - - private JsonArrayBuilder extractRoutes() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getRoutes().forEach(r -> answer.add(r.getId())); - - return answer; - } - - private JsonArrayBuilder extractEndpoints() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri())); - - return answer; - } -} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/resources/application.properties index b4cc6d4..a775e51 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/main/resources/application.properties @@ -14,11 +14,10 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = false quarkus.banner.enabled = false # @@ -26,11 +25,3 @@ quarkus.banner.enabled = false # quarkus.camel.main.routes-discovery.enabled = false -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx - -# -# Integration -# diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionIT.java similarity index 93% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionIT.java index 80588b2..4ff2701 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionIT.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionIT.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.quarkus.deployment; +package org.apache.camel.k.loader.yaml.quarkus; import io.quarkus.test.junit.NativeImageTest; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java similarity index 97% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionTest.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java index 46692d2..1d93719 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/deployment/ExtensionTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-yaml/src/test/java/org/apache/camel/k/loader/yaml/quarkus/ExtensionTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.quarkus.deployment; +package org.apache.camel.k.loader.yaml.quarkus; import java.io.IOException; import java.io.InputStream; diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/pom.xml index cd9a115..b090825 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/pom.xml @@ -48,19 +48,9 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jackson</artifactId> </dependency> - - <!-- quarkus dependencies --> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> </dependency> <!-- test dependencies --> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/java/org/apache/camel/k/itests/polyglot/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/java/org/apache/camel/k/itests/polyglot/quarkus/Application.java index a85dcc5..9f80a18 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/java/org/apache/camel/k/itests/polyglot/quarkus/Application.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/java/org/apache/camel/k/itests/polyglot/quarkus/Application.java @@ -18,8 +18,6 @@ package org.apache.camel.k.itests.polyglot.quarkus; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import javax.json.Json; -import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -29,10 +27,7 @@ import javax.ws.rs.core.MediaType; import org.apache.camel.CamelContext; import org.apache.camel.Consume; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.SourceLoader; -import org.apache.camel.k.Sources; +import org.apache.camel.k.loader.support.LoaderSupport; @Path("/test") @ApplicationScoped @@ -45,40 +40,6 @@ public class Application { @Consume(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) public JsonObject loadRoutes(@PathParam("loaderName") String loaderName, @PathParam("name") String name, byte[] code) throws Exception { - final SourceLoader loader = context.getRegistry().lookupByNameAndType(loaderName, SourceLoader.class); - final Runtime runtime = Runtime.on(context); - final Source source = Sources.fromBytes(name, loaderName, null, code); - final SourceLoader.Result result = loader.load(Runtime.on(context), source); - - result.builder().ifPresent(runtime::addRoutes); - result.configuration().ifPresent(runtime::addConfiguration); - - return Json.createObjectBuilder() - .add("components", extractComponents()) - .add("routes", extractRoutes()) - .add("endpoints", extractEndpoints()) - .build(); - } - - - private JsonArrayBuilder extractComponents() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getComponentNames().forEach(answer::add); - - return answer; - } - - private JsonArrayBuilder extractRoutes() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getRoutes().forEach(r -> answer.add(r.getId())); - - return answer; - } - - private JsonArrayBuilder extractEndpoints() { - JsonArrayBuilder answer = Json.createArrayBuilder(); - context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri())); - - return answer; + return LoaderSupport.inspectSource(context, name, loaderName, code); } } diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/resources/application.properties index 2958915..9af8787 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-polyglot/src/main/resources/application.properties @@ -14,23 +14,13 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- + # # Quarkus # -quarkus.log.file.enable = false -quarkus.log.console.enable = true quarkus.banner.enabled = false # # Quarkus :: Camel # quarkus.camel.main.routes-discovery.enabled = false - -# -# Camel -# -camel.context.name = camel-k-quarkus-ctx - -# -# Integration -# diff --git a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml index 2fdcc1b..c886cd0 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml @@ -32,6 +32,9 @@ <module>camel-k-quarkus-itests-core</module> <module>camel-k-quarkus-itests-cron</module> <module>camel-k-quarkus-itests-knative</module> + <module>camel-k-quarkus-itests-loader-support</module> + <module>camel-k-quarkus-itests-loader-groovy</module> + <module>camel-k-quarkus-itests-loader-java</module> <module>camel-k-quarkus-itests-loader-js</module> <module>camel-k-quarkus-itests-loader-xml</module> <module>camel-k-quarkus-itests-loader-yaml</module> diff --git a/pom.xml b/pom.xml index d3d21b5..ccacb1a 100644 --- a/pom.xml +++ b/pom.xml @@ -271,7 +271,7 @@ <releases> <enabled>false</enabled> </releases> - </repository> + </repository> </repositories> <pluginRepositories> @@ -482,6 +482,14 @@ <version>${project.version}</version> </dependency> + <!-- runtime - quarkus (tests)--> + + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-itests-loader-support</artifactId> + <version>${project.version}</version> + </dependency> + <!-- loaders --> <dependency> <groupId>org.apache.camel.k</groupId>