This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch spring-test in repository https://gitbox.apache.org/repos/asf/camel.git
commit 100be823e5526e3ec2414bba4e9c0ef7e3176127 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Aug 31 11:22:11 2020 +0200 Add to 3.5 upgrade guide about junit 5 and spring boot testing with junit 5 --- .../ROOT/pages/camel-3x-upgrade-guide-3_5.adoc | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_5.adoc index 9143ad2..647c51f 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_5.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_5.adoc @@ -60,3 +60,56 @@ The `LifecycleStrategy` has been enhanced and provides some additional methods a * **onContextStarted**: is now invoked when the context is started * **onContextStopping**: is invoked when the context is about to be stopped, this was previously achieved by the `onContextStop` which is now deprecated. * **onContextStop**: is now invoked when the context is stopped + +=== JUnit 5 testing + +Camel has been migrated from JUnit 4 to JUnit 5 as our default testing in all the components. +The new test components reflect this with the following JAR names: + +- camel-test-junit5 +- camel-test-spring-junit5 +- camel-testcontainers-junit5 +- camel-testcontainers-spring-junit5 + +The older test components supports only JUnit 4. + +=== Spring Boot testing with JUnit 5 + +Testing Camel on Spring Boot with JUnit 5 have also changed slightly to use JUnit 5 APIs and testing style. + +The following set of dependencies can be used: + +[source,xml] +---- +<dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> +</dependency> +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-spring-junit5</artifactId> + <scope>test</scope> +</dependency> +---- + +Then in your test classes you should annotate the Spring Boot test class with the new `@CamelSpringBootTest` +(from package `org.apache.camel.test.spring.junit5.CamelSpringBootTest` in camel-test-spring-junit5 JAR) +annotation as shown: + +[source,java] +---- +@CamelSpringBootTest +@SpringBootTest(classes = MyCamelApplication.class) +public class MyCamelApplicationJUnit5Test { + + @Autowired + private CamelContext camelContext; + + @Test + public void shouldProduceMessages() throws Exception { + // here you can write your unit test + } + +} +----
