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-spring-boot-examples.git
commit b94761e05705482cce2f973211595ad989be3951 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Aug 29 17:42:36 2020 +0200 Migrated test to junit 5 --- camel-example-spring-boot-fhir-auth-tx/pom.xml | 33 +++++++------- .../java/sample/camel/MyCamelApplicationTest.java | 31 +++++-------- camel-example-spring-boot-fhir/pom.xml | 26 ++++++----- .../java/sample/camel/MyCamelApplicationTest.java | 30 +++++-------- camel-example-spring-boot-validator/pom.xml | 13 +++++- .../sample/camel/SampleCamelApplicationTest.java | 7 ++- camel-example-spring-boot-xml/pom.xml | 9 ++-- .../test/java/sample/camel/FooApplicationTest.java | 52 ---------------------- .../sample/camel/SampleCamelApplicationTest.java | 9 ++-- 9 files changed, 77 insertions(+), 133 deletions(-) diff --git a/camel-example-spring-boot-fhir-auth-tx/pom.xml b/camel-example-spring-boot-fhir-auth-tx/pom.xml index dc1390d..f04dfb4 100644 --- a/camel-example-spring-boot-fhir-auth-tx/pom.xml +++ b/camel-example-spring-boot-fhir-auth-tx/pom.xml @@ -90,13 +90,13 @@ </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-fhir</artifactId> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-fhir-starter</artifactId> <version>${camel-version}</version> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-csv</artifactId> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-csv-starter</artifactId> <version>${camel-version}</version> </dependency> <dependency> @@ -117,8 +117,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> - <version>${camel-version}</version> + <artifactId>camel-test-spring-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-management</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> <scope>test</scope> </dependency> @@ -138,18 +147,6 @@ </execution> </executions> </plugin> - - <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-maven-plugin</artifactId> - <version>${camel-version}</version> - <!-- allows to fail if not all routes are fully covered during testing --> - <!-- - <configuration> - <failOnError>true</failOnError> - </configuration> - --> - </plugin> </plugins> </build> </project> diff --git a/camel-example-spring-boot-fhir-auth-tx/src/test/java/sample/camel/MyCamelApplicationTest.java b/camel-example-spring-boot-fhir-auth-tx/src/test/java/sample/camel/MyCamelApplicationTest.java index 44e6005..a33a16c 100644 --- a/camel-example-spring-boot-fhir-auth-tx/src/test/java/sample/camel/MyCamelApplicationTest.java +++ b/camel-example-spring-boot-fhir-auth-tx/src/test/java/sample/camel/MyCamelApplicationTest.java @@ -17,39 +17,32 @@ package sample.camel; import java.io.File; -import java.io.IOException; -import org.apache.camel.EndpointInject; +import org.apache.camel.CamelContext; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.CamelSpringBootRunner; -import org.apache.camel.test.spring.EnableRouteCoverage; -import org.apache.camel.test.spring.MockEndpointsAndSkip; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.apache.camel.test.spring.junit5.MockEndpointsAndSkip; import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -@RunWith(CamelSpringBootRunner.class) +@CamelSpringBootTest @SpringBootTest(classes = MyCamelApplication.class, properties = "input = target/work/fhir/testinput") -@EnableRouteCoverage @MockEndpointsAndSkip("fhir*") public class MyCamelApplicationTest { - @EndpointInject("mock:fhir:transaction/withResources") - private MockEndpoint mock; - - @Before - public void copyData() throws IOException { - FileUtils.copyDirectory(new File("src/main/data"), new File("target/work/fhir/testinput")); - } + @Autowired + private CamelContext camelContext; @Test - public void shouldPushConvertedCsvtoFhir() throws Exception { + public void shouldPushConvertedHl7toFhir() throws Exception { + MockEndpoint mock = camelContext.getEndpoint("mock:fhir:transaction/withResources", MockEndpoint.class); mock.expectedMessageCount(1); + FileUtils.copyDirectory(new File("src/main/data"), new File("target/work/fhir/testinput")); + mock.assertIsSatisfied(); } - } diff --git a/camel-example-spring-boot-fhir/pom.xml b/camel-example-spring-boot-fhir/pom.xml index 0908c14..732f0c3 100644 --- a/camel-example-spring-boot-fhir/pom.xml +++ b/camel-example-spring-boot-fhir/pom.xml @@ -89,18 +89,13 @@ </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-fhir</artifactId> - <version>${camel-version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-hl7</artifactId> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-fhir-starter</artifactId> <version>${camel-version}</version> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-management</artifactId> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-hl7-starter</artifactId> <version>${camel-version}</version> </dependency> <dependency> @@ -116,8 +111,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> - <version>${camel-version}</version> + <artifactId>camel-test-spring-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-management</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> <scope>test</scope> </dependency> diff --git a/camel-example-spring-boot-fhir/src/test/java/sample/camel/MyCamelApplicationTest.java b/camel-example-spring-boot-fhir/src/test/java/sample/camel/MyCamelApplicationTest.java index 2d1618a..cb6ccaa 100644 --- a/camel-example-spring-boot-fhir/src/test/java/sample/camel/MyCamelApplicationTest.java +++ b/camel-example-spring-boot-fhir/src/test/java/sample/camel/MyCamelApplicationTest.java @@ -17,38 +17,32 @@ package sample.camel; import java.io.File; -import java.io.IOException; -import org.apache.camel.EndpointInject; +import org.apache.camel.CamelContext; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.CamelSpringBootRunner; -import org.apache.camel.test.spring.EnableRouteCoverage; -import org.apache.camel.test.spring.MockEndpointsAndSkip; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.apache.camel.test.spring.junit5.MockEndpointsAndSkip; import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -@RunWith(CamelSpringBootRunner.class) +@CamelSpringBootTest @SpringBootTest(classes = MyCamelApplication.class, properties = "input = target/work/fhir/testinput") -@EnableRouteCoverage @MockEndpointsAndSkip("fhir*") public class MyCamelApplicationTest { - @EndpointInject("mock:fhir:create/resource") - private MockEndpoint mock; - - @Before - public void copyData() throws IOException { - FileUtils.copyDirectory(new File("src/main/data"), new File("target/work/fhir/testinput")); - } + @Autowired + private CamelContext camelContext; @Test public void shouldPushConvertedHl7toFhir() throws Exception { + MockEndpoint mock = camelContext.getEndpoint("mock:fhir:create/resource", MockEndpoint.class); mock.expectedBodiesReceived("{\"resourceType\":\"Patient\",\"id\":\"100005056\",\"name\":[{\"family\":\"Freeman\",\"given\":[\"Vincent\"]}]}"); - + + FileUtils.copyDirectory(new File("src/main/data"), new File("target/work/fhir/testinput")); + mock.assertIsSatisfied(); } diff --git a/camel-example-spring-boot-validator/pom.xml b/camel-example-spring-boot-validator/pom.xml index e350eed..4ed69c3 100644 --- a/camel-example-spring-boot-validator/pom.xml +++ b/camel-example-spring-boot-validator/pom.xml @@ -101,8 +101,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> - <version>${camel-version}</version> + <artifactId>camel-test-spring-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-management</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> <scope>test</scope> </dependency> diff --git a/camel-example-spring-boot-validator/src/test/java/sample/camel/SampleCamelApplicationTest.java b/camel-example-spring-boot-validator/src/test/java/sample/camel/SampleCamelApplicationTest.java index b706a6d..1915afc 100644 --- a/camel-example-spring-boot-validator/src/test/java/sample/camel/SampleCamelApplicationTest.java +++ b/camel-example-spring-boot-validator/src/test/java/sample/camel/SampleCamelApplicationTest.java @@ -20,15 +20,14 @@ import java.util.concurrent.TimeUnit; import org.apache.camel.CamelContext; import org.apache.camel.builder.NotifyBuilder; -import org.apache.camel.test.spring.CamelSpringBootRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import static org.junit.Assert.assertTrue; -@RunWith(CamelSpringBootRunner.class) +@CamelSpringBootTest @SpringBootTest(classes = SampleCamelApplication.class) public class SampleCamelApplicationTest { diff --git a/camel-example-spring-boot-xml/pom.xml b/camel-example-spring-boot-xml/pom.xml index 5355640..1efcc4a 100644 --- a/camel-example-spring-boot-xml/pom.xml +++ b/camel-example-spring-boot-xml/pom.xml @@ -101,14 +101,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> - <version>${camel-version}</version> + <artifactId>camel-test-spring-junit5</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-management</artifactId> - <version>${camel-version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/camel-example-spring-boot-xml/src/test/java/sample/camel/FooApplicationTest.java b/camel-example-spring-boot-xml/src/test/java/sample/camel/FooApplicationTest.java deleted file mode 100644 index 88a96af..0000000 --- a/camel-example-spring-boot-xml/src/test/java/sample/camel/FooApplicationTest.java +++ /dev/null @@ -1,52 +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 sample.camel; - -import java.util.concurrent.TimeUnit; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.NotifyBuilder; -import org.apache.camel.test.spring.CamelSpringBootRunner; -import org.apache.camel.test.spring.EnableRouteCoverage; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.junit.Assert.assertTrue; - -@RunWith(CamelSpringBootRunner.class) -@SpringBootTest(classes = SampleCamelApplication.class, - properties = "greeting = Hello foo") -@EnableRouteCoverage -@Ignore // enable me to run this test as well so we can cover testing the route completely -public class FooApplicationTest { - - @Autowired - private CamelContext camelContext; - - @Test - public void shouldSayFoo() throws Exception { - // we expect that one or more messages is automatic done by the Camel - // route as it uses a timer to trigger - NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create(); - - assertTrue(notify.matches(10, TimeUnit.SECONDS)); - } - -} diff --git a/camel-example-spring-boot-xml/src/test/java/sample/camel/SampleCamelApplicationTest.java b/camel-example-spring-boot-xml/src/test/java/sample/camel/SampleCamelApplicationTest.java index c0f1c2d..1915afc 100644 --- a/camel-example-spring-boot-xml/src/test/java/sample/camel/SampleCamelApplicationTest.java +++ b/camel-example-spring-boot-xml/src/test/java/sample/camel/SampleCamelApplicationTest.java @@ -20,18 +20,15 @@ import java.util.concurrent.TimeUnit; import org.apache.camel.CamelContext; import org.apache.camel.builder.NotifyBuilder; -import org.apache.camel.test.spring.CamelSpringBootRunner; -import org.apache.camel.test.spring.EnableRouteCoverage; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import static org.junit.Assert.assertTrue; -@RunWith(CamelSpringBootRunner.class) +@CamelSpringBootTest @SpringBootTest(classes = SampleCamelApplication.class) -@EnableRouteCoverage public class SampleCamelApplicationTest { @Autowired