This is an automated email from the ASF dual-hosted git repository. ppalaga 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 1e938d8 Camel quarkus disable auto route discovery not working #1816 1e938d8 is described below commit 1e938d81ed3374c86913606fbcb0c7e4776eaedf Author: Luca Burgazzoli <lburgazz...@gmail.com> AuthorDate: Tue Sep 22 11:39:35 2020 +0200 Camel quarkus disable auto route discovery not working #1816 --- .../core/deployment/CamelContextProcessor.java | 8 +- .../apache/camel/quarkus/core/CamelRecorder.java | 4 + .../main/deployment/CamelMainProcessor.java | 13 +-- .../camel/quarkus/main/CamelMainRecorder.java | 14 ++- .../quarkus/main/CamelMainRoutesCollector.java | 99 +--------------------- .../main/resources/META-INF/quarkus-extension.yaml | 3 +- .../pom.xml | 62 +++++++++----- .../core/CoreDiscoveryDisabledResource.java | 56 ++++++++++++ .../quarkus/core/CoreDiscoveryDisabledRoutes.java | 29 +++++++ .../core/CoreDiscoveryDisabledRoutesCDI.java | 32 +++++++ .../src/main/resources/application.properties | 21 +++++ .../quarkus/core/CoreDiscoveryDisabledIT.java | 23 +++++ .../quarkus/core/CoreDiscoveryDisabledTest.java | 39 +++++++++ .../pom.xml | 71 +++++++++++----- .../main/MainDiscoveryDisabledResource.java | 56 ++++++++++++ .../quarkus/main/MainDiscoveryDisabledRoutes.java | 29 +++++++ .../main/MainDiscoveryDisabledRoutesCDI.java | 32 +++++++ .../src/main/resources/application.properties | 21 +++++ .../quarkus/main/MainDiscoveryDisabledIT.java | 23 +++++ .../quarkus/main/MainDiscoveryDisabledTest.java | 39 +++++++++ .../camel/quarkus/main/CoreMainXmlIoResource.java | 2 +- .../quarkus/main/CoreMainXmlJaxbResource.java | 2 +- .../camel/quarkus/main/CoreMainResource.java | 2 +- integration-tests/pom.xml | 2 + integration-tests/univocity-parsers/pom.xml | 15 ++++ tooling/scripts/test-categories.yaml | 4 +- 26 files changed, 536 insertions(+), 165 deletions(-) diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java index a488baa..6e16b7c 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java @@ -119,6 +119,7 @@ public class CamelContextProcessor { * @param routesBuilderClasses a list of known {@link org.apache.camel.RoutesBuilder} classes. * @param runtimeTasks a placeholder to ensure all the runtime task are properly are done. * to the registry. + * @param config a reference to the Camel Quarkus configuration * @return a build item holding a {@link CamelRuntime} instance. */ @Overridable @@ -135,7 +136,8 @@ public class CamelContextProcessor { CamelContextBuildItem context, List<RuntimeCamelContextCustomizerBuildItem> customizers, List<CamelRoutesBuilderClassBuildItem> routesBuilderClasses, - List<CamelRuntimeTaskBuildItem> runtimeTasks) { + List<CamelRuntimeTaskBuildItem> runtimeTasks, + CamelConfig config) { for (CamelRoutesBuilderClassBuildItem item : routesBuilderClasses) { // don't add routes builders that are known by the container @@ -146,7 +148,9 @@ public class CamelContextProcessor { recorder.addRoutes(context.getCamelContext(), item.getDotName().toString()); } - recorder.addRoutesFromContainer(context.getCamelContext()); + if (config.routesDiscovery.enabled) { + recorder.addRoutesFromContainer(context.getCamelContext()); + } // run the customizer before starting the context to give a last second // chance to amend camel context setup diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java index 3484a0c..1e8bc4e 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java @@ -107,6 +107,10 @@ public class CamelRecorder { return new RuntimeValue<>(new RegistryRoutesLoaders.Default()); } + public RuntimeValue<RegistryRoutesLoader> newDisabledRegistryRoutesLoader() { + return new RuntimeValue<>(new RegistryRoutesLoaders.Disabled()); + } + public RuntimeValue<Builder> factoryFinderResolverBuilder() { return new RuntimeValue<>(new FastFactoryFinderResolver.Builder()); } diff --git a/extensions-core/main/deployment/src/main/java/org/apache/camel/quarkus/main/deployment/CamelMainProcessor.java b/extensions-core/main/deployment/src/main/java/org/apache/camel/quarkus/main/deployment/CamelMainProcessor.java index 869434d..12ae8c8 100644 --- a/extensions-core/main/deployment/src/main/java/org/apache/camel/quarkus/main/deployment/CamelMainProcessor.java +++ b/extensions-core/main/deployment/src/main/java/org/apache/camel/quarkus/main/deployment/CamelMainProcessor.java @@ -33,6 +33,7 @@ import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.QuarkusMain; import org.apache.camel.CamelContext; +import org.apache.camel.quarkus.core.CamelConfig; import org.apache.camel.quarkus.core.CamelRecorder; import org.apache.camel.quarkus.core.CamelRuntime; import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem; @@ -66,8 +67,10 @@ public class CamelMainProcessor { @Overridable @BuildStep @Record(value = ExecutionTime.STATIC_INIT, optional = true) - public CamelRoutesLoaderBuildItems.Registry routesLoader(CamelRecorder recorder) { - return new CamelRoutesLoaderBuildItems.Registry(recorder.newDefaultRegistryRoutesLoader()); + public CamelRoutesLoaderBuildItems.Registry routesLoader(CamelConfig config, CamelRecorder recorder) { + return config.routesDiscovery.enabled + ? new CamelRoutesLoaderBuildItems.Registry(recorder.newDefaultRegistryRoutesLoader()) + : new CamelRoutesLoaderBuildItems.Registry(recorder.newDisabledRegistryRoutesLoader()); } @Overridable @@ -75,11 +78,9 @@ public class CamelMainProcessor { @Record(value = ExecutionTime.STATIC_INIT, optional = true) public CamelRoutesCollectorBuildItem routesCollector( CamelMainRecorder recorder, - CamelRoutesLoaderBuildItems.Registry registryRoutesLoader, - CamelRoutesLoaderBuildItems.Xml xmlRoutesLoader) { + CamelRoutesLoaderBuildItems.Registry registryRoutesLoader) { - return new CamelRoutesCollectorBuildItem( - recorder.newRoutesCollector(registryRoutesLoader.getLoader(), xmlRoutesLoader.getLoader())); + return new CamelRoutesCollectorBuildItem(recorder.newRoutesCollector(registryRoutesLoader.getLoader())); } /** diff --git a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java index 22baa7d..d7ba558 100644 --- a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java +++ b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java @@ -31,7 +31,6 @@ import org.apache.camel.quarkus.core.CamelContextCustomizer; import org.apache.camel.quarkus.core.CamelProducers; import org.apache.camel.quarkus.core.CamelRuntime; import org.apache.camel.quarkus.core.RegistryRoutesLoader; -import org.apache.camel.spi.XMLRoutesDefinitionLoader; @Recorder public class CamelMainRecorder { @@ -52,11 +51,11 @@ public class CamelMainRecorder { // no need to look for sources. main.setDefaultPropertyPlaceholderLocation("false"); - // xml rest/routes should be explicitly configured as an - // additional dependency is required thus, disable auto - // discovery + // xml rest/routes/templates should be explicitly configured as an + // additional dependency is required thus, disable auto discovery main.configure().setXmlRoutes("false"); main.configure().setXmlRests("false"); + main.configure().setXmlRouteTemplates("false"); // register to the container container.instance(CamelMainProducers.class).setMain(main); @@ -80,11 +79,8 @@ public class CamelMainRecorder { main.getValue().addMainListener(listener.getValue()); } - public RuntimeValue<RoutesCollector> newRoutesCollector( - RuntimeValue<RegistryRoutesLoader> registryRoutesLoader, - RuntimeValue<XMLRoutesDefinitionLoader> xmlRoutesLoader) { - - return new RuntimeValue<>(new CamelMainRoutesCollector(registryRoutesLoader.getValue(), xmlRoutesLoader.getValue())); + public RuntimeValue<RoutesCollector> newRoutesCollector(RuntimeValue<RegistryRoutesLoader> registryRoutesLoader) { + return new RuntimeValue<>(new CamelMainRoutesCollector(registryRoutesLoader.getValue())); } public void customizeContext(RuntimeValue<CamelMain> main, List<RuntimeValue<CamelContextCustomizer>> contextCustomizers) { diff --git a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java index 9498cc1..8595f53 100644 --- a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java +++ b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java @@ -16,44 +16,24 @@ */ package org.apache.camel.quarkus.main; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.ArrayList; import java.util.List; import org.apache.camel.CamelContext; -import org.apache.camel.ExtendedCamelContext; import org.apache.camel.RoutesBuilder; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.main.RoutesCollector; -import org.apache.camel.model.RouteTemplatesDefinition; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.rest.RestsDefinition; +import org.apache.camel.main.DefaultRoutesCollector; import org.apache.camel.quarkus.core.RegistryRoutesLoader; -import org.apache.camel.spi.PackageScanResourceResolver; -import org.apache.camel.spi.XMLRoutesDefinitionLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CamelMainRoutesCollector implements RoutesCollector { - private static final Logger LOGGER = LoggerFactory.getLogger(CamelMainRoutesCollector.class); +public class CamelMainRoutesCollector extends DefaultRoutesCollector { private final RegistryRoutesLoader registryRoutesLoader; - private final XMLRoutesDefinitionLoader xmlRoutesLoader; - public CamelMainRoutesCollector(RegistryRoutesLoader registryRoutesLoader, XMLRoutesDefinitionLoader xmlRoutesLoader) { + public CamelMainRoutesCollector(RegistryRoutesLoader registryRoutesLoader) { this.registryRoutesLoader = registryRoutesLoader; - this.xmlRoutesLoader = xmlRoutesLoader; } public RegistryRoutesLoader getRegistryRoutesLoader() { return registryRoutesLoader; } - public XMLRoutesDefinitionLoader getXmlRoutesLoader() { - return xmlRoutesLoader; - } - @Override public List<RoutesBuilder> collectRoutesFromRegistry( CamelContext camelContext, @@ -62,77 +42,4 @@ public class CamelMainRoutesCollector implements RoutesCollector { return registryRoutesLoader.collectRoutesFromRegistry(camelContext, excludePattern, includePattern); } - - @Override - public List<RoutesDefinition> collectXmlRoutesFromDirectory(CamelContext camelContext, String directory) { - List<RoutesDefinition> answer = new ArrayList<>(); - PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver(); - - for (String part : directory.split(",")) { - LOGGER.info("Loading additional Camel XML routes from: {}", part); - try { - for (InputStream is : resolver.findResources(part)) { - Object definition = xmlRoutesLoader.loadRoutesDefinition(camelContext, is); - if (definition instanceof RoutesDefinition) { - answer.add((RoutesDefinition) definition); - } - } - } catch (FileNotFoundException e) { - LOGGER.warn("File {} can not be found. Skipping XML routes detection.", part); - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeException(e); - } - } - - return answer; - } - - @Override - public List<RouteTemplatesDefinition> collectXmlRouteTemplatesFromDirectory(CamelContext camelContext, String directory) - throws Exception { - List<RouteTemplatesDefinition> answer = new ArrayList<>(); - PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver(); - - for (String part : directory.split(",")) { - LOGGER.info("Loading additional Camel XML route templates from: {}", part); - try { - for (InputStream is : resolver.findResources(part)) { - Object definition = xmlRoutesLoader.loadRouteTemplatesDefinition(camelContext, is); - if (definition instanceof RestsDefinition) { - answer.add((RouteTemplatesDefinition) definition); - } - } - } catch (FileNotFoundException e) { - LOGGER.debug("No XML route templates found in {}. Skipping XML route templates detection.", part); - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeException(e); - } - } - - return answer; - } - - @Override - public List<RestsDefinition> collectXmlRestsFromDirectory(CamelContext camelContext, String directory) { - List<RestsDefinition> answer = new ArrayList<>(); - PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver(); - - for (String part : directory.split(",")) { - LOGGER.info("Loading additional Camel XML rests from: {}", part); - try { - for (InputStream is : resolver.findResources(part)) { - Object definition = xmlRoutesLoader.loadRestsDefinition(camelContext, is); - if (definition instanceof RestsDefinition) { - answer.add((RestsDefinition) definition); - } - } - } catch (FileNotFoundException e) { - LOGGER.debug("No XML rests found in {}. Skipping XML rests detection.", part); - } catch (Exception e) { - throw RuntimeCamelException.wrapRuntimeException(e); - } - } - - return answer; - } } diff --git a/extensions/univocity-parsers/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/univocity-parsers/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 4ca500c..61a7fcc 100644 --- a/extensions/univocity-parsers/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/univocity-parsers/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,9 +24,8 @@ name: "Camel uniVocity CSV" description: "Marshal and unmarshal Java objects from and to CSV (Comma Separated Values) using UniVocity Parsers" metadata: - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/univocity-parsers.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/integration-tests/univocity-parsers/pom.xml b/integration-tests/core-discovery-disabled/pom.xml similarity index 71% copy from integration-tests/univocity-parsers/pom.xml copy to integration-tests/core-discovery-disabled/pom.xml index 25cccf7..2db81cd 100644 --- a/integration-tests/univocity-parsers/pom.xml +++ b/integration-tests/core-discovery-disabled/pom.xml @@ -17,31 +17,17 @@ limitations under the License. --> -<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"> - <modelVersion>4.0.0</modelVersion> +<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.quarkus</groupId> <artifactId>camel-quarkus-integration-tests</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-integration-test-univocity-parsers</artifactId> - <name>Camel Quarkus :: Integration Tests :: uniVocity CSV</name> - <description>Integration tests for Camel Quarkus uniVocity CSV extension</description> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-test</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> + <artifactId>camel-quarkus-integration-test-core-discovery-disabled</artifactId> + <name>Camel Quarkus :: Integration Tests :: Core Discovery Disabled :: Tests</name> + <description>The camel integration tests</description> <dependencies> <dependency> @@ -50,15 +36,24 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-univocity-parsers</artifactId> + <artifactId>camel-quarkus-log</artifactId> + </dependency> + + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jsonb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> + <artifactId>quarkus-resteasy-jsonb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jackson</artifactId> + <artifactId>quarkus-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> </dependency> <!-- test dependencies --> @@ -72,11 +67,16 @@ <artifactId>rest-assured</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </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-univocity-parsers-deployment</artifactId> + <artifactId>camel-quarkus-direct-deployment</artifactId> <version>${project.version}</version> <type>pom</type> <scope>test</scope> @@ -87,6 +87,20 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> <build> @@ -134,4 +148,6 @@ </build> </profile> </profiles> + + </project> diff --git a/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledResource.java b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledResource.java new file mode 100644 index 0000000..748fdde --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledResource.java @@ -0,0 +1,56 @@ +/* + * 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.core; + +import java.util.List; +import java.util.stream.Collectors; + +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.CamelContext; +import org.apache.camel.Route; + +@Path("/test") +@ApplicationScoped +public class CoreDiscoveryDisabledResource { + @Inject + CamelContext context; + + @Path("/inspect") + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject inspect() { + // collect the list of route classes instead of just the + // number of routes to help debugging in case of a failing + // tests + List<String> routes = context.getRoutes().stream() + .map(Route::getClass) + .map(Class::getName) + .collect(Collectors.toList()); + + return Json.createObjectBuilder() + .add("routes", Json.createArrayBuilder(routes)) + .build(); + } +} diff --git a/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutes.java b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutes.java new file mode 100644 index 0000000..3fedf19 --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutes.java @@ -0,0 +1,29 @@ +/* + * 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.core; + +import org.apache.camel.builder.RouteBuilder; + +public class CoreDiscoveryDisabledRoutes extends RouteBuilder { + @Override + public void configure() { + from("direct:camel") + .id("camel") + .to("log:camel"); + + } +} diff --git a/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutesCDI.java b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutesCDI.java new file mode 100644 index 0000000..c0057a8 --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/main/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledRoutesCDI.java @@ -0,0 +1,32 @@ +/* + * 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.core; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.builder.RouteBuilder; + +@ApplicationScoped +public class CoreDiscoveryDisabledRoutesCDI extends RouteBuilder { + @Override + public void configure() { + from("direct:cdi") + .id("cdi") + .to("log:cdi"); + + } +} diff --git a/integration-tests/core-discovery-disabled/src/main/resources/application.properties b/integration-tests/core-discovery-disabled/src/main/resources/application.properties new file mode 100644 index 0000000..9de62fa --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/main/resources/application.properties @@ -0,0 +1,21 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Quarkus :: Camel +# +quarkus.camel.routes-discovery.enabled = false diff --git a/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledIT.java b/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledIT.java new file mode 100644 index 0000000..fb4c441 --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledIT.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.core; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class CoreDiscoveryDisabledIT extends CoreDiscoveryDisabledTest { +} diff --git a/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledTest.java b/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledTest.java new file mode 100644 index 0000000..c9e0d23 --- /dev/null +++ b/integration-tests/core-discovery-disabled/src/test/java/org/apache/camel/quarkus/core/CoreDiscoveryDisabledTest.java @@ -0,0 +1,39 @@ +/* + * 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.core; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@QuarkusTest +public class CoreDiscoveryDisabledTest { + @Test + public void inspect() { + JsonPath path = RestAssured.when() + .get("/test/inspect") + .then() + .statusCode(200) + .extract() + .jsonPath(); + + assertThat(path.getList("routes", String.class)).isEmpty(); + } +} diff --git a/integration-tests/univocity-parsers/pom.xml b/integration-tests/main-discovery-disabled/pom.xml similarity index 67% copy from integration-tests/univocity-parsers/pom.xml copy to integration-tests/main-discovery-disabled/pom.xml index 25cccf7..62f2125 100644 --- a/integration-tests/univocity-parsers/pom.xml +++ b/integration-tests/main-discovery-disabled/pom.xml @@ -17,48 +17,39 @@ limitations under the License. --> -<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"> - <modelVersion>4.0.0</modelVersion> +<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.quarkus</groupId> <artifactId>camel-quarkus-integration-tests</artifactId> <version>1.2.0-SNAPSHOT</version> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-integration-test-univocity-parsers</artifactId> - <name>Camel Quarkus :: Integration Tests :: uniVocity CSV</name> - <description>Integration tests for Camel Quarkus uniVocity CSV extension</description> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-test</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> + <artifactId>camel-quarkus-integration-test-main-discovery-disabled</artifactId> + <name>Camel Quarkus :: Integration Tests :: Main Discovery Disabled :: Tests</name> + <description>The camel integration tests</description> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-main</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-direct</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-univocity-parsers</artifactId> + <artifactId>camel-quarkus-log</artifactId> </dependency> + <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> + <artifactId>quarkus-jsonb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jackson</artifactId> + <artifactId>quarkus-resteasy-jsonb</artifactId> </dependency> <!-- test dependencies --> @@ -72,11 +63,16 @@ <artifactId>rest-assured</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </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-univocity-parsers-deployment</artifactId> + <artifactId>camel-quarkus-direct-deployment</artifactId> <version>${project.version}</version> <type>pom</type> <scope>test</scope> @@ -87,6 +83,33 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <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> + </dependencies> <build> @@ -134,4 +157,6 @@ </build> </profile> </profiles> + + </project> diff --git a/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledResource.java b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledResource.java new file mode 100644 index 0000000..10008ba --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledResource.java @@ -0,0 +1,56 @@ +/* + * 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.main; + +import java.util.List; +import java.util.stream.Collectors; + +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.CamelContext; +import org.apache.camel.Route; + +@Path("/test") +@ApplicationScoped +public class MainDiscoveryDisabledResource { + @Inject + CamelContext context; + + @Path("/inspect") + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject inspect() { + // collect the list of route classes instead of just the + // number of routes to help debugging in case of a failing + // tests + List<String> routes = context.getRoutes().stream() + .map(Route::getClass) + .map(Class::getName) + .collect(Collectors.toList()); + + return Json.createObjectBuilder() + .add("routes", Json.createArrayBuilder(routes)) + .build(); + } +} diff --git a/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutes.java b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutes.java new file mode 100644 index 0000000..817893c --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutes.java @@ -0,0 +1,29 @@ +/* + * 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.main; + +import org.apache.camel.builder.RouteBuilder; + +public class MainDiscoveryDisabledRoutes extends RouteBuilder { + @Override + public void configure() { + from("direct:camel") + .id("camel") + .to("log:camel"); + + } +} diff --git a/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutesCDI.java b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutesCDI.java new file mode 100644 index 0000000..1b763f2 --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/main/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledRoutesCDI.java @@ -0,0 +1,32 @@ +/* + * 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.main; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.builder.RouteBuilder; + +@ApplicationScoped +public class MainDiscoveryDisabledRoutesCDI extends RouteBuilder { + @Override + public void configure() { + from("direct:cdi") + .id("cdi") + .to("log:cdi"); + + } +} diff --git a/integration-tests/main-discovery-disabled/src/main/resources/application.properties b/integration-tests/main-discovery-disabled/src/main/resources/application.properties new file mode 100644 index 0000000..9de62fa --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/main/resources/application.properties @@ -0,0 +1,21 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Quarkus :: Camel +# +quarkus.camel.routes-discovery.enabled = false diff --git a/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledIT.java b/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledIT.java new file mode 100644 index 0000000..d2302a4 --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledIT.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.main; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class MainDiscoveryDisabledIT extends MainDiscoveryDisabledTest { +} diff --git a/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledTest.java b/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledTest.java new file mode 100644 index 0000000..934f738 --- /dev/null +++ b/integration-tests/main-discovery-disabled/src/test/java/org/apache/camel/quarkus/main/MainDiscoveryDisabledTest.java @@ -0,0 +1,39 @@ +/* + * 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.main; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@QuarkusTest +public class MainDiscoveryDisabledTest { + @Test + public void inspect() { + JsonPath path = RestAssured.when() + .get("/test/inspect") + .then() + .statusCode(200) + .extract() + .jsonPath(); + + assertThat(path.getList("routes", String.class)).isEmpty(); + } +} diff --git a/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java index 52d8574..03b225f 100644 --- a/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java +++ b/integration-tests/main-xml-io/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlIoResource.java @@ -61,7 +61,7 @@ public class CoreMainXmlIoResource { if (main.getRoutesCollector() instanceof CamelMainRoutesCollector) { CamelMainRoutesCollector crc = (CamelMainRoutesCollector) main.getRoutesCollector(); collector.add("type-registry", crc.getRegistryRoutesLoader().getClass().getName()); - collector.add("type-xml", crc.getXmlRoutesLoader().getClass().getName()); + collector.add("type-xml", camelContext.getXMLRoutesDefinitionLoader().getClass().getName()); } return Json.createObjectBuilder() diff --git a/integration-tests/main-xml-jaxb/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlJaxbResource.java b/integration-tests/main-xml-jaxb/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlJaxbResource.java index aa5d740..8b93d78 100644 --- a/integration-tests/main-xml-jaxb/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlJaxbResource.java +++ b/integration-tests/main-xml-jaxb/src/main/java/org/apache/camel/quarkus/main/CoreMainXmlJaxbResource.java @@ -55,7 +55,7 @@ public class CoreMainXmlJaxbResource { if (main.getRoutesCollector() instanceof CamelMainRoutesCollector) { CamelMainRoutesCollector crc = (CamelMainRoutesCollector) main.getRoutesCollector(); collector.add("type-registry", crc.getRegistryRoutesLoader().getClass().getName()); - collector.add("type-xml", crc.getXmlRoutesLoader().getClass().getName()); + collector.add("type-xml", camelContext.getXMLRoutesDefinitionLoader().getClass().getName()); } return Json.createObjectBuilder() diff --git a/integration-tests/main/src/main/java/org/apache/camel/quarkus/main/CoreMainResource.java b/integration-tests/main/src/main/java/org/apache/camel/quarkus/main/CoreMainResource.java index d710865..e024201 100644 --- a/integration-tests/main/src/main/java/org/apache/camel/quarkus/main/CoreMainResource.java +++ b/integration-tests/main/src/main/java/org/apache/camel/quarkus/main/CoreMainResource.java @@ -122,7 +122,7 @@ public class CoreMainResource { if (main.getRoutesCollector() instanceof CamelMainRoutesCollector) { CamelMainRoutesCollector crc = (CamelMainRoutesCollector) main.getRoutesCollector(); collector.add("type-registry", crc.getRegistryRoutesLoader().getClass().getName()); - collector.add("type-xml", crc.getXmlRoutesLoader().getClass().getName()); + collector.add("type-xml", camelContext.getXMLRoutesDefinitionLoader().getClass().getName()); } JsonObjectBuilder dataformatsInRegistry = Json.createObjectBuilder(); diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 101f625..cf302bf 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -49,8 +49,10 @@ <modules> <!-- build those first --> <module>core</module> + <module>core-discovery-disabled</module> <module>main</module> <module>main-devmode</module> + <module>main-discovery-disabled</module> <module>main-xml-jaxb</module> <module>main-xml-io</module> <module>main-collector</module> diff --git a/integration-tests/univocity-parsers/pom.xml b/integration-tests/univocity-parsers/pom.xml index 25cccf7..a4ddb5a 100644 --- a/integration-tests/univocity-parsers/pom.xml +++ b/integration-tests/univocity-parsers/pom.xml @@ -76,6 +76,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-direct-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-univocity-parsers-deployment</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index ab581c4..359afbe 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -29,11 +29,13 @@ cloud: - smallrye-reactive-messaging core-main-validation: - core + - core-discovery-disabled - main - main-caffeine-lrucache - main-collector - - main-devmode - main-command-mode + - main-devmode + - main-discovery-disabled - main-xml-io - main-xml-jaxb - bean-validator