This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new b89f5e1  Improve the tests by overriding appropriate methods and 
upgrade to JUnit 5 (#75)
b89f5e1 is described below

commit b89f5e1b94442b52b892b40e90d534aa16979418
Author: Nicolas Filotto <essob...@users.noreply.github.com>
AuthorDate: Fri Feb 18 18:28:11 2022 +0100

    Improve the tests by overriding appropriate methods and upgrade to JUnit 5 
(#75)
---
 examples/bigxml-split/pom.xml                      |  8 +--
 .../camel/example/bigxml/StaxTokenizerTest.java    | 21 +++++---
 .../camel/example/bigxml/XmlTokenizerTest.java     | 22 +++++---
 examples/cafe-endpointdsl/pom.xml                  |  8 +--
 .../camel/example/cafe/CafeRouteBuilderTest.java   | 19 +++----
 examples/cafe/pom.xml                              |  8 +--
 .../camel/example/cafe/CafeRouteBuilderTest.java   | 19 +++----
 .../cafe/CafeRouteSpringIntegrationTest.java       | 63 ----------------------
 .../camel/example/cafe/CafeRouteSpringTest.java    | 10 ++--
 examples/cxf-proxy/pom.xml                         |  8 +--
 .../reportincident/ReportIncidentRoutesTest.java   | 25 ++++-----
 examples/cxf/pom.xml                               | 10 +---
 .../transport/CamelTransportClientServerTest.java  | 35 ++++++------
 .../cxf/httptojms/CxfHttpJmsClientServerTest.java  | 19 ++++---
 .../example/cxf/jaxrs/JAXRSClientServerTest.java   | 30 ++++++-----
 .../example/provider/ProviderClientServerTest.java | 14 ++---
 .../camel/example/jmstofile/JmsToFileTest.java     | 25 ++++-----
 .../org/apache/camel/example/kafka/KafkaTest.java  | 26 ++++-----
 examples/loan-broker-cxf/pom.xml                   | 12 +----
 .../apache/camel/loanbroker/LoanBrokerWSTest.java  | 20 ++++---
 examples/loan-broker-jms/pom.xml                   |  8 +--
 .../camel/loanbroker/LoanBrokerQueueTest.java      | 26 +++++----
 examples/management/pom.xml                        |  8 +--
 .../example/management/ManagementExampleTest.java  | 10 ++--
 examples/pojo-messaging/pom.xml                    |  8 +--
 .../camel/example/pojo/CamelContextTest.java       | 28 +++++-----
 examples/spring-pulsar/pom.xml                     |  2 +-
 .../camel/example/SpringJmsClientServerTest.java   | 22 ++++----
 examples/spring/pom.xml                            | 12 +++--
 .../camel/example/spring/IntegrationTest.java      |  7 ++-
 .../camel/example/vertx/kafka/VertxKafkaTest.java  | 26 ++++-----
 31 files changed, 229 insertions(+), 330 deletions(-)

diff --git a/examples/bigxml-split/pom.xml b/examples/bigxml-split/pom.xml
index 864e98f..e48ba1c 100644
--- a/examples/bigxml-split/pom.xml
+++ b/examples/bigxml-split/pom.xml
@@ -90,15 +90,9 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <version>${junit-version}</version>
-        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/StaxTokenizerTest.java
 
b/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/StaxTokenizerTest.java
index 321d52b..286bb7c 100644
--- 
a/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/StaxTokenizerTest.java
+++ 
b/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/StaxTokenizerTest.java
@@ -22,15 +22,20 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static org.apache.camel.component.stax.StAXBuilder.stax;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-public class StaxTokenizerTest extends CamelTestSupport {
+class StaxTokenizerTest extends CamelTestSupport {
 
-    @BeforeClass
+    private static final Logger LOG = 
LoggerFactory.getLogger(StaxTokenizerTest.class);
+
+    @BeforeAll
     public static void beforeClass() throws Exception {
         TestUtils.buildTestXml();
     }
@@ -48,11 +53,11 @@ public class StaxTokenizerTest extends CamelTestSupport {
     }
 
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         NotifyBuilder notify = new 
NotifyBuilder(context).whenDone(TestUtils.getNumOfRecords()).create();
         boolean matches = notify.matches(TestUtils.getMaxWaitTime(), 
TimeUnit.MILLISECONDS);
-        log.info("Processed XML file with {} records", 
TestUtils.getNumOfRecords());
-        assertTrue("Test completed", matches);
+        LOG.info("Processed XML file with {} records", 
TestUtils.getNumOfRecords());
+        assertTrue(matches, "Test completed");
     }
 
     @Override
diff --git 
a/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/XmlTokenizerTest.java
 
b/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/XmlTokenizerTest.java
index 91249a4..f2ba60a 100644
--- 
a/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/XmlTokenizerTest.java
+++ 
b/examples/bigxml-split/src/test/java/org/apache/camel/example/bigxml/XmlTokenizerTest.java
@@ -22,13 +22,19 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class XmlTokenizerTest extends CamelTestSupport {
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-    @BeforeClass
+class XmlTokenizerTest extends CamelTestSupport {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(XmlTokenizerTest.class);
+
+    @BeforeAll
     public static void beforeClass() throws Exception {
         TestUtils.buildTestXml();
     }
@@ -46,11 +52,11 @@ public class XmlTokenizerTest extends CamelTestSupport {
     }
 
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         NotifyBuilder notify = new 
NotifyBuilder(context).whenDone(TestUtils.getNumOfRecords()).create();
         boolean matches = notify.matches(TestUtils.getMaxWaitTime(), 
TimeUnit.MILLISECONDS);
-        log.info("Processed XML file with {} records", 
TestUtils.getNumOfRecords());
-        assertTrue("Test completed", matches);
+        LOG.info("Processed XML file with {} records", 
TestUtils.getNumOfRecords());
+        assertTrue(matches, "Test completed");
     }
 
     @Override
diff --git a/examples/cafe-endpointdsl/pom.xml 
b/examples/cafe-endpointdsl/pom.xml
index d062c6e..2cf7155 100644
--- a/examples/cafe-endpointdsl/pom.xml
+++ b/examples/cafe-endpointdsl/pom.xml
@@ -80,15 +80,9 @@
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <version>${junit-version}</version>
-        </dependency>
 
     </dependencies>
 
diff --git 
a/examples/cafe-endpointdsl/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
 
b/examples/cafe-endpointdsl/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
index 6904a8f..f818ca7 100644
--- 
a/examples/cafe-endpointdsl/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
+++ 
b/examples/cafe-endpointdsl/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.example.cafe;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.example.cafe.stuff.Barista;
@@ -28,21 +27,15 @@ import org.apache.camel.example.cafe.stuff.OrderSplitter;
 import org.apache.camel.example.cafe.test.TestDrinkRouter;
 import org.apache.camel.example.cafe.test.TestWaiter;
 import org.apache.camel.spi.Registry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
 
-public class CafeRouteBuilderTest extends CamelTestSupport {
+class CafeRouteBuilderTest extends CamelTestSupport {
     protected TestWaiter waiter = new TestWaiter();
     protected TestDrinkRouter driverRouter = new TestDrinkRouter();
 
     @Override
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext context = super.createCamelContext();
-        bindBeans(context.getRegistry());
-        return context;
-    }
-
-    protected void bindBeans(Registry registry) throws Exception {
+    protected void bindToRegistry(Registry registry) throws Exception {
         registry.bind("drinkRouter", driverRouter);
         registry.bind("orderSplitter", new OrderSplitter());
         registry.bind("barista", new Barista());
@@ -51,7 +44,7 @@ public class CafeRouteBuilderTest extends CamelTestSupport {
     }
 
     @Test
-    public void testSplitter() throws InterruptedException {
+    void testSplitter() throws InterruptedException {
         MockEndpoint coldDrinks = context.getEndpoint("mock:coldDrinks", 
MockEndpoint.class);
         MockEndpoint hotDrinks = context.getEndpoint("mock:hotDrinks", 
MockEndpoint.class);
         
@@ -68,7 +61,7 @@ public class CafeRouteBuilderTest extends CamelTestSupport {
     }
     
     @Test
-    public void testCafeRoute() throws Exception {
+    void testCafeRoute() throws Exception {
         driverRouter.setTestModel(false);
         List<Drink> drinks = new ArrayList<>();
         Order order = new Order(2);
diff --git a/examples/cafe/pom.xml b/examples/cafe/pom.xml
index faaa9b0..023c068 100644
--- a/examples/cafe/pom.xml
+++ b/examples/cafe/pom.xml
@@ -95,15 +95,9 @@
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <version>${junit-version}</version>
-        </dependency>
 
     </dependencies>
 
diff --git 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
 
b/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
index 6904a8f..f818ca7 100644
--- 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
+++ 
b/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteBuilderTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.example.cafe;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.example.cafe.stuff.Barista;
@@ -28,21 +27,15 @@ import org.apache.camel.example.cafe.stuff.OrderSplitter;
 import org.apache.camel.example.cafe.test.TestDrinkRouter;
 import org.apache.camel.example.cafe.test.TestWaiter;
 import org.apache.camel.spi.Registry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
 
-public class CafeRouteBuilderTest extends CamelTestSupport {
+class CafeRouteBuilderTest extends CamelTestSupport {
     protected TestWaiter waiter = new TestWaiter();
     protected TestDrinkRouter driverRouter = new TestDrinkRouter();
 
     @Override
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext context = super.createCamelContext();
-        bindBeans(context.getRegistry());
-        return context;
-    }
-
-    protected void bindBeans(Registry registry) throws Exception {
+    protected void bindToRegistry(Registry registry) throws Exception {
         registry.bind("drinkRouter", driverRouter);
         registry.bind("orderSplitter", new OrderSplitter());
         registry.bind("barista", new Barista());
@@ -51,7 +44,7 @@ public class CafeRouteBuilderTest extends CamelTestSupport {
     }
 
     @Test
-    public void testSplitter() throws InterruptedException {
+    void testSplitter() throws InterruptedException {
         MockEndpoint coldDrinks = context.getEndpoint("mock:coldDrinks", 
MockEndpoint.class);
         MockEndpoint hotDrinks = context.getEndpoint("mock:hotDrinks", 
MockEndpoint.class);
         
@@ -68,7 +61,7 @@ public class CafeRouteBuilderTest extends CamelTestSupport {
     }
     
     @Test
-    public void testCafeRoute() throws Exception {
+    void testCafeRoute() throws Exception {
         driverRouter.setTestModel(false);
         List<Drink> drinks = new ArrayList<>();
         Order order = new Order(2);
diff --git 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringIntegrationTest.java
 
b/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringIntegrationTest.java
deleted file mode 100644
index 12867fe..0000000
--- 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringIntegrationTest.java
+++ /dev/null
@@ -1,63 +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 org.apache.camel.example.cafe;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class CafeRouteSpringIntegrationTest extends Assert {
-    private AbstractApplicationContext applicationContext;
-    private ProducerTemplate template;
-    
-    @Before
-    public void setUp() throws Exception {
-        applicationContext = new 
ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml");
-        CamelContext camelContext = getCamelContext();
-        template = camelContext.createProducerTemplate();
-    }
-    
-    @Test
-    public void testCafeRoute() throws Exception {
-        Order order = new Order(2);
-        order.addItem(DrinkType.ESPRESSO, 2, true);
-        order.addItem(DrinkType.CAPPUCCINO, 4, false);
-        order.addItem(DrinkType.LATTE, 4, false);
-        order.addItem(DrinkType.MOCHA, 2, false);
-        
-        template.sendBody("direct:cafe", order);
-        
-        Thread.sleep(7000);
-    }
-    
-    @After
-    public void tearDown() throws Exception {
-        if (applicationContext != null) {
-            applicationContext.stop();
-        }
-    }
-    
-    protected CamelContext getCamelContext() throws Exception {
-        return applicationContext.getBean("camel", CamelContext.class);
-    }
-
-}
diff --git 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringTest.java
 
b/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringTest.java
index 33b6a6b..c81791d 100644
--- 
a/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringTest.java
+++ 
b/examples/cafe/src/test/java/org/apache/camel/example/cafe/CafeRouteSpringTest.java
@@ -19,16 +19,16 @@ package org.apache.camel.example.cafe;
 import org.apache.camel.CamelContext;
 import org.apache.camel.example.cafe.test.TestDrinkRouter;
 import org.apache.camel.example.cafe.test.TestWaiter;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class CafeRouteSpringTest extends CafeRouteBuilderTest {
+class CafeRouteSpringTest extends CafeRouteBuilderTest {
     private AbstractApplicationContext applicationContext;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         applicationContext = new 
ClassPathXmlApplicationContext("META-INF/camel-routes.xml");
         setUseRouteBuilder(false);
@@ -38,7 +38,7 @@ public class CafeRouteSpringTest extends CafeRouteBuilderTest 
{
     }
     
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
         if (applicationContext != null) {
diff --git a/examples/cxf-proxy/pom.xml b/examples/cxf-proxy/pom.xml
index 43a23e4..30fee09 100644
--- a/examples/cxf-proxy/pom.xml
+++ b/examples/cxf-proxy/pom.xml
@@ -118,14 +118,8 @@
         </dependency>
 
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <version>${junit-version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
 
b/examples/cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
index f737d85..689480c 100644
--- 
a/examples/cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
+++ 
b/examples/cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
@@ -23,22 +23,23 @@ import org.apache.camel.spring.Main;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.util.FileUtil;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
  * Unit test of our routes
  */
-public class ReportIncidentRoutesTest {
+class ReportIncidentRoutesTest {
 
     // should be the same address as we have in our route
     private static String url;
 
     protected Main main;
 
-    @BeforeClass
+    @BeforeAll
     public static void setupFreePort() throws Exception {
         // find a free port number, and write that in the custom.properties 
file
         // which we will use for the unit tests, to avoid port number in use 
problems
@@ -57,13 +58,13 @@ public class ReportIncidentRoutesTest {
         url = "http://localhost:"; + port + 
"/camel-example-cxf-proxy/webservices/incident";
     }
 
-    @AfterClass
+    @AfterAll
     public static void cleanup() {
         File custom = new File("target/custom.properties");
         FileUtil.deleteFile(custom);
     }
 
-    protected void startCamel() throws Exception {
+    protected void startCamel() {
         if 
(!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
             main = new Main();
             main.setApplicationContextUri("META-INF/spring/camel-config.xml");
@@ -73,7 +74,7 @@ public class ReportIncidentRoutesTest {
         }
     }
     
-    protected void stopCamel() throws Exception {
+    protected void stopCamel() {
         if (main != null) {
             main.stop();
         }
@@ -88,7 +89,7 @@ public class ReportIncidentRoutesTest {
     }
 
     @Test
-    public void testReportIncident() throws Exception {
+    void testReportIncident() {
         // start camel
         startCamel();
 
@@ -98,7 +99,7 @@ public class ReportIncidentRoutesTest {
         stopCamel();
     }
     
-    protected void runTest() throws Exception {
+    protected void runTest() {
        
         // create input parameter
         InputReportIncident input = new InputReportIncident();
@@ -117,6 +118,6 @@ public class ReportIncidentRoutesTest {
         OutputReportIncident out = client.reportIncident(input);
 
         // assert we got a OK back
-        Assert.assertEquals("OK;456", out.getCode());
+        assertEquals("OK;456", out.getCode());
     }
 }
diff --git a/examples/cxf/pom.xml b/examples/cxf/pom.xml
index aab61ac..026f787 100644
--- a/examples/cxf/pom.xml
+++ b/examples/cxf/pom.xml
@@ -187,19 +187,13 @@
 
         <!-- testing -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <version>${junit-version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <!-- Not test scope because we need to use the port finder utility 
in the actual example code. -->
         </dependency>
 
diff --git 
a/examples/cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
 
b/examples/cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
index 7fed53b..1c04b68 100644
--- 
a/examples/cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
+++ 
b/examples/cxf/src/test/java/org/apache/camel/example/camel/transport/CamelTransportClientServerTest.java
@@ -22,18 +22,21 @@ import org.apache.camel.test.AvailablePortFinder;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.PingMeFault;
 import org.apache.hello_world_soap_http.types.FaultDetail;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class CamelTransportClientServerTest extends Assert {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class CamelTransportClientServerTest {
     static AbstractApplicationContext context;
     static int port;
     
-    @BeforeClass
+    @BeforeAll
     public static void startUpServer() throws Exception {
         if 
(!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
             port = AvailablePortFinder.getNextAvailable();
@@ -44,7 +47,7 @@ public class CamelTransportClientServerTest extends Assert {
         }
     }
     
-    @AfterClass
+    @AfterAll
     public static void shutDownServer() {
         if (context != null) {
             context.stop();
@@ -52,23 +55,23 @@ public class CamelTransportClientServerTest extends Assert {
     }
     
     @Test
-    public void testClientInvocation() throws MalformedURLException {
+    void testClientInvocation() throws MalformedURLException {
         Client client = new Client("http://localhost:"; + port + 
"/GreeterContext/GreeterPort");
         Greeter port = client.getProxy();
         
-        assertNotNull("The proxy should not be null", port);
+        assertNotNull(port, "The proxy should not be null");
         String resp = port.sayHi();
-        assertEquals("Get a wrong response ", "Bonjour from EndpointA", resp); 
       
+        assertEquals("Bonjour from EndpointA", resp, "Get a wrong response ");
 
         resp = port.sayHi();
-        assertEquals("Get a wrong response ", "Bonjour from EndpointB", resp); 
 
+        assertEquals("Bonjour from EndpointB", resp, "Get a wrong response ");
 
        
         resp = port.greetMe("Mike");
-        assertEquals("Get a wrong response ", "Hello Mike from EndpointA", 
resp);
+        assertEquals("Hello Mike from EndpointA", resp, "Get a wrong response 
");
         
         resp = port.greetMe("James");
-        assertEquals("Get a wrong response ", "Hello James from EndpointB", 
resp);  
+        assertEquals("Hello James from EndpointB", resp, "Get a wrong response 
");
        
         port.greetMeOneWay(System.getProperty("user.name"));
 
@@ -76,10 +79,10 @@ public class CamelTransportClientServerTest extends Assert {
             port.pingMe("hello");
             fail("exception expected but none thrown");
         } catch (PingMeFault ex) {
-            assertEquals("Wrong exception message received", "PingMeFault 
raised by server EndpointB", ex.getMessage());
+            assertEquals("PingMeFault raised by server EndpointB", 
ex.getMessage(), "Wrong exception message received");
             FaultDetail detail = ex.getFaultInfo();
-            assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
-            assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
+            assertEquals(2, detail.getMajor(), "Wrong FaultDetail major:");
+            assertEquals(1, detail.getMinor(), "Wrong FaultDetail minor:");
         }
 
     }
diff --git 
a/examples/cxf/src/test/java/org/apache/camel/example/cxf/httptojms/CxfHttpJmsClientServerTest.java
 
b/examples/cxf/src/test/java/org/apache/camel/example/cxf/httptojms/CxfHttpJmsClientServerTest.java
index 83b804a..64e326c 100644
--- 
a/examples/cxf/src/test/java/org/apache/camel/example/cxf/httptojms/CxfHttpJmsClientServerTest.java
+++ 
b/examples/cxf/src/test/java/org/apache/camel/example/cxf/httptojms/CxfHttpJmsClientServerTest.java
@@ -18,19 +18,22 @@ package org.apache.camel.example.cxf.httptojms;
 
 import java.net.MalformedURLException;
 
-import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.PingMeFault;
 import org.apache.hello_world_soap_http.types.FaultDetail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class CxfHttpJmsClientServerTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class CxfHttpJmsClientServerTest extends CamelSpringTestSupport {
     private static final String ROUTER_ADDRESS = 
"http://localhost:{{routerPort}}/SoapContext/SoapPort";;
 
     @Test
-    public void testClientInvocation() throws MalformedURLException {
+    void testClientInvocation() throws MalformedURLException {
         String address = ROUTER_ADDRESS.replace("{{routerPort}}", 
System.getProperty("routerPort"));
         
         Client client = new Client(address + "?wsdl");
@@ -38,10 +41,10 @@ public class CxfHttpJmsClientServerTest extends 
CamelSpringTestSupport {
 
         String resp;
         resp = proxy.sayHi();
-        assertEquals("Get a wrong response", "Bonjour", resp);
+        assertEquals("Bonjour", resp, "Get a wrong response");
 
         resp = proxy.greetMe("Willem");
-        assertEquals("Get a wrong response", "Hello Willem", resp);
+        assertEquals("Hello Willem", resp, "Get a wrong response");
 
         proxy.greetMeOneWay(System.getProperty("user.name"));
 
@@ -50,8 +53,8 @@ public class CxfHttpJmsClientServerTest extends 
CamelSpringTestSupport {
             fail("exception expected but none thrown");
         } catch (PingMeFault ex) {
             FaultDetail detail = ex.getFaultInfo();
-            assertEquals("Wrong FaultDetail major:", 2, detail.getMajor());
-            assertEquals("Wrong FaultDetail minor:", 1, detail.getMinor());
+            assertEquals(2, detail.getMajor(), "Wrong FaultDetail major:");
+            assertEquals(1, detail.getMinor(), "Wrong FaultDetail minor:");
         }
     }
 
diff --git 
a/examples/cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
 
b/examples/cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
index cb81b0f..0b8be03 100644
--- 
a/examples/cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
+++ 
b/examples/cxf/src/test/java/org/apache/camel/example/cxf/jaxrs/JAXRSClientServerTest.java
@@ -20,54 +20,58 @@ import org.apache.camel.example.cxf.jaxrs.resources.Book;
 import org.apache.camel.example.cxf.jaxrs.resources.BookNotFoundFault;
 import org.apache.camel.example.cxf.jaxrs.resources.BookStore;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.cxf.BusFactory;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class JAXRSClientServerTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class JAXRSClientServerTest extends CamelSpringTestSupport {
     
-    @BeforeClass
+    @BeforeAll
     public static void setupPorts() {
         System.setProperty("soapEndpointPort", 
String.valueOf(AvailablePortFinder.getNextAvailable()));
         System.setProperty("restEndpointPort", 
String.valueOf(AvailablePortFinder.getNextAvailable()));
     }
     
     @Test
-    public void testJAXWSClient() throws BookNotFoundFault {
+    void testJAXWSClient() throws BookNotFoundFault {
         JAXWSClient jaxwsClient = new JAXWSClient();
         BookStore bookStore = jaxwsClient.getBookStore();
         
         bookStore.addBook(new Book("Camel User Guide", 123L));
         Book book = bookStore.getBook(123L);
-        assertNotNull("We should find the book here", book);       
+        assertNotNull(book, "We should find the book here");
       
         try {
             book = bookStore.getBook(124L);
             fail("We should not have this book");
         } catch (Exception exception) {
-            assertTrue("The exception should be BookNotFoundFault", exception 
instanceof BookNotFoundFault);
+            assertTrue(exception instanceof BookNotFoundFault, "The exception 
should be BookNotFoundFault");
         }
     }
     
     @Test
-    public void testJAXRSClient() throws BookNotFoundFault {
+    void testJAXRSClient() throws BookNotFoundFault {
         // JAXRSClient invocation
         JAXRSClient jaxrsClient = new JAXRSClient();
         BookStore bookStore =  jaxrsClient.getBookStore();
         
         bookStore.addBook(new Book("Camel User Guide", 124L));
         Book book = bookStore.getBook(124L);
-        assertNotNull("We should find the book here", book);   
+        assertNotNull(book, "We should find the book here");
         
         try {
             book = bookStore.getBook(126L);
             fail("We should not have this book");
         } catch (Exception exception) {
-            assertTrue("The exception should be BookNotFoundFault", exception 
instanceof BookNotFoundFault);
+            assertTrue(exception instanceof BookNotFoundFault, "The exception 
should be BookNotFoundFault");
         }
     }
 
@@ -77,7 +81,7 @@ public class JAXRSClientServerTest extends 
CamelSpringTestSupport {
     }
     
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
         BusFactory.setDefaultBus(null);
diff --git 
a/examples/cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
 
b/examples/cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
index 7d443e8..39869d9 100644
--- 
a/examples/cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
+++ 
b/examples/cxf/src/test/java/org/apache/camel/example/provider/ProviderClientServerTest.java
@@ -18,23 +18,25 @@ package org.apache.camel.example.provider;
 
 import org.apache.camel.example.cxf.provider.Client;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class ProviderClientServerTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ProviderClientServerTest extends CamelSpringTestSupport {
     
     int port;
     
-    @Test 
-    public void testClientInvocation() throws Exception {
+    @Test
+    void testClientInvocation() throws Exception {
         // set the client's service access point
         Client client = new Client("http://localhost:"; + port + 
"/GreeterContext/SOAPMessageService");
         // invoke the services
         String response = client.invoke();
         
-        assertEquals("Get a wrong response", "Greetings from Apache Camel!!!! 
Request was  Hello Camel!!", response);
+        assertEquals("Greetings from Apache Camel!!!! Request was  Hello 
Camel!!", response, "Get a wrong response");
     }
 
     @Override
diff --git 
a/examples/jms-file/src/test/java/org/apache/camel/example/jmstofile/JmsToFileTest.java
 
b/examples/jms-file/src/test/java/org/apache/camel/example/jmstofile/JmsToFileTest.java
index 9cb808f..fb5e594 100644
--- 
a/examples/jms-file/src/test/java/org/apache/camel/example/jmstofile/JmsToFileTest.java
+++ 
b/examples/jms-file/src/test/java/org/apache/camel/example/jmstofile/JmsToFileTest.java
@@ -16,20 +16,20 @@
  */
 package org.apache.camel.example.jmstofile;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.camel.CamelContext;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.spi.Registry;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
-
 import static 
org.apache.camel.example.jmstofile.CamelJmsToFileExample.createActiveMQConnectionFactory;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -40,15 +40,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 class JmsToFileTest extends CamelTestSupport {
 
     @Override
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext camelContext = super.createCamelContext();
-        // Set up the ActiveMQ JMS Components
-        // tag::e2[]
-        ActiveMQConnectionFactory connectionFactory = 
createActiveMQConnectionFactory();
-        // Note we can explicitly name the component
-        camelContext.addComponent("test-jms", 
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
-
-        return camelContext;
+    protected void bindToRegistry(Registry registry) throws Exception {
+        registry.bind("test-jms", 
JmsComponent.jmsComponentAutoAcknowledge(createActiveMQConnectionFactory()));
     }
 
     @Test
diff --git 
a/examples/kafka/src/test/java/org/apache/camel/example/kafka/KafkaTest.java 
b/examples/kafka/src/test/java/org/apache/camel/example/kafka/KafkaTest.java
index 07679cd..75aa1f0 100644
--- a/examples/kafka/src/test/java/org/apache/camel/example/kafka/KafkaTest.java
+++ b/examples/kafka/src/test/java/org/apache/camel/example/kafka/KafkaTest.java
@@ -16,20 +16,20 @@
  */
 package org.apache.camel.example.kafka;
 
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.AdviceWith;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.testcontainers.containers.KafkaContainer;
 import org.testcontainers.utility.DockerImageName;
 
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
 import static 
org.apache.camel.example.kafka.MessagePublisherClient.setUpKafkaComponent;
 import static org.apache.camel.util.PropertiesHelper.asProperties;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -56,11 +56,6 @@ class KafkaTest extends CamelTestSupport {
     }
 
     @Override
-    public boolean isUseAdviceWith() {
-        return true;
-    }
-
-    @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
         // Set the location of the configuration
@@ -76,14 +71,15 @@ class KafkaTest extends CamelTestSupport {
         return camelContext;
     }
 
-    @Test
-    void should_exchange_messages_with_a_kafka_broker() throws Exception {
+    @BeforeEach
+    public void setUp() throws Exception {
         // Replace the from endpoint to send messages easily
-        AdviceWith.adviceWith(context, "input", ad -> 
ad.replaceFromWith("direct:in"));
-
-        // must start Camel after we are done using advice-with
-        context.start();
+        replaceRouteFromWith("input", "direct:in");
+        super.setUp();
+    }
 
+    @Test
+    void should_exchange_messages_with_a_kafka_broker() throws Exception {
         String message = UUID.randomUUID().toString();
         template.sendBody("direct:in", message);
         NotifyBuilder notify = new 
NotifyBuilder(context).fromRoute("FromKafka")
diff --git a/examples/loan-broker-cxf/pom.xml b/examples/loan-broker-cxf/pom.xml
index c91dc35..2e9bf5e 100644
--- a/examples/loan-broker-cxf/pom.xml
+++ b/examples/loan-broker-cxf/pom.xml
@@ -66,10 +66,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring-xml</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
             <artifactId>camel-cxf</artifactId>
         </dependency>
         <dependency>
@@ -112,14 +108,8 @@
 
         <!-- testing -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit-version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java
 
b/examples/loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java
index 79c9090..f740c50 100644
--- 
a/examples/loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java
+++ 
b/examples/loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java
@@ -20,17 +20,23 @@ import java.io.File;
 import java.io.FileOutputStream;
 
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class LoanBrokerWSTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class LoanBrokerWSTest extends CamelSpringTestSupport {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(LoanBrokerWSTest.class);
 
     private static String url;
 
-    @BeforeClass
+    @BeforeAll
     public static void setupFreePort() throws Exception {
         // find a free port number, and write that in the custom.properties 
file
         // which we will use for the unit tests, to avoid port number in use 
problems
@@ -63,10 +69,10 @@ public class LoanBrokerWSTest extends 
CamelSpringTestSupport {
     }
 
     @Test
-    public void testInvocation() throws Exception {
+    void testInvocation() throws Exception {
         LoanBrokerWS loanBroker = Client.getProxy(url);
         String result = loanBroker.getLoanQuote("SSN", 1000.54, 10);
-        log.info("Result: {}", result);
+        LOG.info("Result: {}", result);
         assertTrue(result.startsWith("The best rate is [ssn:SSN bank:bank"));
     }
 
diff --git a/examples/loan-broker-jms/pom.xml b/examples/loan-broker-jms/pom.xml
index 67f2200..6e42d4b 100644
--- a/examples/loan-broker-jms/pom.xml
+++ b/examples/loan-broker-jms/pom.xml
@@ -126,14 +126,8 @@
 
         <!-- testing -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit-version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java
 
b/examples/loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java
index 0a471dd..1b5ff1a 100644
--- 
a/examples/loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java
+++ 
b/examples/loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java
@@ -18,19 +18,27 @@ package org.apache.camel.loanbroker;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.test.junit4.TestSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class LoanBrokerQueueTest extends TestSupport {
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class LoanBrokerQueueTest extends CamelTestSupport {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(LoanBrokerQueueTest.class);
+
     private AbstractApplicationContext applicationContext;
     private CamelContext camelContext;
     private ProducerTemplate template;
 
-    @Before
+    @BeforeEach
     public void startServices() throws Exception {
         applicationContext = new 
ClassPathXmlApplicationContext("META-INF/spring/server.xml");
         camelContext = getCamelContext();
@@ -39,7 +47,7 @@ public class LoanBrokerQueueTest extends TestSupport {
         camelContext.start();
     }
 
-    @After
+    @AfterEach
     public void stopServices() throws Exception {
         if (camelContext != null) {
             camelContext.stop();
@@ -47,10 +55,10 @@ public class LoanBrokerQueueTest extends TestSupport {
     }
 
     @Test
-    public void testClientInvocation() throws Exception {
+    void testClientInvocation() throws Exception {
         String out = template.requestBodyAndHeader("jms:queue:loan", null, 
Constants.PROPERTY_SSN, "Client-A", String.class);
 
-        log.info("Result: {}", out);
+        LOG.info("Result: {}", out);
         assertNotNull(out);
         assertTrue(out.startsWith("The best rate is [ssn:Client-A bank:bank"));
     }
diff --git a/examples/management/pom.xml b/examples/management/pom.xml
index e2b9944..64e7f26 100644
--- a/examples/management/pom.xml
+++ b/examples/management/pom.xml
@@ -127,13 +127,7 @@
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit-version}</version>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/management/src/test/java/org/apache/camel/example/management/ManagementExampleTest.java
 
b/examples/management/src/test/java/org/apache/camel/example/management/ManagementExampleTest.java
index 5f111a2..e100cc8 100644
--- 
a/examples/management/src/test/java/org/apache/camel/example/management/ManagementExampleTest.java
+++ 
b/examples/management/src/test/java/org/apache/camel/example/management/ManagementExampleTest.java
@@ -21,12 +21,14 @@ import java.util.Set;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class ManagementExampleTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ManagementExampleTest extends CamelSpringTestSupport {
 
     @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
@@ -34,7 +36,7 @@ public class ManagementExampleTest extends 
CamelSpringTestSupport {
     }
 
     @Test
-    public void testManagementExample() throws Exception {
+    void testManagementExample() throws Exception {
         // Give it a bit of time to run
         Thread.sleep(2000);
 
diff --git a/examples/pojo-messaging/pom.xml b/examples/pojo-messaging/pom.xml
index 0b9658a..04a65ee 100644
--- a/examples/pojo-messaging/pom.xml
+++ b/examples/pojo-messaging/pom.xml
@@ -129,14 +129,8 @@
 
         <!-- testing -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit-version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git 
a/examples/pojo-messaging/src/test/java/org/apache/camel/example/pojo/CamelContextTest.java
 
b/examples/pojo-messaging/src/test/java/org/apache/camel/example/pojo/CamelContextTest.java
index b6b09a3..48f057b 100644
--- 
a/examples/pojo-messaging/src/test/java/org/apache/camel/example/pojo/CamelContextTest.java
+++ 
b/examples/pojo-messaging/src/test/java/org/apache/camel/example/pojo/CamelContextTest.java
@@ -17,33 +17,35 @@
 package org.apache.camel.example.pojo;
 
 import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class CamelContextTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class CamelContextTest extends CamelSpringTestSupport {
 
     @Override
-    @Before
-    public void setUp() throws Exception {
-        deleteDirectory("target/messages");
-        super.setUp();
+    protected Path testDirectory() {
+        return Paths.get("target/messages");
     }
 
     @Test
-    public void testCheckFiles() throws Exception {
+    void testCheckFiles() throws Exception {
         // wait a little for the files to be picked up and processed
         Thread.sleep(5000);
 
         File file = new File("target/messages/emea/hr_pickup");
-        assertTrue("The pickup folder should exists", file.exists());
-        assertEquals("There should be 1 dumped files", 1, file.list().length);
+        assertTrue(file.exists(), "The pickup folder should exists");
+        assertEquals(1, file.list().length, "There should be 1 dumped files");
         file = new File("target/messages/amer/hr_pickup");
-        assertTrue("The pickup folder should exists", file.exists());
-        assertEquals("There should be 2 dumped files", 2, file.list().length);
+        assertTrue(file.exists(), "The pickup folder should exists");
+        assertEquals(2, file.list().length, "There should be 2 dumped files");
     }
 
     @Override
diff --git a/examples/spring-pulsar/pom.xml b/examples/spring-pulsar/pom.xml
index ce03cdc..6835fcf 100644
--- a/examples/spring-pulsar/pom.xml
+++ b/examples/spring-pulsar/pom.xml
@@ -95,7 +95,7 @@
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
+            <artifactId>camel-test-spring-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/spring-pulsar/src/test/java/org/apache/camel/example/SpringJmsClientServerTest.java
 
b/examples/spring-pulsar/src/test/java/org/apache/camel/example/SpringJmsClientServerTest.java
index 13bf877..e7e8aaf 100644
--- 
a/examples/spring-pulsar/src/test/java/org/apache/camel/example/SpringJmsClientServerTest.java
+++ 
b/examples/spring-pulsar/src/test/java/org/apache/camel/example/SpringJmsClientServerTest.java
@@ -24,15 +24,17 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Producer;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class SpringJmsClientServerTest extends CamelSpringTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-    @BeforeClass
+class SpringJmsClientServerTest extends CamelSpringTestSupport {
+
+    @BeforeAll
     public static void setupFreePort() throws Exception {
         // find a free port number, and write that in the custom.properties 
file
         // which we will use for the unit tests, to avoid port number in use 
problems
@@ -51,14 +53,14 @@ public class SpringJmsClientServerTest extends 
CamelSpringTestSupport {
     }
     
     @Test
-    public void testCamelClientInvocation() {
+    void testCamelClientInvocation() {
         // as opposed to the CamelClientRemoting example we need to define the 
service URI in this java code
         int response = template.requestBody("jms:queue:numbers", 22, 
Integer.class);
-        assertEquals("Get a wrong response", 66, response);
+        assertEquals(66, response, "Get a wrong response");
     }
     
     @Test
-    public void testCamelEndpointInvocation() throws Exception {
+    void testCamelEndpointInvocation() throws Exception {
         // get the endpoint from the camel context
         Endpoint endpoint = context.getEndpoint("jms:queue:numbers");
 
@@ -78,9 +80,9 @@ public class SpringJmsClientServerTest extends 
CamelSpringTestSupport {
         producer.process(exchange);
 
         // get the response from the out body and cast it to an integer
-        int response = exchange.getOut().getBody(Integer.class);
+        int response = exchange.getIn().getBody(Integer.class);
         
-        assertEquals("Get a wrong response.", 33, response);
+        assertEquals(33, response, "Get a wrong response.");
 
         // stop the producer after usage
         producer.stop();
diff --git a/examples/spring/pom.xml b/examples/spring/pom.xml
index b2c3f4c..6901d7f 100644
--- a/examples/spring/pom.xml
+++ b/examples/spring/pom.xml
@@ -112,9 +112,15 @@
 
         <!-- for testing -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit-version}</version>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>${junit-jupiter-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>${junit-jupiter-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/examples/spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java
 
b/examples/spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java
index 2c3785c..3a776b6 100644
--- 
a/examples/spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java
+++ 
b/examples/spring/src/test/java/org/apache/camel/example/spring/IntegrationTest.java
@@ -17,13 +17,12 @@
 package org.apache.camel.example.spring;
 
 import org.apache.camel.spring.Main;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class IntegrationTest extends Assert {
+class IntegrationTest {
 
     @Test
-    public void testCamelRulesDeployCorrectlyInSpring() throws Exception {
+    void testCamelRulesDeployCorrectlyInSpring() throws Exception {
         // let's boot up the Spring application context for 2 seconds to check 
that it works OK
         Main main = new Main();
         main.run(new String[]{"-duration", "2s"});
diff --git 
a/examples/vertx-kafka/src/test/java/org/apache/camel/example/vertx/kafka/VertxKafkaTest.java
 
b/examples/vertx-kafka/src/test/java/org/apache/camel/example/vertx/kafka/VertxKafkaTest.java
index b5f2904..14a9795 100644
--- 
a/examples/vertx-kafka/src/test/java/org/apache/camel/example/vertx/kafka/VertxKafkaTest.java
+++ 
b/examples/vertx-kafka/src/test/java/org/apache/camel/example/vertx/kafka/VertxKafkaTest.java
@@ -16,20 +16,20 @@
  */
 package org.apache.camel.example.vertx.kafka;
 
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.AdviceWith;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.testcontainers.containers.KafkaContainer;
 import org.testcontainers.utility.DockerImageName;
 
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
 import static 
org.apache.camel.example.vertx.kafka.MessagePublisherClient.setUpKafkaComponent;
 import static org.apache.camel.util.PropertiesHelper.asProperties;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -57,11 +57,6 @@ class VertxKafkaTest extends CamelTestSupport {
     }
 
     @Override
-    public boolean isUseAdviceWith() {
-        return true;
-    }
-
-    @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
         // Set the location of the configuration
@@ -77,14 +72,15 @@ class VertxKafkaTest extends CamelTestSupport {
         return camelContext;
     }
 
-    @Test
-    void should_exchange_messages_with_a_kafka_broker() throws Exception {
+    @BeforeEach
+    public void setUp() throws Exception {
         // Replace the from endpoint to send messages easily
-        AdviceWith.adviceWith(context, "input", ad -> 
ad.replaceFromWith("direct:in"));
-
-        // must start Camel after we are done using advice-with
-        context.start();
+        replaceRouteFromWith("input", "direct:in");
+        super.setUp();
+    }
 
+    @Test
+    void should_exchange_messages_with_a_kafka_broker() throws Exception {
         String message = UUID.randomUUID().toString();
         template.sendBody("direct:in", message);
         NotifyBuilder notify = new 
NotifyBuilder(context).fromRoute("FromKafka")

Reply via email to