This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 877be20 CAMEL-15210: camel-api-component-maven-plugin - Should generate test code in junit 5 format 877be20 is described below commit 877be2018e9f5a3b20677665298a4449213d8944 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Aug 29 15:06:08 2020 +0200 CAMEL-15210: camel-api-component-maven-plugin - Should generate test code in junit 5 format --- .../META-INF/maven/archetype-metadata.xml | 3 + .../__artifactId__-component/pom.xml | 7 +- .../src/test/java/Abstract__name__TestSupport.java | 83 ---------------------- .../src/test/resources/test-options.properties | 1 - 4 files changed, 7 insertions(+), 87 deletions(-) diff --git a/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml index 62f80fc..f5b3f51 100644 --- a/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml +++ b/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -39,6 +39,9 @@ <requiredProperty key="build-helper-maven-plugin-version"> <defaultValue>${build-helper-maven-plugin-version}</defaultValue> </requiredProperty> + <requiredProperty key="junit-jupiter-version"> + <defaultValue>${junit-jupiter-version}</defaultValue> + </requiredProperty> <requiredProperty key="slf4j-version"> <defaultValue>${slf4j-version}</defaultValue> </requiredProperty> diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml index 56af557..8cb68f5 100644 --- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml +++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml @@ -70,12 +70,13 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-junit5</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <version>${junit-jupiter-version}</version> <scope>test</scope> </dependency> </dependencies> diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java deleted file mode 100644 index 1613e9d..0000000 --- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/java/Abstract__name__TestSupport.java +++ /dev/null @@ -1,83 +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 ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelExecutionException; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.apache.camel.support.IntrospectionSupport; - -/** - * Abstract base class for ${name} Integration tests generated by Camel API component maven plugin. - */ -public class Abstract${name}TestSupport extends CamelTestSupport { - - private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties"; - - @Override - protected CamelContext createCamelContext() throws Exception { - - final CamelContext context = super.createCamelContext(); - - // read ${name} component configuration from TEST_OPTIONS_PROPERTIES - final Properties properties = new Properties(); - try { - properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES)); - } catch (Exception e) { - throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), - e); - } - - Map<String, Object> options = new HashMap<String, Object>(); - for (Map.Entry<Object, Object> entry : properties.entrySet()) { - options.put(entry.getKey().toString(), entry.getValue()); - } - - final ${name}Configuration configuration = new ${name}Configuration(); - IntrospectionSupport.setProperties(configuration, options); - - // add ${name}Component to Camel context - final ${name}Component component = new ${name}Component(context); - component.setConfiguration(configuration); - context.addComponent("${scheme}", component); - - return context; - } - - @Override - public boolean isCreateCamelContextPerClass() { - // only create the context once for this class - return true; - } - - @SuppressWarnings("unchecked") - protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) - throws CamelExecutionException { - return (T) template().requestBodyAndHeaders(endpointUri, body, headers); - } - - @SuppressWarnings("unchecked") - protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException { - return (T) template().requestBody(endpoint, body); - } -} diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/test-options.properties b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/test-options.properties deleted file mode 100644 index 3257402..0000000 --- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/test-options.properties +++ /dev/null @@ -1 +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. ## --------------------------------------------------------------------------- # TODO provide test values for ${name} con figuration properties \ No newline at end of file