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/08/19 15:51:05 UTC

[camel] branch CAMEL-13826 updated (5791584 -> 318d0f7)

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

aldettinger pushed a change to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git.


 discard 5791584  Merging CAMEL-13826 branch with master
 discard 904fedd  CAMEL-13826: Migrated camel-hbase tests to camel-test-junit5
 discard 947c6fe  CAMEL-13826: Migrated camel-jmx tests to camel-test-junit5
 discard 5b2e63e  CAMEL-13826: Removed unneeded throws Exception for tests in camel-test-junit5
 discard e3cbc03  CAMEL-13826: Migrated camel-ahc-ws tests to camel-test-junit5
 discard a2db899  CAMEL-13826: Migrated camel-ahc tests to camel-test-junit5
 discard 1605719  CAMEL-13826: Moved route coverage to a dedicated class
 discard 0685f2a  CAMEL-13826: Removed deprecated methods and class
 discard 9894f4d  CAMEL-13826: Turned TestSupport into a utility class
     add 0cd6fa4  Camel-Salesforce: Support for relationship queries.
     new 5998ed2  CAMEL-13826: Turned TestSupport into a utility class
     new 22ea2e5  CAMEL-13826: Removed deprecated methods and class
     new 7b1bdbd  CAMEL-13826: Moved route coverage to a dedicated class
     new 1b1822f  CAMEL-13826: Migrated camel-ahc tests to camel-test-junit5
     new 0315224  CAMEL-13826: Migrated camel-ahc-ws tests to camel-test-junit5
     new 4115a6d  CAMEL-13826: Removed unneeded throws Exception for tests in camel-test-junit5
     new ebf74e5  CAMEL-13826: Migrated camel-jmx tests to camel-test-junit5
     new cdf8fac  CAMEL-13826: Migrated camel-hbase tests to camel-test-junit5
     new 318d0f7  Merging CAMEL-13826 branch with master

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5791584)
            \
             N -- N -- N   refs/heads/CAMEL-13826 (318d0f7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../salesforce/api/dto/AbstractSObjectBase.java    |    8 +
 .../component/salesforce/api/dto/Attributes.java   |   21 +
 .../salesforce/api/dto/SObjectDescription.java     |    1 +
 .../salesforce/api/dto/composite/Attributes.java   |   53 -
 .../salesforce/api/dto/composite/SObjectNode.java  |   14 +-
 .../dto/composite/SObjectNodeXStreamConverter.java |    4 +-
 .../salesforce/api/dto/composite/SObjectTree.java  |    7 +-
 .../salesforce/RestApiIntegrationTest.java         |  136 +-
 .../api/MultiSelectPicklistJsonTest.java           |    4 +-
 .../api/dto/composite/SObjectBatchTest.java        |  129 +-
 .../api/dto/composite/SObjectCompositeTest.java    |    6 +-
 .../api/dto/composite/SObjectTreeTest.java         |  101 +-
 .../salesforce/api/utils/QueryHelperTest.java      |   26 +-
 .../salesforce/dto/generated/Account.java          | 2965 +-------------------
 .../component/salesforce/dto/generated/Asset.java  |    4 +
 .../salesforce/dto/generated/Contact.java          |  854 +++---
 .../salesforce/dto/generated/Document.java         |  110 +-
 .../salesforce/dto/generated/Line_Item__c.java     |  114 +-
 .../salesforce/dto/generated/MSPTest.java          |    5 +-
 .../salesforce/dto/generated/Merchandise__c.java   |  119 +-
 .../dto/generated/QueryRecordsAccount.java         |   19 +
 .../dto/generated/QueryRecordsContact.java         |   19 +
 .../api/dto/composite_request_example.json         |   15 +-
 .../java/org/apache/camel/maven/GenerateMojo.java  |   51 +-
 .../org/apache/camel/maven/ObjectDescriptions.java |    4 +
 .../src/main/resources/sobject-lookup.vm           |   62 -
 .../src/main/resources/sobject-pojo.vm             |   63 +-
 .../camel/maven/CamelSalesforceMojoOutputTest.java |   13 +-
 .../src/test/resources/generated/Asset.java        |   12 +-
 .../resources/generated/Asset_LocalDateTime.java   |   12 +-
 .../src/test/resources/generated/Case.java         |   12 +-
 .../generated/ComplexCalculatedFormula.java        |   10 +-
 .../resources/generated/With_Reference__c.java     |   23 +-
 .../it/resources/salesforce/objects/Account.object |   11 +
 .../it/resources/salesforce/package.xml            |    1 +
 .../System Administrator With Hard Delete.profile  |    7 +-
 36 files changed, 1445 insertions(+), 3570 deletions(-)
 delete mode 100644 components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/composite/Attributes.java
 create mode 100644 components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/QueryRecordsAccount.java
 create mode 100644 components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/QueryRecordsContact.java
 delete mode 100644 components/camel-salesforce/camel-salesforce-maven-plugin/src/main/resources/sobject-lookup.vm


[camel] 01/09: CAMEL-13826: Turned TestSupport into a utility class

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5998ed22698756727ae56f6187d42b61cacfcb39
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Aug 8 20:36:35 2019 +0200

    CAMEL-13826: Turned TestSupport into a utility class
---
 .../apache/camel/test/junit5/CamelTestSupport.java |  53 +--
 .../org/apache/camel/test/junit5/TestSupport.java  | 444 ++++++++++-----------
 .../junit5/patterns/AdviceWithNotStartedTest.java  |   1 +
 .../test/junit5/patterns/DebugJUnit5Test.java      |   6 +-
 .../patterns/DebugNoLazyTypeConverterTest.java     |   6 +-
 .../camel/test/junit5/patterns/DebugTest.java      |   6 +-
 .../junit5/patterns/IsMockEndpointsFileTest.java   |   2 +
 .../RouteProcessorDumpRouteCoverageTest.java       |   1 +
 8 files changed, 265 insertions(+), 254 deletions(-)

diff --git a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index ff5c85b..d324389 100644
--- a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -108,7 +108,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
  * with some routes along with a {@link org.apache.camel.ProducerTemplate} for
  * use in the test case Do <tt>not</tt> use this class for Spring Boot testing.
  */
-public abstract class CamelTestSupport extends TestSupport implements BeforeEachCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback {
+public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback {
 
     /**
      * JVM system property which can be set to true to turn on dumping route
@@ -357,9 +357,9 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
 
     @BeforeEach
     public void setUp() throws Exception {
-        log.info("********************************************************************************");
-        log.info("Testing: " + currentTestName + "(" + getClass().getName() + ")");
-        log.info("********************************************************************************");
+        LOG.info("********************************************************************************");
+        LOG.info("Testing: " + currentTestName + "(" + getClass().getName() + ")");
+        LOG.info("********************************************************************************");
 
         if (isCreateCamelContextPerClass()) {
             INSTANCE.set(this);
@@ -421,7 +421,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
     }
 
     private void doSetUp() throws Exception {
-        log.debug("setUp test");
+        LOG.debug("setUp test");
         // jmx is enabled if we have configured to use it, or if dump route
         // coverage is enabled (it requires JMX)
         boolean jmx = useJmx() || isRouteCoverageEnabled();
@@ -445,7 +445,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         // set debugger if enabled
         if (isUseDebugger()) {
             if (context.getStatus().equals(ServiceStatus.Started)) {
-                log.info("Cannot setting the Debugger to the starting CamelContext, stop the CamelContext now.");
+                LOG.info("Cannot setting the Debugger to the starting CamelContext, stop the CamelContext now.");
                 // we need to stop the context first to setup the debugger
                 context.stop();
             }
@@ -492,7 +492,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         String include = getRouteFilterIncludePattern();
         String exclude = getRouteFilterExcludePattern();
         if (include != null || exclude != null) {
-            log.info("Route filtering pattern: include={}, exclude={}", include, exclude);
+            LOG.info("Route filtering pattern: include={}, exclude={}", include, exclude);
             context.getExtension(Model.class).setRouteFilterPattern(include, exclude);
         }
 
@@ -502,23 +502,23 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         if (isUseRouteBuilder()) {
             RoutesBuilder[] builders = createRouteBuilders();
             for (RoutesBuilder builder : builders) {
-                log.debug("Using created route builder: " + builder);
+                LOG.debug("Using created route builder: " + builder);
                 context.addRoutes(builder);
             }
             replaceFromEndpoints();
             boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
             if (skip) {
-                log.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
+                LOG.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
             } else if (isUseAdviceWith()) {
-                log.info("Skipping starting CamelContext as isUseAdviceWith is set to true.");
+                LOG.info("Skipping starting CamelContext as isUseAdviceWith is set to true.");
             } else {
                 startCamelContext();
             }
         } else {
             replaceFromEndpoints();
-            log.debug("Using route builder from the created context: " + context);
+            LOG.debug("Using route builder from the created context: " + context);
         }
-        log.debug("Routing Rules are: " + context.getRoutes());
+        LOG.debug("Routing Rules are: " + context.getRoutes());
 
         assertValidContext(context);
     }
@@ -542,9 +542,9 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
     public void tearDown() throws Exception {
         long time = watch.taken();
 
-        log.info("********************************************************************************");
-        log.info("Testing done: " + currentTestName + "(" + getClass().getName() + ")");
-        log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
+        LOG.info("********************************************************************************");
+        LOG.info("Testing done: " + currentTestName + "(" + getClass().getName() + ")");
+        LOG.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
 
         // if we should dump route stats, then write that to a file
         if (isRouteCoverageEnabled()) {
@@ -555,7 +555,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
             ManagedCamelContext mc = context != null ? context.getExtension(ManagedCamelContext.class) : null;
             ManagedCamelContextMBean managedCamelContext = mc != null ? mc.getManagedCamelContext() : null;
             if (managedCamelContext == null) {
-                log.warn("Cannot dump route coverage to file as JMX is not enabled. "
+                LOG.warn("Cannot dump route coverage to file as JMX is not enabled. "
                          + "Add camel-management-impl JAR as dependency and/or override useJmx() method to enable JMX in the unit test classes.");
             } else {
                 logCoverageSummary(managedCamelContext);
@@ -568,14 +568,14 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
                 file.mkdirs();
                 file = new File(dir, name);
 
-                log.info("Dumping route coverage to file: {}", file);
+                LOG.info("Dumping route coverage to file: {}", file);
                 InputStream is = new ByteArrayInputStream(combined.getBytes());
                 OutputStream os = new FileOutputStream(file, false);
                 IOHelper.copyAndCloseInput(is, os);
                 IOHelper.close(os);
             }
         }
-        log.info("********************************************************************************");
+        LOG.info("********************************************************************************");
 
         if (isCreateCamelContextPerClass()) {
             // will tear down test specially in CamelTearDownRule
@@ -677,7 +677,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         }
 
         builder.append(routesSummary);
-        log.info(builder.toString());
+        LOG.info(builder.toString());
     }
 
     /**
@@ -953,7 +953,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         // jndi.properties is optional
         InputStream in = getClass().getClassLoader().getResourceAsStream("jndi.properties");
         if (in != null) {
-            log.debug("Using jndi.properties from classpath root");
+            LOG.debug("Using jndi.properties from classpath root");
             properties.load(in);
         } else {
             properties.put("java.naming.factory.initial", "org.apache.camel.support.jndi.CamelInitialContextFactory");
@@ -1013,7 +1013,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
      * @return the endpoint
      */
     protected Endpoint resolveMandatoryEndpoint(String uri) {
-        return resolveMandatoryEndpoint(context, uri);
+        return TestSupport.resolveMandatoryEndpoint(context, uri);
     }
 
     /**
@@ -1025,7 +1025,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
      * @return the endpoint
      */
     protected <T extends Endpoint> T resolveMandatoryEndpoint(String uri, Class<T> endpointType) {
-        return resolveMandatoryEndpoint(context, uri, endpointType);
+        return TestSupport.resolveMandatoryEndpoint(context, uri, endpointType);
     }
 
     /**
@@ -1055,7 +1055,8 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
      * @throws NoSuchEndpointException is the mock endpoint does not exists
      */
     protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
-        // look for existing mock endpoints that have the same queue name, and to
+        // look for existing mock endpoints that have the same queue name, and
+        // to
         // do that we need to normalize uri and strip out query parameters and
         // whatnot
         String n;
@@ -1144,7 +1145,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
      * Creates an exchange with the given body
      */
     protected Exchange createExchangeWithBody(Object body) {
-        return createExchangeWithBody(context, body);
+        return TestSupport.createExchangeWithBody(context, body);
     }
 
     /**
@@ -1157,7 +1158,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         Expression expression = language.createExpression(expressionText);
         assertNotNull(expression, "No Expression could be created for text: " + expressionText + " language: " + language);
 
-        assertExpression(expression, exchange, expectedValue);
+        TestSupport.assertExpression(expression, exchange, expectedValue);
     }
 
     /**
@@ -1170,7 +1171,7 @@ public abstract class CamelTestSupport extends TestSupport implements BeforeEach
         Predicate predicate = language.createPredicate(expressionText);
         assertNotNull(predicate, "No Predicate could be created for text: " + expressionText + " language: " + language);
 
-        assertPredicate(predicate, exchange, expected);
+        TestSupport.assertPredicate(predicate, exchange, expected);
     }
 
     /**
diff --git a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java
index 47d296f..04b39b5 100644
--- a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java
+++ b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java
@@ -44,33 +44,37 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
- * A bunch of useful testing methods
+ * Provides utility methods for camel test purpose (builders, assertions,
+ * endpoint resolutions, file helpers).
  */
-public abstract class TestSupport {
+public final class TestSupport {
 
-    protected static final String LS = System.lineSeparator();
     private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class);
-    protected Logger log = LoggerFactory.getLogger(getClass());
 
+    private TestSupport() {
+    }
+
+    // -------------------------------------------------------------------------
     // Builder methods for expressions used when testing
     // -------------------------------------------------------------------------
 
     /**
-     * Returns a value builder for the given header
+     * Returns a value builder for the given header.
      */
     public static ValueBuilder header(String name) {
         return Builder.header(name);
     }
 
     /**
-     * Returns a value builder for the given exchange property
+     * Returns a value builder for the given exchange property.
      */
     public static ValueBuilder exchangeProperty(String name) {
         return Builder.exchangeProperty(name);
     }
 
     /**
-     * Returns a predicate and value builder for the inbound body on an exchange
+     * Returns a predicate and value builder for the inbound body on an
+     * exchange.
      */
     public static ValueBuilder body() {
         return Builder.body();
@@ -78,134 +82,139 @@ public abstract class TestSupport {
 
     /**
      * Returns a predicate and value builder for the inbound message body as a
-     * specific type
+     * specific type.
      */
     public static <T> ValueBuilder bodyAs(Class<T> type) {
         return Builder.bodyAs(type);
     }
 
     /**
-     * Returns a value builder for the given system property
+     * Returns a value builder for the given system property.
      */
     public static ValueBuilder systemProperty(String name) {
         return Builder.systemProperty(name);
     }
 
     /**
-     * Returns a value builder for the given system property
+     * Returns a value builder for the given system property.
      */
     public static ValueBuilder systemProperty(String name, String defaultValue) {
         return Builder.systemProperty(name, defaultValue);
     }
 
+    // -----------------------------------------------------------------------
     // Assertions
     // -----------------------------------------------------------------------
 
+    /**
+     * Asserts that a given value is of an expected type.
+     */
     public static <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
         assertNotNull(value, "Expected an instance of type: " + expectedType.getName() + " but was null");
         assertTrue(expectedType.isInstance(value), "Object should be of type " + expectedType.getName() + " but was: " + value + " with the type: " + value.getClass().getName());
         return expectedType.cast(value);
     }
 
-    public static void assertEndpointUri(Endpoint endpoint, String uri) {
-        assertNotNull(endpoint, "Endpoint is null when expecting endpoint for: " + uri);
-        assertEquals(endpoint.getEndpointUri(), "Endpoint uri for: " + endpoint, uri);
+    /**
+     * Asserts that a given endpoint has an expected uri.
+     */
+    public static void assertEndpointUri(Endpoint endpoint, String expectedUri) {
+        assertNotNull(endpoint, "Endpoint is null when expecting endpoint for: " + expectedUri);
+        assertEquals(expectedUri, endpoint.getEndpointUri(), "Endpoint uri for: " + endpoint);
     }
 
     /**
-     * Asserts the In message on the exchange contains the expected value
+     * Asserts that the In message on the exchange contains an header with a
+     * given name and expected value.
      */
-    public static Object assertInMessageHeader(Exchange exchange, String name, Object expected) {
-        return assertMessageHeader(exchange.getIn(), name, expected);
+    public static Object assertInMessageHeader(Exchange exchange, String headerName, Object expectedValue) {
+        return assertMessageHeader(exchange.getIn(), headerName, expectedValue);
     }
 
     /**
-     * Asserts the Out message on the exchange contains the expected value
+     * Asserts that the message on the exchange contains an header with a given
+     * name and expected value.
      */
-    public static Object assertOutMessageHeader(Exchange exchange, String name, Object expected) {
-        return assertMessageHeader(exchange.getOut(), name, expected);
+    public static Object assertOutMessageHeader(Exchange exchange, String headerName, Object expectedValue) {
+        return assertMessageHeader(exchange.getMessage(), headerName, expectedValue);
     }
 
     /**
-     * Asserts that the given exchange has an OUT message of the given body
-     * value
-     *
-     * @param exchange the exchange which should have an OUT message
-     * @param expected the expected value of the OUT message
-     * @throws InvalidPayloadException is thrown if the payload is not the
-     *             expected class type
+     * Asserts that the given exchange has a given expectedBody on the IN
+     * message.
      */
-    public static void assertInMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException {
-        assertNotNull(exchange, "Should have a response exchange!");
+    public static void assertInMessageBodyEquals(Exchange exchange, Object expectedBody) throws InvalidPayloadException {
+        assertNotNull(exchange, "Should have a response exchange");
 
-        Object actual;
-        if (expected == null) {
-            actual = exchange.getIn().getMandatoryBody();
-            assertEquals(expected, actual, "in body of: " + exchange);
+        Object actualBody;
+        if (expectedBody == null) {
+            actualBody = exchange.getIn().getMandatoryBody();
+            assertEquals(expectedBody, actualBody, "in body of: " + exchange);
         } else {
-            actual = exchange.getIn().getMandatoryBody(expected.getClass());
+            actualBody = exchange.getIn().getMandatoryBody(expectedBody.getClass());
         }
-        assertEquals(expected, actual, "in body of: " + exchange);
+        assertEquals(expectedBody, actualBody, "in body of: " + exchange);
 
         LOG.debug("Received response: " + exchange + " with in: " + exchange.getIn());
     }
 
     /**
-     * Asserts that the given exchange has an OUT message of the given body
-     * value
-     *
-     * @param exchange the exchange which should have an OUT message
-     * @param expected the expected value of the OUT message
-     * @throws InvalidPayloadException is thrown if the payload is not the
-     *             expected class type
+     * Asserts that the given exchange has a given expectedBody on the message.
      */
-    public static void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException {
+    public static void assertMessageBodyEquals(Exchange exchange, Object expectedBody) throws InvalidPayloadException {
         assertNotNull(exchange, "Should have a response exchange!");
 
-        Object actual;
-        if (expected == null) {
-            actual = exchange.getOut().getMandatoryBody();
-            assertEquals(expected, actual, "output body of: " + exchange);
+        Object actualBody;
+        if (expectedBody == null) {
+            actualBody = exchange.getMessage().getMandatoryBody();
+            assertEquals(expectedBody, actualBody, "output body of: " + exchange);
         } else {
-            actual = exchange.getOut().getMandatoryBody(expected.getClass());
+            actualBody = exchange.getMessage().getMandatoryBody(expectedBody.getClass());
         }
-        assertEquals(expected, actual, "output body of: " + exchange);
+        assertEquals(expectedBody, actualBody, "output body of: " + exchange);
 
-        LOG.debug("Received response: " + exchange + " with out: " + exchange.getOut());
+        LOG.debug("Received response: " + exchange + " with out: " + exchange.getMessage());
     }
 
-    public static Object assertMessageHeader(Message message, String name, Object expected) {
-        Object value = message.getHeader(name);
-        assertEquals(expected, value, "Header: " + name + " on Message: " + message);
-        return value;
+    /**
+     * Asserts that a given message contains an header with a given name and
+     * expected value.
+     */
+    public static Object assertMessageHeader(Message message, String headerName, Object expectedValue) {
+        Object actualValue = message.getHeader(headerName);
+        assertEquals(expectedValue, actualValue, "Header: " + headerName + " on Message: " + message);
+        return actualValue;
     }
 
     /**
-     * Asserts that the given expression when evaluated returns the given answer
+     * Asserts that the given expression when evaluated returns the given
+     * answer.
      */
-    public static Object assertExpression(Expression expression, Exchange exchange, Object expected) {
-        Object value;
-        if (expected != null) {
-            value = expression.evaluate(exchange, expected.getClass());
+    public static Object assertExpression(Expression expression, Exchange exchange, Object expectedAnswer) {
+        Object actualAnswer;
+        if (expectedAnswer != null) {
+            actualAnswer = expression.evaluate(exchange, expectedAnswer.getClass());
         } else {
-            value = expression.evaluate(exchange, Object.class);
+            actualAnswer = expression.evaluate(exchange, Object.class);
         }
 
-        LOG.debug("Evaluated expression: " + expression + " on exchange: " + exchange + " result: " + value);
+        LOG.debug("Evaluated expression: " + expression + " on exchange: " + exchange + " result: " + actualAnswer);
 
-        assertEquals(expected, value, "Expression: " + expression + " on Exchange: " + exchange);
-        return value;
+        assertEquals(expectedAnswer, actualAnswer, "Expression: " + expression + " on Exchange: " + exchange);
+        return actualAnswer;
     }
 
     /**
-     * Asserts that the predicate returns the expected value on the exchange
+     * Asserts that a given predicate returns <code>true</code> on a given
+     * exchange.
      */
     public static void assertPredicateMatches(Predicate predicate, Exchange exchange) {
         assertPredicate(predicate, exchange, true);
     }
 
     /**
-     * Asserts that the predicate returns the expected value on the exchange
+     * Asserts that a given predicate returns <code>false</code> on a given
+     * exchange.
      */
     public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) {
         try {
@@ -217,91 +226,163 @@ public abstract class TestSupport {
     }
 
     /**
-     * Asserts that the predicate returns the expected value on the exchange
+     * Asserts that the predicate returns the expected value on the exchange.
      */
-    public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean expected) {
-        if (expected) {
+    public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean expectedValue) {
+        if (expectedValue) {
             PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange);
         }
-        boolean value = predicate.matches(exchange);
+        boolean actualValue = predicate.matches(exchange);
 
-        LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result: " + value);
+        LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result: " + actualValue);
 
-        assertEquals(expected, value, "Predicate: " + predicate + " on Exchange: " + exchange);
-        return value;
+        assertEquals(expectedValue, actualValue, "Predicate: " + predicate + " on Exchange: " + exchange);
+        return actualValue;
     }
 
     /**
-     * Resolves an endpoint and asserts that it is found
+     * Asserts that a given list has a single element.
      */
-    public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
-        Endpoint endpoint = context.getEndpoint(uri);
+    public static <T> T assertOneElement(List<T> list) {
+        assertEquals(1, list.size(), "Size of list should be 1: " + list);
+        return list.get(0);
+    }
 
-        assertNotNull(endpoint, "No endpoint found for URI: " + uri);
+    /**
+     * Asserts that a given list has a given expected size.
+     */
+    public static <T> List<T> assertListSize(List<T> list, int expectedSize) {
+        return assertListSize("List", list, expectedSize);
+    }
 
-        return endpoint;
+    /**
+     * Asserts that a list is of the given size. When the assertion is broken,
+     * the error message starts with a given prefix.
+     */
+    public static <T> List<T> assertListSize(String brokenAssertionMessagePrefix, List<T> list, int expectedSize) {
+        assertEquals(expectedSize, list.size(), brokenAssertionMessagePrefix + " should be of size: " + expectedSize + " but is: " + list);
+        return list;
     }
 
     /**
-     * Resolves an endpoint and asserts that it is found
+     * Asserts that a given collection has a given size.
      */
-    public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context, String uri, Class<T> endpointType) {
-        T endpoint = context.getEndpoint(uri, endpointType);
+    public static <T> Collection<T> assertCollectionSize(Collection<T> list, int expectedSize) {
+        return assertCollectionSize("List", list, expectedSize);
+    }
 
-        assertNotNull(endpoint, "No endpoint found for URI: " + uri);
+    /**
+     * Asserts that a given collection has a given size. When the assertion is
+     * broken, the error message starts with a given prefix.
+     */
+    public static <T> Collection<T> assertCollectionSize(String brokenAssertionMessagePrefix, Collection<T> list, int expectedSize) {
+        assertEquals(expectedSize, list.size(), brokenAssertionMessagePrefix + " should be of size: " + expectedSize + " but is: " + list);
+        return list;
+    }
 
-        return endpoint;
+    /**
+     * Asserts that the text contains the given string.
+     *
+     * @param text the text to compare
+     * @param containedText the text which must be contained inside the other
+     *            text parameter
+     */
+    public static void assertStringContains(String text, String containedText) {
+        assertNotNull(text, "Text should not be null!");
+        assertTrue(text.contains(containedText), "Text: " + text + " does not contain: " + containedText);
     }
 
     /**
-     * Creates an exchange with the given body
+     * Asserts that two given directories are equal. To be used for
+     * folder/directory comparison that works across different platforms such as
+     * Window, Mac and Linux.
      */
-    protected Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
-        Exchange exchange = new DefaultExchange(camelContext);
-        Message message = exchange.getIn();
-        message.setHeader("testClass", getClass().getName());
-        message.setBody(body);
-        return exchange;
+    public static void assertDirectoryEquals(String expected, String actual) {
+        assertDirectoryEquals(null, expected, actual);
     }
 
-    public static <T> T assertOneElement(List<T> list) {
-        assertEquals(1, list.size(), "Size of list should be 1: " + list);
-        return list.get(0);
+    /**
+     * Asserts that two given directories are equal. To be used for
+     * folder/directory comparison that works across different platforms such as
+     * Window, Mac and Linux.
+     */
+    public static void assertDirectoryEquals(String message, String expected, String actual) {
+        // must use single / as path separators
+        String expectedPath = expected.replace('\\', '/');
+        String actualPath = actual.replace('\\', '/');
+
+        if (message != null) {
+            assertEquals(message, expectedPath, actualPath);
+        } else {
+            assertEquals(expectedPath, actualPath);
+        }
     }
 
     /**
-     * Asserts that a list is of the given size
+     * Asserts that a given directory is found in the file system.
      */
-    public static <T> List<T> assertListSize(List<T> list, int size) {
-        return assertListSize("List", list, size);
+    public static void assertDirectoryExists(String filename) {
+        File file = new File(filename);
+        assertTrue(file.exists(), "Directory " + filename + " should exist");
+        assertTrue(file.isDirectory(), "Directory " + filename + " should be a directory");
     }
 
     /**
-     * Asserts that a list is of the given size
+     * Asserts that a given file is found in the file system.
      */
-    public static <T> List<T> assertListSize(String message, List<T> list, int size) {
-        assertEquals(size, list.size(), message + " should be of size: " + size + " but is: " + list);
-        return list;
+    public static void assertFileExists(String filename) {
+        File file = new File(filename);
+        assertTrue(file.exists(), "File " + filename + " should exist");
+        assertTrue(file.isFile(), "File " + filename + " should be a file");
     }
 
     /**
-     * Asserts that a list is of the given size
+     * Asserts that a given file is <b>not</b> found in the file system.
      */
-    public static <T> Collection<T> assertCollectionSize(Collection<T> list, int size) {
-        return assertCollectionSize("List", list, size);
+    public static void assertFileNotExists(String filename) {
+        File file = new File(filename);
+        assertFalse(file.exists(), "File " + filename + " should not exist");
     }
 
+    // -----------------------------------------------------------------------
+    // Other helpers, resolution, file, getRouteList
+    // -----------------------------------------------------------------------
+
     /**
-     * Asserts that a list is of the given size
+     * Resolves an endpoint and asserts that it is found.
      */
-    public static <T> Collection<T> assertCollectionSize(String message, Collection<T> list, int size) {
-        assertEquals(size, list.size(), message + " should be of size: " + size + " but is: " + list);
-        return list;
+    public static Endpoint resolveMandatoryEndpoint(CamelContext context, String endpointUri) {
+        Endpoint endpoint = context.getEndpoint(endpointUri);
+
+        assertNotNull(endpoint, "No endpoint found for URI: " + endpointUri);
+
+        return endpoint;
+    }
+
+    /**
+     * Resolves an endpoint and asserts that it is found.
+     */
+    public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context, String endpointUri, Class<T> endpointType) {
+        T endpoint = context.getEndpoint(endpointUri, endpointType);
+
+        assertNotNull(endpoint, "No endpoint found for URI: " + endpointUri);
+
+        return endpoint;
+    }
+
+    /**
+     * Creates an exchange with the given body.
+     */
+    public static Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
+        Exchange exchange = new DefaultExchange(camelContext);
+        Message message = exchange.getIn();
+        message.setBody(body);
+        return exchange;
     }
 
     /**
      * A helper method to create a list of Route objects for a given route
-     * builder
+     * builder.
      */
     public static List<Route> getRouteList(RouteBuilder builder) throws Exception {
         CamelContext context = new DefaultCamelContext();
@@ -313,32 +394,22 @@ public abstract class TestSupport {
     }
 
     /**
-     * Asserts that the text contains the given string
-     *
-     * @param text the text to compare
-     * @param containedText the text which must be contained inside the other
-     *            text parameter
-     */
-    public static void assertStringContains(String text, String containedText) {
-        assertNotNull(text, "Text should not be null!");
-        assertTrue(text.contains(containedText), "Text: " + text + " does not contain: " + containedText);
-    }
-
-    /**
-     * Recursively delete a directory, useful to zapping test data
+     * Recursively delete a directory, useful to zapping test data. Deletion
+     * will be attempted up to five time before giving up.
      *
      * @param file the directory to be deleted
-     * @return <tt>false</tt> if error deleting directory
+     * @return <tt>false</tt> when an error occur while deleting directory
      */
     public static boolean deleteDirectory(String file) {
         return deleteDirectory(new File(file));
     }
 
     /**
-     * Recursively delete a directory, useful to zapping test data
+     * Recursively delete a directory, useful to zapping test data. Deletion
+     * will be attempted up to five time before giving up.
      *
      * @param file the directory to be deleted
-     * @return <tt>false</tt> if error deleting directory
+     * @return <tt>false</tt> when an error occur while deleting directory
      */
     public static boolean deleteDirectory(File file) {
         int tries = 0;
@@ -359,7 +430,13 @@ public abstract class TestSupport {
         return !exists;
     }
 
-    private static void recursivelyDeleteDirectory(File file) {
+    /**
+     * Recursively delete a directory. Deletion will be attempted a single time
+     * before giving up.
+     *
+     * @param file the directory to be deleted
+     */
+    public static void recursivelyDeleteDirectory(File file) {
         if (!file.exists()) {
             return;
         }
@@ -377,7 +454,7 @@ public abstract class TestSupport {
     }
 
     /**
-     * create the directory
+     * Creates a given directory.
      *
      * @param file the directory to be created
      */
@@ -387,122 +464,39 @@ public abstract class TestSupport {
     }
 
     /**
-     * To be used for folder/directory comparison that works across different
-     * platforms such as Window, Mac and Linux.
-     */
-    public static void assertDirectoryEquals(String expected, String actual) {
-        assertDirectoryEquals(null, expected, actual);
-    }
-
-    /**
-     * To be used for folder/directory comparison that works across different
-     * platforms such as Window, Mac and Linux.
-     */
-    public static void assertDirectoryEquals(String message, String expected, String actual) {
-        // must use single / as path separators
-        String expectedPath = expected.replace('\\', '/');
-        String actualPath = actual.replace('\\', '/');
-
-        if (message != null) {
-            assertEquals(message, expectedPath, actualPath);
-        } else {
-            assertEquals(expectedPath, actualPath);
-        }
-    }
-
-    /**
-     * To be used to check is a directory is found in the file system
-     */
-    public static void assertDirectoryExists(String filename) {
-        File file = new File(filename);
-        assertTrue(file.exists(), "Directory " + filename + " should exist");
-        assertTrue(file.isDirectory(), "Directory " + filename + " should be a directory");
-    }
-
-    /**
-     * To be used to check is a file is found in the file system
-     */
-    public static void assertFileExists(String filename) {
-        File file = new File(filename);
-        assertTrue(file.exists(), "File " + filename + " should exist");
-        assertTrue(file.isFile(), "File " + filename + " should be a file");
-    }
-
-    /**
-     * To be used to check is a file is <b>not</b> found in the file system
-     */
-    public static void assertFileNotExists(String filename) {
-        File file = new File(filename);
-        assertFalse(file.exists(), "File " + filename + " should not exist");
-    }
-
-    /**
-     * Is this OS the given platform.
+     * Tells whether the current Operating System is the given expected
+     * platform.
      * <p/>
-     * Uses <tt>os.name</tt> from the system properties to determine the OS.
+     * Uses <tt>os.name</tt> from the system properties to determine the
+     * Operating System.
      *
-     * @param platform such as Windows
-     * @return <tt>true</tt> if its that platform.
+     * @param expectedPlatform such as Windows
+     * @return <tt>true</tt> when the current Operating System is the expected
+     *         platform, <tt>false</tt> otherwise.
      */
-    public static boolean isPlatform(String platform) {
+    public static boolean isPlatform(String expectedPlatform) {
         String osName = System.getProperty("os.name").toLowerCase(Locale.US);
-        return osName.contains(platform.toLowerCase(Locale.US));
+        return osName.contains(expectedPlatform.toLowerCase(Locale.US));
     }
 
     /**
-     * Is this Java by the given vendor.
+     * Tells whether the current Java Virtual Machine has been issued by a given
+     * expected vendor.
      * <p/>
      * Uses <tt>java.vendor</tt> from the system properties to determine the
      * vendor.
      *
-     * @param vendor such as IBM
-     * @return <tt>true</tt> if its that vendor.
+     * @param expectedVendor such as IBM
+     * @return <tt>true</tt> when the current Java Virtual Machine has been
+     *         issued by the expected vendor, <tt>false</tt> otherwise.
      */
-    public static boolean isJavaVendor(String vendor) {
+    public static boolean isJavaVendor(String expectedVendor) {
         String javaVendor = System.getProperty("java.vendor").toLowerCase(Locale.US);
-        return javaVendor.contains(vendor.toLowerCase(Locale.US));
-    }
-
-    /**
-     * Is this Java 1.5
-     *
-     * @return <tt>true</tt> if its Java 1.5, <tt>false</tt> if its not (for
-     *         example Java 1.6 or better)
-     * @deprecated will be removed in the future as Camel requires JDK1.8+
-     */
-    @Deprecated
-    public static boolean isJava15() {
-        return getJavaMajorVersion() == 5;
-    }
-
-    /**
-     * Is this Java 1.6
-     *
-     * @return <tt>true</tt> if its Java 1.6, <tt>false</tt> if its not (for
-     *         example Java 1.7 or better)
-     * @deprecated will be removed in the future as Camel requires JDK1.8+
-     */
-    @Deprecated
-    public static boolean isJava16() {
-        return getJavaMajorVersion() == 6;
-
-    }
-
-    /**
-     * Is this Java 1.7
-     *
-     * @return <tt>true</tt> if its Java 1.7, <tt>false</tt> if its not (for
-     *         example Java 1.6 or older)
-     * @deprecated will be removed in the future as Camel requires JDK1.8+
-     */
-    @Deprecated
-    public static boolean isJava17() {
-        return getJavaMajorVersion() == 7;
-
+        return javaVendor.contains(expectedVendor.toLowerCase(Locale.US));
     }
 
     /**
-     * Is this Java 1.8
+     * Tells whether the current Java version is 1.8.
      *
      * @return <tt>true</tt> if its Java 1.8, <tt>false</tt> if its not (for
      *         example Java 1.7 or older)
@@ -513,7 +507,7 @@ public abstract class TestSupport {
     }
 
     /**
-     * Is this Java 1.9
+     * Tells whether the current Java version is 1.9.
      *
      * @return <tt>true</tt> if its Java 1.9, <tt>false</tt> if its not (for
      *         example Java 1.8 or older)
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
index 68aae9c..b097165 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
@@ -26,6 +26,7 @@ import org.apache.camel.reifier.RouteReifier;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 import static org.junit.jupiter.api.Assertions.fail;
 
 public class AdviceWithNotStartedTest extends CamelTestSupport {
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
index 9a6811b..183d1d7 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
@@ -22,9 +22,13 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DebugJUnit5Test extends CamelTestSupport {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DebugJUnit5Test.class);
+
     // START SNIPPET: e1
     @Override
     public boolean isUseDebugger() {
@@ -38,7 +42,7 @@ public class DebugJUnit5Test extends CamelTestSupport {
         // processor
         // from your Java editor you can just add a breakpoint in the code line
         // below
-        log.info("Before " + definition + " with body " + exchange.getIn().getBody());
+        LOG.info("Before " + definition + " with body " + exchange.getIn().getBody());
     }
     // END SNIPPET: e1
 
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
index 7584f15..a9cb78f 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
@@ -22,9 +22,13 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DebugNoLazyTypeConverterTest extends CamelTestSupport {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DebugNoLazyTypeConverterTest.class);
+
     @Override
     protected boolean isLazyLoadingTypeConverter() {
         return false;
@@ -43,7 +47,7 @@ public class DebugNoLazyTypeConverterTest extends CamelTestSupport {
         // processor
         // from your Java editor you can just add a breakpoint in the code line
         // below
-        log.info("Before " + definition + " with body " + exchange.getIn().getBody());
+        LOG.info("Before " + definition + " with body " + exchange.getIn().getBody());
     }
     // END SNIPPET: e1
 
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
index 38f75d5..87ae779 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
@@ -22,9 +22,13 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DebugTest extends CamelTestSupport {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DebugTest.class);
+
     // START SNIPPET: e1
     @Override
     public boolean isUseDebugger() {
@@ -38,7 +42,7 @@ public class DebugTest extends CamelTestSupport {
         // processor
         // from your Java editor you can just add a breakpoint in the code line
         // below
-        log.info("Before " + definition + " with body " + exchange.getIn().getBody());
+        LOG.info("Before " + definition + " with body " + exchange.getIn().getBody());
     }
     // END SNIPPET: e1
 
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
index 1407f13..fe621af 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
@@ -23,6 +23,8 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
+
 public class IsMockEndpointsFileTest extends CamelTestSupport {
 
     @Override
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
index fe820dd..b97959c 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
@@ -22,6 +22,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {


[camel] 09/09: Merging CAMEL-13826 branch with master

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 318d0f7e7384a61abb1e9f5c53cf1fe6560765a8
Author: aldettinger <al...@gmail.com>
AuthorDate: Mon Aug 19 16:41:46 2019 +0200

    Merging CAMEL-13826 branch with master
---
 .../apache/camel/test/AvailablePortFinderTest.java | 38 ++++++++++------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
index 3b96852..c4fdf09 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
@@ -1,19 +1,19 @@
 /*
- *  * 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.
- *                */
+ * 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.test;
 
 import java.net.DatagramSocket;
@@ -24,14 +24,12 @@ import java.net.ServerSocket;
 
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class AvailablePortFinderTest {
 
     @Test
-    public void testNotAvailableTcpPort() {
+    public void testNotAvailableTcpPort() throws Exception {
         int p1 = AvailablePortFinder.getNextAvailable();
         ServerSocket socket = new ServerSocket(p1);
         int p2 = AvailablePortFinder.getNextAvailable();
@@ -40,7 +38,7 @@ public class AvailablePortFinderTest {
     }
 
     @Test
-    public void testNotAvailableUdpPort() {
+    public void testNotAvailableUdpPort() throws Exception {
         int p1 = AvailablePortFinder.getNextAvailable();
         DatagramSocket socket = new DatagramSocket(p1);
         int p2 = AvailablePortFinder.getNextAvailable();
@@ -49,7 +47,7 @@ public class AvailablePortFinderTest {
     }
 
     @Test
-    public void testNotAvailableMulticastPort() {
+    public void testNotAvailableMulticastPort() throws Exception {
         int p1 = AvailablePortFinder.getNextAvailable();
         MulticastSocket socket = new MulticastSocket(null);
         socket.setReuseAddress(false); // true is default for MulticastSocket, we wan to fail if port is occupied


[camel] 04/09: CAMEL-13826: Migrated camel-ahc tests to camel-test-junit5

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1b1822fa29ecea5e32f8597104f4b0f871cde096
Author: aldettinger <al...@gmail.com>
AuthorDate: Tue Aug 13 16:09:14 2019 +0200

    CAMEL-13826: Migrated camel-ahc tests to camel-test-junit5
---
 components/camel-ahc/pom.xml                       |  7 +++--
 .../ahc/AhcBridgeEndpointPathWithSpacesTest.java   |  6 +++--
 .../camel/component/ahc/AhcBridgeEndpointTest.java | 12 ++++++---
 .../component/ahc/AhcClientConfigRealmUriTest.java |  4 ++-
 .../component/ahc/AhcClientConfigUriTest.java      |  4 ++-
 .../ahc/AhcComponentClientConfigTest.java          |  2 +-
 ...entConfigWithClientConfigUriParametersTest.java |  5 +++-
 .../ahc/AhcComponentCustomClientConfigTest.java    |  2 +-
 .../ahc/AhcComponentNettyClientConfigTest.java     |  2 +-
 .../apache/camel/component/ahc/AhcGoogleTest.java  |  8 +++---
 .../ahc/AhcOperationFailedExceptionTest.java       |  4 +--
 .../camel/component/ahc/AhcProduce500Test.java     |  7 ++++-
 .../component/ahc/AhcProduceClientConfigTest.java  |  2 +-
 ...entConfigWithClientConfigUriParametersTest.java |  5 +++-
 .../component/ahc/AhcProduceGetHeadersTest.java    |  2 +-
 .../ahc/AhcProduceGetNoSlashInUriTest.java         |  2 +-
 .../camel/component/ahc/AhcProduceGetTest.java     |  4 ++-
 .../AhcProduceNoThrowExceptionOnFailureTest.java   |  2 +-
 .../component/ahc/AhcProducePostDoWhileTest.java   |  2 +-
 .../component/ahc/AhcProducePostHeadersTest.java   |  2 +-
 .../camel/component/ahc/AhcProducePostTest.java    |  4 ++-
 .../ahc/AhcProduceTransferExceptionTest.java       |  7 ++++-
 ...hcProduceWithClientConfigUriParametersTest.java |  2 +-
 .../ahc/AhcProducerConnectionCloseHeadersTest.java |  2 +-
 .../component/ahc/AhcProducerSessionTest.java      |  2 +-
 .../AhcProducerTwoParametersWithSameKeyTest.java   | 10 ++++---
 .../apache/camel/component/ahc/BaseAhcTest.java    |  6 ++---
 .../camel/component/ahc/HttpEndpointURLTest.java   |  6 +++--
 .../ahc/HttpHeaderFilterStrategyTest.java          | 11 +++++---
 .../ahc/javabody/AhcProduceJavaBodyTest.java       |  8 +++++-
 .../src/main/docs/test-junit5.adoc                 | 31 ++++++++++++++++++++++
 31 files changed, 124 insertions(+), 49 deletions(-)

diff --git a/components/camel-ahc/pom.xml b/components/camel-ahc/pom.xml
index 8395944..18d4d9b 100644
--- a/components/camel-ahc/pom.xml
+++ b/components/camel-ahc/pom.xml
@@ -65,7 +65,7 @@
         <!-- testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -78,10 +78,9 @@
             <artifactId>camel-jetty</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointPathWithSpacesTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointPathWithSpacesTest.java
index a71ddf6..ac4bcde 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointPathWithSpacesTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointPathWithSpacesTest.java
@@ -21,7 +21,9 @@ import java.io.ByteArrayInputStream;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AhcBridgeEndpointPathWithSpacesTest extends BaseAhcTest {
 
@@ -32,7 +34,7 @@ public class AhcBridgeEndpointPathWithSpacesTest extends BaseAhcTest {
     public void testBridgeEndpoint() throws Exception {
         String response = template.requestBodyAndHeader("http://localhost:" + port1 + "/test bar/hello",
                 new ByteArrayInputStream("This is a test".getBytes()), "Content-Type", "application/xml", String.class);
-        assertEquals("Get a wrong response", "/proxy%20bar/hello", response);
+        assertEquals("/proxy%20bar/hello", response, "Get a wrong response");
     }
 
     @Override
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointTest.java
index 920d0ae..0a15b63 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcBridgeEndpointTest.java
@@ -22,7 +22,11 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class AhcBridgeEndpointTest extends BaseAhcTest {
 
@@ -33,16 +37,16 @@ public class AhcBridgeEndpointTest extends BaseAhcTest {
     public void testBridgeEndpoint() throws Exception {
         String response = template.requestBodyAndHeader("http://localhost:" + port1 + "/test/hello",
                 new ByteArrayInputStream("This is a test".getBytes()), "Content-Type", "application/xml", String.class);
-        assertEquals("Get a wrong response", "/", response);
+        assertEquals("/", response, "Get a wrong response");
 
         response = template.requestBody("http://localhost:" + port2 + "/hello/world", "hello", String.class);
-        assertEquals("Get a wrong response", "/hello/world", response);
+        assertEquals("/hello/world", response, "Get a wrong response");
 
         try {
             template.requestBody("http://localhost:" + port1 + "/hello/world", "hello", String.class);
             fail("Expect exception here!");
         } catch (Exception ex) {
-            assertTrue("We should get a RuntimeCamelException", ex instanceof RuntimeCamelException);
+            assertTrue(ex instanceof RuntimeCamelException, "We should get a RuntimeCamelException");
         }
     }
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
index 0f44664..dce95e0 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
@@ -17,7 +17,9 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AhcClientConfigRealmUriTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigUriTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigUriTest.java
index 835acee..9b29667 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigUriTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigUriTest.java
@@ -17,7 +17,9 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AhcClientConfigUriTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java
index 35a3311..6664ada 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.asynchttpclient.DefaultAsyncHttpClientConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcComponentClientConfigTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java
index 2e827b7..50c7b4d 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java
@@ -17,7 +17,10 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.Endpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class AhcComponentClientConfigWithClientConfigUriParametersTest extends AhcComponentClientConfigTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentCustomClientConfigTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentCustomClientConfigTest.java
index 7e1d518..3ebba9f 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentCustomClientConfigTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentCustomClientConfigTest.java
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.asynchttpclient.DefaultAsyncHttpClientConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcComponentCustomClientConfigTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentNettyClientConfigTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentNettyClientConfigTest.java
index 94c0681..33f370a 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentNettyClientConfigTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentNettyClientConfigTest.java
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.asynchttpclient.DefaultAsyncHttpClientConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcComponentNettyClientConfigTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcGoogleTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcGoogleTest.java
index 3c71f5b..f7cb93c 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcGoogleTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcGoogleTest.java
@@ -17,14 +17,14 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Requires online internet connection for testing.
  */
-@Ignore("Run this test manual as it requires online internet")
+@Disabled("Run this test manual as it requires online internet")
 public class AhcGoogleTest extends CamelTestSupport {
 
     @Test
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcOperationFailedExceptionTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcOperationFailedExceptionTest.java
index 0ad335d..5a58d41 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcOperationFailedExceptionTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcOperationFailedExceptionTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.ahc;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsNot.not;
 import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertThat;
 
 public class AhcOperationFailedExceptionTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java
index 1843822..42bf0e7 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java
@@ -20,7 +20,12 @@ import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class AhcProduce500Test extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java
index 0416a7d..b30a684 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.asynchttpclient.DefaultAsyncHttpClientConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProduceClientConfigTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java
index 0b023d7..9058c8d 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java
@@ -17,7 +17,10 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.Endpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class AhcProduceClientConfigWithClientConfigUriParametersTest extends AhcProduceClientConfigTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java
index f053f45..72029d3 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProduceGetHeadersTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java
index 682b8f6..bcee6b4 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java
@@ -17,7 +17,7 @@
 package org.apache.camel.component.ahc;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProduceGetNoSlashInUriTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java
index 1e53506..0075202 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java
@@ -18,7 +18,9 @@ package org.apache.camel.component.ahc;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AhcProduceGetTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java
index 99c1bca..ce6aaa8 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.ahc;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProduceNoThrowExceptionOnFailureTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostDoWhileTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostDoWhileTest.java
index a32275f..87d8307 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostDoWhileTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostDoWhileTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.ahc;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProducePostDoWhileTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java
index 40fff12..734fb50 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProducePostHeadersTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java
index d34f645..d2767e5 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java
@@ -18,7 +18,9 @@ package org.apache.camel.component.ahc;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AhcProducePostTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java
index 4e2076b..c8b3305 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java
@@ -18,7 +18,12 @@ package org.apache.camel.component.ahc;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class AhcProduceTransferExceptionTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java
index da1ba0a..fed7ab3 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.ahc;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProduceWithClientConfigUriParametersTest extends BaseAhcTest {
     @Test
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
index 34ade6e..cc37cee 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProducerConnectionCloseHeadersTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
index 1707957..d39becb 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
@@ -28,7 +28,7 @@ import org.apache.camel.http.common.cookie.ExchangeCookieHandler;
 import org.apache.camel.http.common.cookie.InstanceCookieHandler;
 import org.asynchttpclient.AsyncHttpClientConfig;
 import org.asynchttpclient.DefaultAsyncHttpClientConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AhcProducerSessionTest extends BaseAhcTest {
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java
index d3edca1..a4e891b 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java
@@ -22,7 +22,11 @@ import java.util.List;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 /**
  *
@@ -34,7 +38,7 @@ public class AhcProducerTwoParametersWithSameKeyTest extends BaseAhcTest {
         Exchange out = template.request("ahc:http://localhost:{{port}}/myapp?from=me&to=foo&to=bar", null);
 
         assertNotNull(out);
-        assertFalse("Should not fail", out.isFailed());
+        assertFalse(out.isFailed(), "Should not fail");
         assertEquals("OK", out.getOut().getBody(String.class));
         assertEquals("yes", out.getOut().getHeader("bar"));
     }
@@ -53,7 +57,7 @@ public class AhcProducerTwoParametersWithSameKeyTest extends BaseAhcTest {
         });
 
         assertNotNull(out);
-        assertFalse("Should not fail", out.isFailed());
+        assertFalse(out.isFailed(), "Should not fail");
         assertEquals("OK", out.getOut().getBody(String.class));
         assertEquals("yes", out.getOut().getHeader("bar"));
 
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
index 047b2b1..254b11b 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
@@ -27,8 +27,8 @@ import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.support.jsse.SSLContextServerParameters;
 import org.apache.camel.support.jsse.TrustManagersParameters;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.BeforeClass;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeAll;
 
 public abstract class BaseAhcTest extends CamelTestSupport {
 
@@ -36,7 +36,7 @@ public abstract class BaseAhcTest extends CamelTestSupport {
 
     private static volatile int port;
 
-    @BeforeClass
+    @BeforeAll
     public static void initPort() throws Exception {
         port = AvailablePortFinder.getNextAvailable();
     }
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpEndpointURLTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpEndpointURLTest.java
index 108e281..dcea426 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpEndpointURLTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpEndpointURLTest.java
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.component.ahc;
 
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class HttpEndpointURLTest extends CamelTestSupport {
     
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpHeaderFilterStrategyTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpHeaderFilterStrategyTest.java
index 6b198c3..8447415 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpHeaderFilterStrategyTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/HttpHeaderFilterStrategyTest.java
@@ -19,9 +19,12 @@ package org.apache.camel.component.ahc;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HttpHeaderFilterStrategyTest extends CamelTestSupport {
 
@@ -29,7 +32,7 @@ public class HttpHeaderFilterStrategyTest extends CamelTestSupport {
     private Exchange exchange;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         filter = new HttpHeaderFilterStrategy();
         exchange = new DefaultExchange(new DefaultCamelContext());
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java
index 4f3804a..77bc296 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java
@@ -24,7 +24,13 @@ import org.apache.camel.component.ahc.AhcConstants;
 import org.apache.camel.component.ahc.BaseAhcTest;
 import org.apache.camel.component.jetty.JettyHttpComponent;
 import org.apache.camel.http.common.HttpCommonComponent;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  *
diff --git a/components/camel-test-junit5/src/main/docs/test-junit5.adoc b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
index 6624d90..d9a4d5c 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -44,3 +44,34 @@ public class SimpleMockTest extends CamelTestSupport {
 }
 ----
 
+== Migrating Camel Tests from JUnit 4 to JUnit 5
+Find below some hints to help in migrating camel tests from JUnit 4 to JUnit 5.
+
+=== Referencing the Camel Test JUnit5 library in your project
+Projects using `camel-test` would need to use `camel-test-junit5`. For instance, maven users would update their pom.xml file as below:
+----
+<dependency>
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-test-junit5</artifactId>
+  <scope>test</scope>
+</dependency>
+----
+
+=== Typical migration steps linked to JUnit 5 support in Camel Test
+* Imports of `org.apache.camel.test.junit4.\*` should be replaced with `org.apache.camel.test.junit5.*`
+* `TestSupport` static methods should be imported where needed, for instance `import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf`
+
+=== Typical migration steps linked to JUnit 5 itself
+Once Camel related steps have been performed, there are still typical JUnit 5 migration steps to remember:
+
+* New JUnit 5 assertions should be imported where needed, for instance `import static org.junit.jupiter.api.Assertions.assertEquals`
+* Assertion messages should be moved to the last parameter where needed, for instance `assertEquals("message", 2, 1)` becomes `assertEquals(2, 1, "message")`
+* `org.junit.Test` should be changed in favor of `org.junit.jupiter.api.Test`
+* `org.junit.Ignore` should be changed in favor of `org.junit.jupiter.api.Disabled`
+* `org.junit.Before` should be changed in favor of `org.junit.jupiter.api.BeforeEach`
+* `org.junit.After` should be changed in favor of `org.junit.jupiter.api.AfterEach`
+* `org.junit.BeforeClass` should be changed in favor of `import org.junit.jupiter.api.BeforeAll`
+* `org.junit.AfterClass` should be changed in favor of `import org.junit.jupiter.api.AfterAll`
+* Built-in `assertThat` from third-party assertion libraries should be used. For instance, use `org.hamcrest.MatcherAssert.assertThat` from `java-hamcrest`
+
+Depending on the context, more involved tips might be needed, please check the https://junit.org/junit5/docs/current/user-guide/[JUnit 5 User Guide] then.
\ No newline at end of file


[camel] 03/09: CAMEL-13826: Moved route coverage to a dedicated class

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7b1bdbdbe0416cf40b3f1e5b12407dd55a749a3b
Author: aldettinger <al...@gmail.com>
AuthorDate: Mon Aug 12 17:52:33 2019 +0200

    CAMEL-13826: Moved route coverage to a dedicated class
---
 .../camel/test/CamelRouteCoverageDumper.java       | 190 +++++++++++++++++++++
 .../apache/camel/test/junit5/CamelTestSupport.java | 152 +----------------
 .../RouteProcessorDumpRouteCoverageTest.java       |  20 ++-
 3 files changed, 208 insertions(+), 154 deletions(-)

diff --git a/components/camel-test-junit5/src/main/java/org/apache/camel/test/CamelRouteCoverageDumper.java b/components/camel-test-junit5/src/main/java/org/apache/camel/test/CamelRouteCoverageDumper.java
new file mode 100644
index 0000000..ff3252a
--- /dev/null
+++ b/components/camel-test-junit5/src/main/java/org/apache/camel/test/CamelRouteCoverageDumper.java
@@ -0,0 +1,190 @@
+/*
+ * 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.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.apache.camel.Route;
+import org.apache.camel.api.management.ManagedCamelContext;
+import org.apache.camel.api.management.mbean.ManagedCamelContextMBean;
+import org.apache.camel.api.management.mbean.ManagedProcessorMBean;
+import org.apache.camel.api.management.mbean.ManagedRouteMBean;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.util.IOHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A <code>CamelRouteCoverageDumper</code> instance dumps the route coverage of
+ * a given camel test.
+ */
+public class CamelRouteCoverageDumper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(CamelRouteCoverageDumper.class);
+
+    public void dump(ManagedCamelContextMBean managedCamelContext, ModelCamelContext context, String dumpDir, String dumpFilename, String testClass, String testName,
+                     long testTimeTaken)
+        throws Exception {
+        logCoverageSummary(managedCamelContext, context);
+
+        String routeCoverageAsXml = managedCamelContext.dumpRoutesCoverageAsXml();
+        String combined = "<camelRouteCoverage>\n" + gatherTestDetailsAsXml(testClass, testName, testTimeTaken) + routeCoverageAsXml + "\n</camelRouteCoverage>";
+
+        File dumpFile = new File(dumpDir);
+        // ensure dir exists
+        dumpFile.mkdirs();
+        dumpFile = new File(dumpDir, dumpFilename);
+
+        LOG.info("Dumping route coverage to file: {}", dumpFile);
+        InputStream is = new ByteArrayInputStream(combined.getBytes());
+        OutputStream os = new FileOutputStream(dumpFile, false);
+        IOHelper.copyAndCloseInput(is, os);
+        IOHelper.close(os);
+    }
+
+    /**
+     * Groups all processors from Camel context by route id.
+     */
+    private Map<String, List<ManagedProcessorMBean>> findProcessorsForEachRoute(MBeanServer server, ModelCamelContext context)
+        throws MalformedObjectNameException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
+        String domain = context.getManagementStrategy().getManagementAgent().getMBeanServerDefaultDomain();
+
+        Map<String, List<ManagedProcessorMBean>> processorsForRoute = new HashMap<>();
+
+        ObjectName processorsObjectName = new ObjectName(domain + ":context=" + context.getManagementName() + ",type=processors,name=*");
+        Set<ObjectName> objectNames = server.queryNames(processorsObjectName, null);
+
+        for (ObjectName objectName : objectNames) {
+            String routeId = server.getAttribute(objectName, "RouteId").toString();
+            String name = objectName.getKeyProperty("name");
+            name = ObjectName.unquote(name);
+
+            ManagedProcessorMBean managedProcessor = context.getExtension(ManagedCamelContext.class).getManagedProcessor(name);
+
+            if (managedProcessor != null) {
+                if (processorsForRoute.get(routeId) == null) {
+                    List<ManagedProcessorMBean> processorsList = new ArrayList<>();
+                    processorsList.add(managedProcessor);
+
+                    processorsForRoute.put(routeId, processorsList);
+                } else {
+                    processorsForRoute.get(routeId).add(managedProcessor);
+                }
+            }
+        }
+
+        // sort processors by position in route definition
+        for (Map.Entry<String, List<ManagedProcessorMBean>> entry : processorsForRoute.entrySet()) {
+            Collections.sort(entry.getValue(), Comparator.comparing(ManagedProcessorMBean::getIndex));
+        }
+
+        return processorsForRoute;
+    }
+
+    /**
+     * Gathers test details as xml.
+     */
+    private String gatherTestDetailsAsXml(String testClass, String testName, long timeTaken) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("<test>\n");
+        sb.append("  <class>").append(testClass).append("</class>\n");
+        sb.append("  <method>").append(testName).append("</method>\n");
+        sb.append("  <time>").append(timeTaken).append("</time>\n");
+        sb.append("</test>\n");
+        return sb.toString();
+    }
+
+    /**
+     * Logs route coverage summary, including which routes are uncovered and
+     * what is the coverage of each processor in each route.
+     */
+    private void logCoverageSummary(ManagedCamelContextMBean managedCamelContext, ModelCamelContext context) throws Exception {
+        StringBuilder builder = new StringBuilder("\nCoverage summary\n");
+
+        int routes = managedCamelContext.getTotalRoutes();
+
+        long contextExchangesTotal = managedCamelContext.getExchangesTotal();
+
+        List<String> uncoveredRoutes = new ArrayList<>();
+
+        StringBuilder routesSummary = new StringBuilder();
+        routesSummary.append("\tProcessor coverage\n");
+
+        MBeanServer server = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Map<String, List<ManagedProcessorMBean>> processorsForRoute = findProcessorsForEachRoute(server, context);
+
+        // log processor coverage for each route
+        for (Route route : context.getRoutes()) {
+            ManagedRouteMBean managedRoute = context.getExtension(ManagedCamelContext.class).getManagedRoute(route.getId());
+            if (managedRoute.getExchangesTotal() == 0) {
+                uncoveredRoutes.add(route.getId());
+            }
+
+            long routeCoveragePercentage = Math.round((double)managedRoute.getExchangesTotal() / contextExchangesTotal * 100);
+            routesSummary.append("\t\tRoute ").append(route.getId()).append(" total: ").append(managedRoute.getExchangesTotal()).append(" (").append(routeCoveragePercentage)
+                .append("%)\n");
+
+            if (server != null) {
+                List<ManagedProcessorMBean> processors = processorsForRoute.get(route.getId());
+                if (processors != null) {
+                    for (ManagedProcessorMBean managedProcessor : processors) {
+                        String processorId = managedProcessor.getProcessorId();
+                        long processorExchangesTotal = managedProcessor.getExchangesTotal();
+                        long processorCoveragePercentage = Math.round((double)processorExchangesTotal / contextExchangesTotal * 100);
+                        routesSummary.append("\t\t\tProcessor ").append(processorId).append(" total: ").append(processorExchangesTotal).append(" (")
+                            .append(processorCoveragePercentage).append("%)\n");
+                    }
+                }
+            }
+        }
+
+        int used = routes - uncoveredRoutes.size();
+
+        long contextPercentage = Math.round((double)used / routes * 100);
+        builder.append("\tRoute coverage: ").append(used).append(" out of ").append(routes).append(" routes used (").append(contextPercentage).append("%)\n");
+        builder.append("\t\tCamelContext (").append(managedCamelContext.getCamelId()).append(") total: ").append(contextExchangesTotal).append("\n");
+
+        if (uncoveredRoutes.size() > 0) {
+            builder.append("\t\tUncovered routes: ").append(uncoveredRoutes.stream().collect(Collectors.joining(", "))).append("\n");
+        }
+
+        builder.append(routesSummary);
+        LOG.info(builder.toString());
+    }
+
+}
diff --git a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index c7f24d8..1818a98 100644
--- a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -16,31 +16,12 @@
  */
 package org.apache.camel.test.junit5;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ConsumerTemplate;
@@ -55,7 +36,6 @@ import org.apache.camel.NoSuchEndpointException;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.Route;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.Service;
@@ -63,8 +43,6 @@ import org.apache.camel.ServiceStatus;
 import org.apache.camel.api.management.JmxSystemPropertyKeys;
 import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedCamelContextMBean;
-import org.apache.camel.api.management.mbean.ManagedProcessorMBean;
-import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.camel.builder.AdviceWithRouteBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -81,7 +59,7 @@ import org.apache.camel.spi.CamelBeanPostProcessor;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.support.EndpointHelper;
-import org.apache.camel.util.IOHelper;
+import org.apache.camel.test.CamelRouteCoverageDumper;
 import org.apache.camel.util.StopWatch;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.TimeUtils;
@@ -134,6 +112,7 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     private static final ThreadLocal<AtomicInteger> TESTS = new ThreadLocal<>();
     private static final ThreadLocal<CamelTestSupport> INSTANCE = new ThreadLocal<>();
     private String currentTestName;
+    private CamelRouteCoverageDumper routeCoverageDumper = new CamelRouteCoverageDumper();
     // CHECKSTYLE:ON
 
     @Override
@@ -554,21 +533,7 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
                 LOG.warn("Cannot dump route coverage to file as JMX is not enabled. "
                          + "Add camel-management-impl JAR as dependency and/or override useJmx() method to enable JMX in the unit test classes.");
             } else {
-                logCoverageSummary(managedCamelContext);
-
-                String xml = managedCamelContext.dumpRoutesCoverageAsXml();
-                String combined = "<camelRouteCoverage>\n" + gatherTestDetailsAsXml() + xml + "\n</camelRouteCoverage>";
-
-                File file = new File(dir);
-                // ensure dir exists
-                file.mkdirs();
-                file = new File(dir, name);
-
-                LOG.info("Dumping route coverage to file: {}", file);
-                InputStream is = new ByteArrayInputStream(combined.getBytes());
-                OutputStream os = new FileOutputStream(file, false);
-                IOHelper.copyAndCloseInput(is, os);
-                IOHelper.close(os);
+                routeCoverageDumper.dump(managedCamelContext, context, dir, name, getClass().getName(), currentTestName, timeTaken());
             }
         }
         LOG.info("********************************************************************************");
@@ -618,117 +583,6 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     /**
-     * Logs route coverage summary: - which routes are uncovered - what is the
-     * coverage of each processor in each route
-     */
-    private void logCoverageSummary(ManagedCamelContextMBean managedCamelContext) throws Exception {
-        StringBuilder builder = new StringBuilder("\nCoverage summary\n");
-
-        int routes = managedCamelContext.getTotalRoutes();
-
-        long contextExchangesTotal = managedCamelContext.getExchangesTotal();
-
-        List<String> uncoveredRoutes = new ArrayList<>();
-
-        StringBuilder routesSummary = new StringBuilder();
-        routesSummary.append("\tProcessor coverage\n");
-
-        MBeanServer server = context.getManagementStrategy().getManagementAgent().getMBeanServer();
-
-        Map<String, List<ManagedProcessorMBean>> processorsForRoute = findProcessorsForEachRoute(server);
-
-        // log processor coverage for each route
-        for (Route route : context.getRoutes()) {
-            ManagedRouteMBean managedRoute = context.getExtension(ManagedCamelContext.class).getManagedRoute(route.getId());
-            if (managedRoute.getExchangesTotal() == 0) {
-                uncoveredRoutes.add(route.getId());
-            }
-
-            long routeCoveragePercentage = Math.round((double)managedRoute.getExchangesTotal() / contextExchangesTotal * 100);
-            routesSummary.append("\t\tRoute ").append(route.getId()).append(" total: ").append(managedRoute.getExchangesTotal()).append(" (").append(routeCoveragePercentage)
-                .append("%)\n");
-
-            if (server != null) {
-                List<ManagedProcessorMBean> processors = processorsForRoute.get(route.getId());
-                if (processors != null) {
-                    for (ManagedProcessorMBean managedProcessor : processors) {
-                        String processorId = managedProcessor.getProcessorId();
-                        long processorExchangesTotal = managedProcessor.getExchangesTotal();
-                        long processorCoveragePercentage = Math.round((double)processorExchangesTotal / contextExchangesTotal * 100);
-                        routesSummary.append("\t\t\tProcessor ").append(processorId).append(" total: ").append(processorExchangesTotal).append(" (")
-                            .append(processorCoveragePercentage).append("%)\n");
-                    }
-                }
-            }
-        }
-
-        int used = routes - uncoveredRoutes.size();
-
-        long contextPercentage = Math.round((double)used / routes * 100);
-        builder.append("\tRoute coverage: ").append(used).append(" out of ").append(routes).append(" routes used (").append(contextPercentage).append("%)\n");
-        builder.append("\t\tCamelContext (").append(managedCamelContext.getCamelId()).append(") total: ").append(contextExchangesTotal).append("\n");
-
-        if (uncoveredRoutes.size() > 0) {
-            builder.append("\t\tUncovered routes: ").append(uncoveredRoutes.stream().collect(Collectors.joining(", "))).append("\n");
-        }
-
-        builder.append(routesSummary);
-        LOG.info(builder.toString());
-    }
-
-    /**
-     * Groups all processors from Camel context by route id
-     */
-    private Map<String, List<ManagedProcessorMBean>> findProcessorsForEachRoute(MBeanServer server)
-        throws MalformedObjectNameException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
-        String domain = context.getManagementStrategy().getManagementAgent().getMBeanServerDefaultDomain();
-
-        Map<String, List<ManagedProcessorMBean>> processorsForRoute = new HashMap<>();
-
-        ObjectName processorsObjectName = new ObjectName(domain + ":context=" + context.getManagementName() + ",type=processors,name=*");
-        Set<ObjectName> objectNames = server.queryNames(processorsObjectName, null);
-
-        for (ObjectName objectName : objectNames) {
-            String routeId = server.getAttribute(objectName, "RouteId").toString();
-            String name = objectName.getKeyProperty("name");
-            name = ObjectName.unquote(name);
-
-            ManagedProcessorMBean managedProcessor = context.getExtension(ManagedCamelContext.class).getManagedProcessor(name);
-
-            if (managedProcessor != null) {
-                if (processorsForRoute.get(routeId) == null) {
-                    List<ManagedProcessorMBean> processorsList = new ArrayList<>();
-                    processorsList.add(managedProcessor);
-
-                    processorsForRoute.put(routeId, processorsList);
-                } else {
-                    processorsForRoute.get(routeId).add(managedProcessor);
-                }
-            }
-        }
-
-        // sort processors by position in route definition
-        for (Map.Entry<String, List<ManagedProcessorMBean>> entry : processorsForRoute.entrySet()) {
-            Collections.sort(entry.getValue(), Comparator.comparing(ManagedProcessorMBean::getIndex));
-        }
-
-        return processorsForRoute;
-    }
-
-    /**
-     * Gathers test details as xml
-     */
-    private String gatherTestDetailsAsXml() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("<test>\n");
-        sb.append("  <class>").append(getClass().getName()).append("</class>\n");
-        sb.append("  <method>").append(currentTestName).append("</method>\n");
-        sb.append("  <time>").append(timeTaken()).append("</time>\n");
-        sb.append("</test>\n");
-        return sb.toString();
-    }
-
-    /**
      * Returns the timeout to use when shutting down (unit in seconds).
      * <p/>
      * Will default use 10 seconds.
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
index b97959c..e5a99e0 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
@@ -19,11 +19,14 @@ package org.apache.camel.test.junit5.patterns;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestReporter;
 
 import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {
 
@@ -38,12 +41,19 @@ public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {
         assertEquals("Bye World", out);
     }
 
-    @Override
-    @AfterEach
-    public void tearDown() throws Exception {
-        super.tearDown();
+    @Test
+    public void testProcessorJunit5WithTestParameterInjection(TestInfo info, TestReporter testReporter) throws Exception {
+        assertNotNull(info);
+        assertNotNull(testReporter);
+        String out = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("Bye World", out);
+    }
+
+    @AfterAll
+    public static void checkDumpFilesCreatedAfterTests() {
         // should create that file when test is done
         assertFileExists("target/camel-route-coverage/RouteProcessorDumpRouteCoverageTest-testProcessorJunit5.xml");
+        assertFileExists("target/camel-route-coverage/RouteProcessorDumpRouteCoverageTest-testProcessorJunit5WithTestParameterInjection.xml");
     }
 
     @Override


[camel] 05/09: CAMEL-13826: Migrated camel-ahc-ws tests to camel-test-junit5

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 03152247edf0856409240cecbb53bc6dcf95b1b6
Author: aldettinger <al...@gmail.com>
AuthorDate: Tue Aug 13 19:35:58 2019 +0200

    CAMEL-13826: Migrated camel-ahc-ws tests to camel-test-junit5
---
 components/camel-ahc-ws/pom.xml                    |  7 +-----
 .../component/ahc/ws/WsProducerConsumerTest.java   | 28 ++++++++++++++--------
 .../camel/component/ahc/ws/WsProducerTestBase.java | 26 +++++++++++---------
 .../camel/component/ahc/ws/WssProducerTest.java    |  4 ++--
 .../src/main/docs/test-junit5.adoc                 |  1 +
 5 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/components/camel-ahc-ws/pom.xml b/components/camel-ahc-ws/pom.xml
index f38b7e8..a680c8c 100644
--- a/components/camel-ahc-ws/pom.xml
+++ b/components/camel-ahc-ws/pom.xml
@@ -62,12 +62,7 @@
         <!-- testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerConsumerTest.java b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerConsumerTest.java
index 3f4f539..e556130 100644
--- a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerConsumerTest.java
+++ b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerConsumerTest.java
@@ -20,21 +20,29 @@ import java.util.List;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+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 static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  *
  */
 public class WsProducerConsumerTest extends CamelTestSupport {
+    
     protected static final String TEST_MESSAGE = "Hello World!";
     protected static final int PORT = AvailablePortFinder.getNextAvailable();
+    
+    private static final Logger LOG = LoggerFactory.getLogger(WsProducerConsumerTest.class);
+    
     protected Server server;
    
     protected List<Object> messages;
@@ -52,23 +60,23 @@ public class WsProducerConsumerTest extends CamelTestSupport {
         server.setHandler(ctx);
         
         server.start();
-        assertTrue(server.isStarted());      
+        assertTrue(server.isStarted());
     }
-    
+
     public void stopTestServer() throws Exception {
         server.stop();
         server.destroy();
     }
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         startTestServer();
         super.setUp();
     }
 
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
         stopTestServer();
@@ -95,7 +103,7 @@ public class WsProducerConsumerTest extends CamelTestSupport {
 
         resetMocks();
 
-        log.info("Restarting bar route");
+        LOG.info("Restarting bar route");
         context.getRouteController().stopRoute("bar");
         Thread.sleep(500);
         context.getRouteController().startRoute("bar");
@@ -118,7 +126,7 @@ public class WsProducerConsumerTest extends CamelTestSupport {
 
         resetMocks();
 
-        log.info("Restarting foo route");
+        LOG.info("Restarting foo route");
         context.getRouteController().stopRoute("foo");
         Thread.sleep(500);
         context.getRouteController().startRoute("foo");
diff --git a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerTestBase.java b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerTestBase.java
index e8f3c26..7f6186a 100644
--- a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerTestBase.java
+++ b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WsProducerTestBase.java
@@ -31,16 +31,20 @@ import org.apache.camel.test.AvailablePortFinder;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  *
  */
-public abstract class WsProducerTestBase extends Assert {
+public abstract class WsProducerTestBase {
     
     protected static final String TEST_MESSAGE = "Hello World!";
     protected static final int PORT = AvailablePortFinder.getNextAvailable();
@@ -54,7 +58,7 @@ public abstract class WsProducerTestBase extends Assert {
         server = new Server(PORT);
         Connector connector = getConnector();
         server.addConnector(connector);
-        
+
         ServletContextHandler ctx = new ServletContextHandler();
         ctx.setContextPath("/");
         ctx.addServlet(TestServletFactory.class.getName(), "/*");
@@ -70,7 +74,7 @@ public abstract class WsProducerTestBase extends Assert {
         server.destroy();
     }
     
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         TestMessages.getInstance().getMessages().clear();
 
@@ -83,7 +87,7 @@ public abstract class WsProducerTestBase extends Assert {
         template = camelContext.createProducerTemplate();
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         template.stop();
         camelContext.stop();
@@ -113,7 +117,7 @@ public abstract class WsProducerTestBase extends Assert {
         verifyMessage(testMessage, TestMessages.getInstance().getMessages().get(0));
     }
 
-    @Ignore
+    @Disabled
     @Test
     public void testWriteBytesToWebsocket() throws Exception {
         byte[] testMessageBytes = getByteTestMessage();
@@ -122,7 +126,7 @@ public abstract class WsProducerTestBase extends Assert {
         verifyMessage(testMessageBytes, TestMessages.getInstance().getMessages().get(0));
     }
 
-    @Ignore
+    @Disabled
     @Test
     public void testWriteStreamToWebsocket() throws Exception {
         byte[] testMessageBytes = createLongByteTestMessage();
diff --git a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WssProducerTest.java b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WssProducerTest.java
index 2d41f01..11c2511 100644
--- a/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WssProducerTest.java
+++ b/components/camel-ahc-ws/src/test/java/org/apache/camel/component/ahc/ws/WssProducerTest.java
@@ -26,9 +26,9 @@ import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
-import org.junit.Ignore;
+import org.junit.jupiter.api.Disabled;
 
-@Ignore("Not yet migrated to work with Jetty 9")
+@Disabled("Not yet migrated to work with Jetty 9")
 public class WssProducerTest extends WsProducerTestBase {
     protected static final String PW = "changeit";
     
diff --git a/components/camel-test-junit5/src/main/docs/test-junit5.adoc b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
index d9a4d5c..eb74435 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -60,6 +60,7 @@ Projects using `camel-test` would need to use `camel-test-junit5`. For instance,
 === Typical migration steps linked to JUnit 5 support in Camel Test
 * Imports of `org.apache.camel.test.junit4.\*` should be replaced with `org.apache.camel.test.junit5.*`
 * `TestSupport` static methods should be imported where needed, for instance `import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf`
+* Usage of the field `CamelTestSupport.log` should be replaced by another logger, for instance `org.slf4j.LoggerFactory.getLogger(MyCamelTest.class);`
 
 === Typical migration steps linked to JUnit 5 itself
 Once Camel related steps have been performed, there are still typical JUnit 5 migration steps to remember:


[camel] 07/09: CAMEL-13826: Migrated camel-jmx tests to camel-test-junit5

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ebf74e58ecbb1c2be466a5fdc14ebf54fc7fbd39
Author: aldettinger <al...@gmail.com>
AuthorDate: Wed Aug 14 16:06:20 2019 +0200

    CAMEL-13826: Migrated camel-jmx tests to camel-test-junit5
---
 components/camel-jmx/pom.xml                        |  7 +------
 ...nsumerObserveAttributeMatchStringDifferTest.java |  4 ++--
 ...lJmxConsumerObserveAttributeMatchStringTest.java |  4 ++--
 .../jmx/CamelJmxConsumerObserveAttributeTest.java   |  4 ++--
 .../camel/component/jmx/CamelJmxConsumerTest.java   |  4 ++--
 .../camel/component/jmx/JMXComponentTest.java       | 12 ++++++------
 .../apache/camel/component/jmx/JMXConsumerTest.java | 10 +++++-----
 .../apache/camel/component/jmx/JMXEndpointTest.java | 18 +++++++++---------
 .../apache/camel/component/jmx/JMXHandbackTest.java |  9 ++++-----
 .../component/jmx/JMXMonitorTypeCounterTest.java    |  2 +-
 .../component/jmx/JMXMonitorTypeGaugeTest.java      |  2 +-
 .../jmx/JMXMonitorTypeLongCounterTest.java          |  2 +-
 .../jmx/JMXMonitorTypeStringDiffersTest.java        |  2 +-
 .../jmx/JMXMonitorTypeStringMatchesTest.java        |  2 +-
 .../component/jmx/JMXNotificationFilterTest.java    |  8 ++++----
 .../component/jmx/JMXObjectPropertiesTest.java      |  2 +-
 .../apache/camel/component/jmx/JMXRemoteTest.java   |  6 +++---
 .../jmx/JMXRobustRemoteConnectionTest.java          | 21 ++++++++++-----------
 .../camel/component/jmx/JMXUriBuilderTest.java      |  4 ++--
 .../camel/component/jmx/MockEndpointFixture.java    |  6 +++---
 .../camel/component/jmx/SimpleBeanFixture.java      |  8 ++++----
 .../org/apache/camel/component/jmx/XmlFixture.java  |  4 ++--
 22 files changed, 67 insertions(+), 74 deletions(-)

diff --git a/components/camel-jmx/pom.xml b/components/camel-jmx/pom.xml
index 013d1ae..11d1130 100644
--- a/components/camel-jmx/pom.xml
+++ b/components/camel-jmx/pom.xml
@@ -44,12 +44,7 @@
         <!-- test dependencies -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
index fc81b2a..9baa615 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.camel.builder.RouteBuilder;
-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 CamelJmxConsumerObserveAttributeMatchStringDifferTest extends CamelTestSupport {
 
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
index d1e8f8e..562ef84 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.camel.builder.RouteBuilder;
-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 CamelJmxConsumerObserveAttributeMatchStringTest extends CamelTestSupport {
 
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
index 9d2749e..ccabaa1 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.camel.builder.RouteBuilder;
-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 CamelJmxConsumerObserveAttributeTest extends CamelTestSupport {
 
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
index f106df8..a399d21 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.camel.builder.RouteBuilder;
-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 CamelJmxConsumerTest extends CamelTestSupport {
 
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
index 05c6f7e..cb7b291 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
@@ -20,13 +20,13 @@ import java.util.Map;
 
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Test behavior in the component for initializing an endpoint. Not much here beyond
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
index 6fd9ffe..f10b0fb 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
@@ -19,9 +19,9 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests that trigger notification events on our simple bean without
@@ -32,7 +32,7 @@ public class JMXConsumerTest extends SimpleBeanFixture {
     ISimpleMXBean simpleBean;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         super.setUp();
         simpleBean = getSimpleMXBean();
@@ -78,7 +78,7 @@ public class JMXConsumerTest extends SimpleBeanFixture {
         waitAndAssertMessageReceived("src/test/resources/consumer-test/mbeanServerNotification.xml");
     }
 
-    @Ignore
+    @Disabled
     public void relationNotification() throws Exception {
         simpleBean.triggerRelationNotification();
         waitAndAssertMessageReceived("src/test/resources/consumer-test/relationNotification.xml");
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
index 8e108b7..b358838 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
@@ -21,15 +21,15 @@ import java.util.Hashtable;
 import javax.management.ObjectName;
 
 import org.apache.camel.impl.DefaultCamelContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Tests for the endpoint. Most of the params in the endpoint are
@@ -40,7 +40,7 @@ public class JMXEndpointTest {
 
     DefaultCamelContext context;
     
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         context = new DefaultCamelContext();
     }
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXHandbackTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXHandbackTest.java
index 455fb64..0166f9e 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXHandbackTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXHandbackTest.java
@@ -20,11 +20,10 @@ import java.net.URI;
 
 import org.apache.camel.Message;
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertSame;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 /**
  * Tests that we get the handback object in the message header
@@ -34,7 +33,7 @@ public class JMXHandbackTest extends SimpleBeanFixture {
     URI hb;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         hb = new URI("urn:some:handback:object");
         super.setUp();
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeCounterTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeCounterTest.java
index a8c43e8..0452049 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeCounterTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeCounterTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class JMXMonitorTypeCounterTest extends SimpleBeanFixture {
     
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeGaugeTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeGaugeTest.java
index ccba9d5..916c7ec 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeGaugeTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeGaugeTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class JMXMonitorTypeGaugeTest extends SimpleBeanFixture {
     
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeLongCounterTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeLongCounterTest.java
index e59ef47..b8b2d7f 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeLongCounterTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeLongCounterTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class JMXMonitorTypeLongCounterTest extends SimpleBeanFixture {
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringDiffersTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringDiffersTest.java
index 0a30f35..b56ac46 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringDiffersTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringDiffersTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class JMXMonitorTypeStringDiffersTest extends SimpleBeanFixture {
     
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringMatchesTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringMatchesTest.java
index 5338486..721b2b4 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringMatchesTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXMonitorTypeStringMatchesTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jmx;
 import java.io.File;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class JMXMonitorTypeStringMatchesTest extends SimpleBeanFixture {
     
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXNotificationFilterTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXNotificationFilterTest.java
index aa1c8ac..5d90034 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXNotificationFilterTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXNotificationFilterTest.java
@@ -22,9 +22,9 @@ import javax.management.NotificationFilter;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
  * Tests that the NotificationFilter is applied if configured
@@ -40,7 +40,7 @@ public class JMXNotificationFilterTest extends SimpleBeanFixture {
     public void testNotificationFilter() throws Exception {
         ISimpleMXBean bean = getSimpleMXBean();
 
-        assertEquals("no notifications should have been filtered at this point", 0, mRejected.size());
+        assertEquals(0, mRejected.size(), "no notifications should have been filtered at this point");
 
         // we should only get 5 messages, which is 1/2 the number of times we touched the object.
         // The 1/2 is due to the behavior of the test NotificationFilter implemented below 
@@ -50,7 +50,7 @@ public class JMXNotificationFilterTest extends SimpleBeanFixture {
         }
 
         getMockFixture().waitForMessages();
-        assertEquals("5 notifications should have been filtered", 5, mRejected.size());
+        assertEquals(5, mRejected.size(), "5 notifications should have been filtered");
 
         // assert that all of the rejected ones are odd and accepted ones even
         for (Notification rejected : mRejected) {
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java
index 0c767c2..7fbc1e5 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java
@@ -20,7 +20,7 @@ import java.util.Hashtable;
 import java.util.Map;
 
 import org.apache.camel.component.jmx.beans.ISimpleMXBean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests that the objectName is created with the hashtable of objectProperties
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRemoteTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRemoteTest.java
index 3999b2b..406e0f2 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRemoteTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRemoteTest.java
@@ -27,8 +27,8 @@ import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
 import org.apache.camel.test.AvailablePortFinder;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests against a "remote" JMX server. Creates an RMI Registry on or near port 39000
@@ -45,7 +45,7 @@ public class JMXRemoteTest extends SimpleBeanFixture {
     Registry registry;
 
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
         connector.stop();
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
index 2680cff..cbd8038 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXRobustRemoteConnectionTest.java
@@ -28,13 +28,12 @@ import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
 import org.apache.camel.test.AvailablePortFinder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Test to verify:
@@ -52,7 +51,7 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
     Registry registry;
     int port;
     
-    @Before
+    @BeforeEach
     @Override
     public void setUp() throws Exception {
         port = AvailablePortFinder.getNextAvailable();
@@ -63,7 +62,7 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
     }
     
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
         connector.stop();
@@ -106,7 +105,7 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
         getSimpleMXBean().touch();
         getMockFixture().waitForMessages();
         getMockFixture().assertMessageReceived(new File("src/test/resources/consumer-test/touched.xml"));
-                
+
         // stop the server; the JMX consumer should lose connectivity and the mock will not receive notifications
         connector.stop();
         Thread.sleep(2000);
@@ -114,11 +113,11 @@ public class JMXRobustRemoteConnectionTest extends SimpleBeanFixture {
         getMockFixture().getMockEndpoint().setExpectedMessageCount(1);
         getSimpleMXBean().touch();
         getMockFixture().getMockEndpoint().assertIsNotSatisfied();
-        
+
         // restart the server;  the JMX consumer should re-connect and the mock should receive a notification
         initServer();
         initBean();
-        Thread.sleep(2000);        
+        Thread.sleep(2000);
         getSimpleMXBean().touch();
         getMockFixture().waitForMessages();
         getMockFixture().assertMessageReceived(new File("src/test/resources/consumer-test/touched.xml"));
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
index 7a059be..494635a 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
@@ -18,9 +18,9 @@ package org.apache.camel.component.jmx;
 
 import java.util.LinkedHashMap;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
  * Various tests for the uri builder
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/MockEndpointFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/MockEndpointFixture.java
index ee52094..91db651 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/MockEndpointFixture.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/MockEndpointFixture.java
@@ -28,8 +28,8 @@ import org.apache.camel.Message;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.xmlunit.xpath.JAXPXPathEngine;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 /**
  * Waits for messages to arrive on the mock endpoint and performs assertions on the message bodies.
@@ -47,7 +47,7 @@ public class MockEndpointFixture {
 
     protected void waitForMessages(MockEndpoint aMockEndpoint) throws InterruptedException {
         mMockEndpoint.await(10, TimeUnit.SECONDS);
-        assertEquals("Expected number of messages didn't arrive before timeout", aMockEndpoint.getExpectedCount(), aMockEndpoint.getReceivedCounter());
+        assertEquals(aMockEndpoint.getExpectedCount(), aMockEndpoint.getReceivedCounter(), "Expected number of messages didn't arrive before timeout");
     }
     
     protected MockEndpoint getMockEndpoint() {
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
index 73bb93f..c8809e1 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
@@ -34,8 +34,8 @@ import org.apache.camel.component.jmx.beans.SimpleBean;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.support.SimpleRegistry;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 
 /**
  * MBean that is registered for the unit tests. The fixture will register a bean
@@ -69,7 +69,7 @@ public class SimpleBeanFixture {
     private MockEndpointFixture mMockEndpoint;
 
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         initServer();
         initBean();
@@ -82,7 +82,7 @@ public class SimpleBeanFixture {
         mContext.start();
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         if (!mContext.isStopped()) {
             mContext.stop();
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
index 87b5c92..c64fc4f 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
@@ -30,7 +30,7 @@ import org.xmlunit.builder.DiffBuilder;
 import org.xmlunit.builder.Input;
 import org.xmlunit.diff.Diff;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 public final class XmlFixture {
 
@@ -50,7 +50,7 @@ public final class XmlFixture {
                 .ignoreComments().ignoreWhitespace()
                 .checkForSimilar().build();
         try {
-            assertFalse(aMessage + ":\n" + diff.toString(), diff.hasDifferences());
+            assertFalse(diff.hasDifferences(), aMessage + ":\n" + diff.toString());
         } catch (Throwable t) {
             dump(aActual);
             throw t;


[camel] 02/09: CAMEL-13826: Removed deprecated methods and class

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 22ea2e5ea840ba54548669f7b847cb80e1678ed4
Author: aldettinger <al...@gmail.com>
AuthorDate: Mon Aug 12 14:50:52 2019 +0200

    CAMEL-13826: Removed deprecated methods and class
---
 .../apache/camel/test/junit5/CamelTestSupport.java | 85 +---------------------
 .../patterns/DebugNoLazyTypeConverterTest.java     |  5 --
 .../src/test/resources/jndi.properties             | 22 ------
 3 files changed, 1 insertion(+), 111 deletions(-)

diff --git a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index d324389..c7f24d8 100644
--- a/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -42,8 +41,6 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ConsumerTemplate;
@@ -73,7 +70,6 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.impl.engine.InterceptSendToMockEndpointStrategy;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ModelCamelContext;
@@ -753,17 +749,6 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     /**
-     * Whether or not type converters should be lazy loaded (notice core
-     * converters is always loaded)
-     *
-     * @return <tt>false</tt> by default.
-     */
-    @Deprecated
-    protected boolean isLazyLoadingTypeConverter() {
-        return false;
-    }
-
-    /**
      * Override this method to include and override properties with the Camel
      * {@link PropertiesComponent}.
      *
@@ -884,22 +869,7 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     protected CamelContext createCamelContext() throws Exception {
-        // for backwards compatibility
-        Registry registry = createRegistry();
-        if (registry instanceof FakeJndiRegistry) {
-            boolean inUse = ((FakeJndiRegistry)registry).isInUse();
-            if (!inUse) {
-                registry = null;
-            }
-        }
-        if (registry != null) {
-            String msg = "createRegistry() from camel-test is deprecated. Use createCamelRegistry if you want to control which registry to use, however"
-                         + " if you need to bind beans to the registry then this is possible already with the bind method on registry,"
-                         + " and there is no need to override this method.";
-            LOG.warn(msg);
-        } else {
-            registry = createCamelRegistry();
-        }
+        Registry registry = createCamelRegistry();
 
         CamelContext context;
         if (registry != null) {
@@ -929,59 +899,6 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     /**
-     * @deprecated use createCamelRegistry if you want to control which registry
-     *             to use, however if you need to bind beans to the registry
-     *             then this is possible already with the bind method on
-     *             registry, and there is no need to override this method.
-     */
-    @Deprecated
-    protected JndiRegistry createRegistry() throws Exception {
-        return new FakeJndiRegistry(createJndiContext());
-    }
-
-    /**
-     * @deprecated use createCamelRegistry if you want to control which registry
-     *             to use, however if you need to bind beans to the registry
-     *             then this is possible already with the bind method on
-     *             registry, and there is no need to use JndiRegistry and
-     *             override this method.
-     */
-    @Deprecated
-    protected Context createJndiContext() throws Exception {
-        Properties properties = new Properties();
-
-        // jndi.properties is optional
-        InputStream in = getClass().getClassLoader().getResourceAsStream("jndi.properties");
-        if (in != null) {
-            LOG.debug("Using jndi.properties from classpath root");
-            properties.load(in);
-        } else {
-            properties.put("java.naming.factory.initial", "org.apache.camel.support.jndi.CamelInitialContextFactory");
-        }
-        return new InitialContext(new Hashtable<>(properties));
-    }
-
-    private class FakeJndiRegistry extends JndiRegistry {
-
-        private boolean inUse;
-
-        public FakeJndiRegistry(Context context) {
-            super(context);
-        }
-
-        @Override
-        public void bind(String name, Object object) {
-            super.bind(name, object);
-            inUse = true;
-        }
-
-        public boolean isInUse() {
-            // only if the end user bind beans then its in use
-            return inUse;
-        }
-    }
-
-    /**
      * Factory method which derived classes can use to create a
      * {@link RouteBuilder} to define the routes for testing
      */
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
index a9cb78f..056efae 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
@@ -29,11 +29,6 @@ public class DebugNoLazyTypeConverterTest extends CamelTestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(DebugNoLazyTypeConverterTest.class);
 
-    @Override
-    protected boolean isLazyLoadingTypeConverter() {
-        return false;
-    }
-
     // START SNIPPET: e1
     @Override
     public boolean isUseDebugger() {
diff --git a/components/camel-test-junit5/src/test/resources/jndi.properties b/components/camel-test-junit5/src/test/resources/jndi.properties
deleted file mode 100644
index 7f9b32b..0000000
--- a/components/camel-test-junit5/src/test/resources/jndi.properties
+++ /dev/null
@@ -1,22 +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.
-## ---------------------------------------------------------------------------
-
-# START SNIPPET: jndi
-
-java.naming.factory.initial = org.apache.camel.support.jndi.CamelInitialContextFactory
-
-# END SNIPPET: jndi


[camel] 06/09: CAMEL-13826: Removed unneeded throws Exception for tests in camel-test-junit5

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4115a6d9c6eb67dfebaed75bad6dd164b5b4d4a7
Author: aldettinger <al...@gmail.com>
AuthorDate: Wed Aug 14 14:52:07 2019 +0200

    CAMEL-13826: Removed unneeded throws Exception for tests in camel-test-junit5
---
 .../src/main/docs/test-junit5.adoc                 |  4 +--
 .../apache/camel/test/AvailablePortFinderTest.java | 36 +++++++++++-----------
 .../camel/test/junit5/CamelTestSupportTest.java    |  4 +--
 .../test/junit5/RouteFilterPatternExcludeTest.java |  4 +--
 .../RouteFilterPatternIncludeExcludeTest.java      |  4 +--
 .../test/junit5/RouteFilterPatternIncludeTest.java |  4 +--
 .../test/junit5/patterns/AdviceWithLambdaTest.java |  4 +--
 .../junit5/patterns/AdviceWithNotStartedTest.java  |  6 ++--
 .../CreateCamelContextPerTestFalseTest.java        |  2 +-
 .../CreateCamelContextPerTestTrueTest.java         |  2 +-
 .../test/junit5/patterns/DebugJUnit5Test.java      |  4 +--
 .../patterns/DebugNoLazyTypeConverterTest.java     |  4 +--
 .../camel/test/junit5/patterns/DebugTest.java      |  4 +--
 .../test/junit5/patterns/GetMockEndpointTest.java  |  4 +--
 .../patterns/IsMockEndpointsAndSkipJUnit5Test.java |  4 +--
 .../junit5/patterns/IsMockEndpointsFileTest.java   |  4 +--
 .../junit5/patterns/IsMockEndpointsJUnit5Test.java |  4 +--
 .../test/junit5/patterns/IsMockEndpointsTest.java  |  4 +--
 .../test/junit5/patterns/ProduceBeanTest.java      |  4 +--
 .../RouteBuilderConfigureExceptionTest.java        |  4 +--
 .../RouteProcessorDumpRouteCoverageTest.java       |  8 ++---
 .../junit5/patterns/SimpleMockEndpointsTest.java   |  4 +--
 .../camel/test/junit5/patterns/SimpleMockTest.java |  4 +--
 .../junit5/patterns/SimpleNotifyBuilderTest.java   |  6 ++--
 .../patterns/SimpleWeaveAddMockLastTest.java       |  6 ++--
 25 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/components/camel-test-junit5/src/main/docs/test-junit5.adoc b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
index eb74435..63330ac 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -32,10 +32,10 @@ public class SimpleMockTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("mock:result");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
index 2356bfd..3b96852 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
@@ -1,19 +1,19 @@
 /*
- * 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.
- */
+ *  * 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.test;
 
 import java.net.DatagramSocket;
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 public class AvailablePortFinderTest {
 
     @Test
-    public void testNotAvailableTcpPort() throws Exception {
+    public void testNotAvailableTcpPort() {
         int p1 = AvailablePortFinder.getNextAvailable();
         ServerSocket socket = new ServerSocket(p1);
         int p2 = AvailablePortFinder.getNextAvailable();
@@ -40,7 +40,7 @@ public class AvailablePortFinderTest {
     }
 
     @Test
-    public void testNotAvailableUdpPort() throws Exception {
+    public void testNotAvailableUdpPort() {
         int p1 = AvailablePortFinder.getNextAvailable();
         DatagramSocket socket = new DatagramSocket(p1);
         int p2 = AvailablePortFinder.getNextAvailable();
@@ -49,7 +49,7 @@ public class AvailablePortFinderTest {
     }
 
     @Test
-    public void testNotAvailableMulticastPort() throws Exception {
+    public void testNotAvailableMulticastPort() {
         int p1 = AvailablePortFinder.getNextAvailable();
         MulticastSocket socket = new MulticastSocket(null);
         socket.setReuseAddress(false); // true is default for MulticastSocket, we wan to fail if port is occupied
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/CamelTestSupportTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/CamelTestSupportTest.java
index 025c01e..4c8453f 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/CamelTestSupportTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/CamelTestSupportTest.java
@@ -64,10 +64,10 @@ public class CamelTestSupportTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:something").id("routeId").to("mock:result");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternExcludeTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternExcludeTest.java
index a90649e..378c71a 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternExcludeTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternExcludeTest.java
@@ -42,10 +42,10 @@ public class RouteFilterPatternExcludeTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:foo").routeId("foo").to("mock:foo");
 
                 from("direct:bar").routeId("bar").to("mock:bar");
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeExcludeTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeExcludeTest.java
index a6ce59d..57e72f4 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeExcludeTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeExcludeTest.java
@@ -47,10 +47,10 @@ public class RouteFilterPatternIncludeExcludeTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:foo").routeId("foo").to("mock:foo");
 
                 from("direct:bar").routeId("bar").to("mock:bar");
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeTest.java
index 7148557..eb848c7 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/RouteFilterPatternIncludeTest.java
@@ -42,10 +42,10 @@ public class RouteFilterPatternIncludeTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:foo").routeId("foo").to("mock:foo");
 
                 from("direct:bar").routeId("bar").to("mock:bar");
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java
index 3ce739f..3ec84fc 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java
@@ -45,10 +45,10 @@ public class AdviceWithLambdaTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").routeId("foo").to("log:foo");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
index b097165..a20d400 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithNotStartedTest.java
@@ -40,7 +40,7 @@ public class AdviceWithNotStartedTest extends CamelTestSupport {
     public void testNotStarted() throws Exception {
         RouteReifier.adviceWith(context.getRouteDefinition("foo"), context, new AdviceWithRouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 weaveAddLast().to("mock:result");
             }
         });
@@ -63,10 +63,10 @@ public class AdviceWithNotStartedTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").routeId("foo").to("log:foo");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestFalseTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestFalseTest.java
index ed769d9..34c8591 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestFalseTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestFalseTest.java
@@ -103,7 +103,7 @@ public class CreateCamelContextPerTestFalseTest extends CamelTestSupport {
     }
 
     @AfterAll
-    public static void validateTearDown() throws Exception {
+    public static void validateTearDown() {
         assertEquals(3, CREATED_CONTEXTS.get());
         assertEquals(3, POST_TEAR_DOWN.get());
     }
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestTrueTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestTrueTest.java
index 41f5e79..a234455 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestTrueTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/CreateCamelContextPerTestTrueTest.java
@@ -112,7 +112,7 @@ public class CreateCamelContextPerTestTrueTest extends CamelTestSupport {
     }
 
     @AfterAll
-    public static void shouldTearDown() throws Exception {
+    public static void shouldTearDown() {
         // we are called before doPostTearDown so lets wait for that to be
         // called
         Runnable r = () -> {
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
index 183d1d7..8b68874 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugJUnit5Test.java
@@ -75,10 +75,10 @@ public class DebugJUnit5Test extends CamelTestSupport {
 
     // START SNIPPET: e2
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 // this is the route we want to debug
                 from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b");
             }
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
index 056efae..3a02afb 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugNoLazyTypeConverterTest.java
@@ -75,10 +75,10 @@ public class DebugNoLazyTypeConverterTest extends CamelTestSupport {
 
     // START SNIPPET: e2
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 // this is the route we want to debug
                 from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b");
             }
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
index 87ae779..3d1fe95 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/DebugTest.java
@@ -75,10 +75,10 @@ public class DebugTest extends CamelTestSupport {
 
     // START SNIPPET: e2
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 // this is the route we want to debug
                 from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b");
             }
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/GetMockEndpointTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/GetMockEndpointTest.java
index 8edec28..4709eff 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/GetMockEndpointTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/GetMockEndpointTest.java
@@ -33,10 +33,10 @@ public class GetMockEndpointTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("mock:result?failFast=false");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsAndSkipJUnit5Test.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsAndSkipJUnit5Test.java
index f2a487e..2e6b160 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsAndSkipJUnit5Test.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsAndSkipJUnit5Test.java
@@ -53,10 +53,10 @@ public class IsMockEndpointsAndSkipJUnit5Test extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("direct:foo").to("mock:result");
 
                 from("direct:foo").transform(constant("Bye World")).to("seda:foo");
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
index fe621af..ff3c250 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
@@ -59,10 +59,10 @@ public class IsMockEndpointsFileTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("file:target/input").choice().when(bodyAs(String.class).contains("Camel")).to("file:target/messages/camel").otherwise().to("file:target/messages/others");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsJUnit5Test.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsJUnit5Test.java
index 6b1fee9..c131d8c 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsJUnit5Test.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsJUnit5Test.java
@@ -59,10 +59,10 @@ public class IsMockEndpointsJUnit5Test extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("direct:foo").to("log:foo").to("mock:result");
 
                 from("direct:foo").transform(constant("Bye World"));
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsTest.java
index afc9b78..2bef92a 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsTest.java
@@ -52,10 +52,10 @@ public class IsMockEndpointsTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("direct:foo").to("log:foo").to("mock:result");
 
                 from("direct:foo").transform(constant("Bye World"));
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/ProduceBeanTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/ProduceBeanTest.java
index e72edb7..af2a99e 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/ProduceBeanTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/ProduceBeanTest.java
@@ -35,10 +35,10 @@ public class ProduceBeanTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").bean(MyProduceBean.class, "doSomething");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteBuilderConfigureExceptionTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteBuilderConfigureExceptionTest.java
index 46954b6..d1ab53b 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteBuilderConfigureExceptionTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteBuilderConfigureExceptionTest.java
@@ -30,7 +30,7 @@ public class RouteBuilderConfigureExceptionTest extends CamelTestSupport {
 
     @Override
     @BeforeEach
-    public void setUp() throws Exception {
+    public void setUp() {
         try {
             super.setUp();
             fail("Should have thrown exception");
@@ -40,7 +40,7 @@ public class RouteBuilderConfigureExceptionTest extends CamelTestSupport {
     }
 
     @Test
-    public void testFoo() throws Exception {
+    public void testFoo() {
     }
 
     @Override
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
index e5a99e0..702d39c 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/RouteProcessorDumpRouteCoverageTest.java
@@ -36,13 +36,13 @@ public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {
     }
 
     @Test
-    public void testProcessorJunit5() throws Exception {
+    public void testProcessorJunit5() {
         String out = template.requestBody("direct:start", "Hello World", String.class);
         assertEquals("Bye World", out);
     }
 
     @Test
-    public void testProcessorJunit5WithTestParameterInjection(TestInfo info, TestReporter testReporter) throws Exception {
+    public void testProcessorJunit5WithTestParameterInjection(TestInfo info, TestReporter testReporter) {
         assertNotNull(info);
         assertNotNull(testReporter);
         String out = template.requestBody("direct:start", "Hello World", String.class);
@@ -57,10 +57,10 @@ public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").process(exchange -> exchange.getMessage().setBody("Bye World"));
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockEndpointsTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockEndpointsTest.java
index 875bfad..40f2f3b 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockEndpointsTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockEndpointsTest.java
@@ -38,10 +38,10 @@ public class SimpleMockEndpointsTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("seda:start").transform(simple("Bye ${body}")).to("seda:queue");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockTest.java
index 43b0429..be5ed41 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleMockTest.java
@@ -33,10 +33,10 @@ public class SimpleMockTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("direct:start").to("mock:result");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleNotifyBuilderTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleNotifyBuilderTest.java
index f44a03d..3dbef5a 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleNotifyBuilderTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleNotifyBuilderTest.java
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 public class SimpleNotifyBuilderTest extends CamelTestSupport {
 
     @Test
-    public void testNotifyBuilder() throws Exception {
+    public void testNotifyBuilder() {
         NotifyBuilder notify = new NotifyBuilder(context).from("seda:start").wereSentTo("seda:queue").whenDone(10).create();
 
         for (int i = 0; i < 10; i++) {
@@ -41,10 +41,10 @@ public class SimpleNotifyBuilderTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("seda:start").transform(simple("Bye ${body}")).to("seda:queue");
             }
         };
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleWeaveAddMockLastTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleWeaveAddMockLastTest.java
index b988275..cf27ab4 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleWeaveAddMockLastTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/SimpleWeaveAddMockLastTest.java
@@ -33,7 +33,7 @@ public class SimpleWeaveAddMockLastTest extends CamelTestSupport {
     public void testWeaveAddMockLast() throws Exception {
         RouteReifier.adviceWith(context.getRouteDefinitions().get(0), context, new AdviceWithRouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 weaveAddLast().to("mock:result");
             }
         });
@@ -47,10 +47,10 @@ public class SimpleWeaveAddMockLastTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from("seda:start").transform(simple("Bye ${body}")).to("seda:queue");
             }
         };


[camel] 08/09: CAMEL-13826: Migrated camel-hbase tests to camel-test-junit5

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13826
in repository https://gitbox.apache.org/repos/asf/camel.git

commit cdf8facae0af197aa0abde9de0782c0c1e5f8781
Author: aldettinger <al...@gmail.com>
AuthorDate: Wed Aug 14 19:51:51 2019 +0200

    CAMEL-13826: Migrated camel-hbase tests to camel-test-junit5
---
 components/camel-hbase/pom.xml                       | 14 +++++++++++++-
 .../camel/component/hbase/CamelHBaseFilterTest.java  | 12 +++++++-----
 .../camel/component/hbase/CamelHBaseTestSupport.java | 20 ++++++++++----------
 .../camel/component/hbase/HBaseComponentTest.java    | 11 ++++++-----
 .../camel/component/hbase/HBaseConsumerTest.java     |  2 +-
 .../camel/component/hbase/HBaseConvertionsTest.java  |  4 +++-
 .../camel/component/hbase/HBaseProducerTest.java     |  9 +++++++--
 .../idempotent/HBaseIdempotentRepositoryTest.java    | 15 +++++++++------
 .../camel-test-junit5/src/main/docs/test-junit5.adoc |  1 +
 9 files changed, 57 insertions(+), 31 deletions(-)

diff --git a/components/camel-hbase/pom.xml b/components/camel-hbase/pom.xml
index 06fdad9..370644a 100644
--- a/components/camel-hbase/pom.xml
+++ b/components/camel-hbase/pom.xml
@@ -65,6 +65,10 @@
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <!-- because hbase-client 1.1.1 use hadoop2.5.1 by default, check is it still required by the next version update -->
@@ -179,7 +183,7 @@
         <!-- testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -205,6 +209,10 @@
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <!-- because hbase-server 1.1.1 use hadoop2.5.1 by default, check is it still required by the next version update -->
@@ -270,6 +278,10 @@
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <!-- because hbase-testing-util 1.1.1 use hadoop2.5.1 by default, check is it still required by the next version update -->
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
index 9bd93ef..473126a 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseFilterTest.java
@@ -28,7 +28,9 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.hbase.filters.ModelAwareColumnMatchingFilter;
 import org.apache.hadoop.hbase.filter.Filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class CamelHBaseFilterTest extends CamelHBaseTestSupport {
 
@@ -52,10 +54,10 @@ public class CamelHBaseFilterTest extends CamelHBaseTestSupport {
             exchange.getIn().setHeader(HBaseAttribute.HBASE_VALUE.asHeader(), body[0][0][0]);
             Exchange resp = template.send(endpoint, exchange);
             Message out = resp.getOut();
-            assertTrue("two first keys returned",
-                out.getHeaders().containsValue(body[0][0][0])
-                    && out.getHeaders().containsValue(body[1][0][0])
-                    && !out.getHeaders().containsValue(body[2][0][0]));
+            assertTrue(out.getHeaders().containsValue(body[0][0][0])
+                       && out.getHeaders().containsValue(body[1][0][0])
+                       && !out.getHeaders().containsValue(body[2][0][0]),
+                       "two first keys returned");
         }
     }
 
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
index 83ea867..5ce1624 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/CamelHBaseTestSupport.java
@@ -20,7 +20,7 @@ import java.io.IOException;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.camel.util.IOHelper;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -30,10 +30,10 @@ import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Table;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,7 +70,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
             family[1].getBytes(),
             family[2].getBytes()};
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() throws Exception {
         try {
             hbaseUtil.startMiniCluster(numServers);
@@ -80,7 +80,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
         }
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownClass() throws Exception {
         if (systemReady) {
             hbaseUtil.shutdownMiniCluster();
@@ -88,7 +88,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
     }
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         if (systemReady) {
             try {
@@ -102,7 +102,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
     }
 
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         if (systemReady) {
             hbaseUtil.deleteTable(PERSON_TABLE.getBytes());
@@ -112,7 +112,7 @@ public abstract class CamelHBaseTestSupport extends CamelTestSupport {
 
     @Override
     public CamelContext createCamelContext() throws Exception {
-        CamelContext context = new DefaultCamelContext(createRegistry());
+        CamelContext context = new DefaultCamelContext(createCamelRegistry());
         // configure hbase component
         HBaseComponent component = context.getComponent("hbase", HBaseComponent.class);
         component.setConfiguration(hbaseUtil.getConfiguration());
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
index 24b9338..d80aec2 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
@@ -22,8 +22,9 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 public class HBaseComponentTest {
 
@@ -39,7 +40,7 @@ public class HBaseComponentTest {
         component.doStop();
 
         ClassLoader actualClassLoader = component.getConfiguration().getClassLoader();
-        Assert.assertSame(expectedClassLoader, actualClassLoader);
+        assertSame(expectedClassLoader, actualClassLoader);
     }
 
     @Test
@@ -59,7 +60,7 @@ public class HBaseComponentTest {
         component.doStop();
 
         ClassLoader actualClassLoader = component.getConfiguration().getClassLoader();
-        Assert.assertSame(expectedClassLoader, actualClassLoader);
+        assertSame(expectedClassLoader, actualClassLoader);
     }
 
     @Test
@@ -71,6 +72,6 @@ public class HBaseComponentTest {
         component.doStop();
 
         ClassLoader actualClassLoader = component.getConfiguration().getClassLoader();
-        Assert.assertSame(expectedClassLoader, actualClassLoader);
+        assertSame(expectedClassLoader, actualClassLoader);
     }
 }
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
index 61c684a..5b4cdcc 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConsumerTest.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class HBaseConsumerTest extends CamelHBaseTestSupport {
 
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
index cd99762..1154a6e 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseConvertionsTest.java
@@ -30,7 +30,9 @@ import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 
 public class HBaseConvertionsTest extends CamelHBaseTestSupport {
 
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
index 10537bd..cadd550 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseProducerTest.java
@@ -32,7 +32,12 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Table;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HBaseProducerTest extends CamelHBaseTestSupport {
 
@@ -254,7 +259,7 @@ public class HBaseProducerTest extends CamelHBaseTestSupport {
             Object result2 = resp.getOut().getHeader(HBaseAttribute.HBASE_VALUE.asHeader(2));
             // as we use maxResults=2 we only get 2 results back
             Object result3 = resp.getOut().getHeader(HBaseAttribute.HBASE_VALUE.asHeader(3));
-            assertNull("Should only get 2 results back", result3);
+            assertNull(result3, "Should only get 2 results back");
 
             List<?> bodies = Arrays.asList(body[0][0][0], body[1][0][0]);
             assertTrue(bodies.contains(result1) && bodies.contains(result2));
diff --git a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/processor/idempotent/HBaseIdempotentRepositoryTest.java b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/processor/idempotent/HBaseIdempotentRepositoryTest.java
index 5eb7273..cd1797e 100644
--- a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/processor/idempotent/HBaseIdempotentRepositoryTest.java
+++ b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/processor/idempotent/HBaseIdempotentRepositoryTest.java
@@ -24,9 +24,12 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.hadoop.hbase.TableExistsException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HBaseIdempotentRepositoryTest extends CamelHBaseTestSupport {
 
@@ -36,7 +39,7 @@ public class HBaseIdempotentRepositoryTest extends CamelHBaseTestSupport {
     private String key02 = "456";
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         if (systemReady) {
             try {
@@ -50,7 +53,7 @@ public class HBaseIdempotentRepositoryTest extends CamelHBaseTestSupport {
     }
 
     @Override
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         if (systemReady) {
             hbaseUtil.deleteTable(HBaseHelper.getHBaseFieldAsBytes(PERSON_TABLE));
@@ -145,7 +148,7 @@ public class HBaseIdempotentRepositoryTest extends CamelHBaseTestSupport {
 
     @Override
     public CamelContext createCamelContext() throws Exception {
-        return new DefaultCamelContext(createRegistry());
+        return new DefaultCamelContext(createCamelRegistry());
     }
 
     @Override
diff --git a/components/camel-test-junit5/src/main/docs/test-junit5.adoc b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
index 63330ac..0ae295f 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -61,6 +61,7 @@ Projects using `camel-test` would need to use `camel-test-junit5`. For instance,
 * Imports of `org.apache.camel.test.junit4.\*` should be replaced with `org.apache.camel.test.junit5.*`
 * `TestSupport` static methods should be imported where needed, for instance `import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf`
 * Usage of the field `CamelTestSupport.log` should be replaced by another logger, for instance `org.slf4j.LoggerFactory.getLogger(MyCamelTest.class);`
+* Usage of the method `CamelTestSupport.createRegistry` should be replaced by `CamelTestSupport.createCamelRegistry()`
 
 === Typical migration steps linked to JUnit 5 itself
 Once Camel related steps have been performed, there are still typical JUnit 5 migration steps to remember: