You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2019/09/27 06:39:05 UTC
[camel] branch master updated: CAMEL-13965: Added a JUnit 5 version
of camel-example-spring-boot tests (testing coexistence of JUnit 4 and
JUnit 5)
This is an automated email from the ASF dual-hosted git repository.
aldettinger 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 070b157 CAMEL-13965: Added a JUnit 5 version of camel-example-spring-boot tests (testing coexistence of JUnit 4 and JUnit 5)
070b157 is described below
commit 070b157e737d0734368dc2f23bc7a22f145f06e4
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Sep 26 15:06:16 2019 +0200
CAMEL-13965: Added a JUnit 5 version of camel-example-spring-boot tests (testing coexistence of JUnit 4 and JUnit 5)
---
examples/camel-example-spring-boot/pom.xml | 11 ++++-
.../sample/camel/FooApplicationJUnit5Test.java | 52 ++++++++++++++++++++++
.../sample/camel/MyCamelApplicationJUnit5Test.java | 48 ++++++++++++++++++++
parent/pom.xml | 16 ++-----
4 files changed, 114 insertions(+), 13 deletions(-)
diff --git a/examples/camel-example-spring-boot/pom.xml b/examples/camel-example-spring-boot/pom.xml
index 2f2e789..9925258 100644
--- a/examples/camel-example-spring-boot/pom.xml
+++ b/examples/camel-example-spring-boot/pom.xml
@@ -104,7 +104,16 @@
<artifactId>camel-test-spring</artifactId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/examples/camel-example-spring-boot/src/test/java/sample/camel/FooApplicationJUnit5Test.java b/examples/camel-example-spring-boot/src/test/java/sample/camel/FooApplicationJUnit5Test.java
new file mode 100644
index 0000000..5e88f59
--- /dev/null
+++ b/examples/camel-example-spring-boot/src/test/java/sample/camel/FooApplicationJUnit5Test.java
@@ -0,0 +1,52 @@
+/*
+ * 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.junit5.CamelSpringBootTest;
+import org.apache.camel.test.spring.junit5.EnableRouteCoverage;
+import org.apache.camel.test.spring.junit5.MockEndpoints;
+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;
+
+@CamelSpringBootTest
+@SpringBootTest(classes = MyCamelApplication.class,
+ properties = "greeting = Hello foo")
+@EnableRouteCoverage
+@MockEndpoints("log:foo") // mock the log:foo endpoint => mock:log:foo which we then use in the testing
+//@Ignore // enable me to run this test as well so we can cover testing the route completely
+public class FooApplicationJUnit5Test {
+
+ @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/examples/camel-example-spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit5Test.java b/examples/camel-example-spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit5Test.java
new file mode 100644
index 0000000..b990532
--- /dev/null
+++ b/examples/camel-example-spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit5Test.java
@@ -0,0 +1,48 @@
+/*
+ * 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.junit5.CamelSpringBootTest;
+import org.apache.camel.test.spring.junit5.EnableRouteCoverage;
+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;
+
+@CamelSpringBootTest
+@SpringBootTest(classes = MyCamelApplication.class)
+@EnableRouteCoverage
+public class MyCamelApplicationJUnit5Test {
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Test
+ public void shouldProduceMessages() 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/parent/pom.xml b/parent/pom.xml
index e4cf7ec..be46bc3 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -4820,19 +4820,11 @@
<version>${junit-version}</version>
</dependency>
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit-jupiter-version}</version>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <version>${junit-jupiter-version}</version>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
<version>${junit-jupiter-version}</version>
+ <type>pom</type>
+ <scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>