[camel] branch CAMEL-13826 updated (9d40a37 -> ee69256)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch CAMEL-13826 updated (9d40a37 -> ee69256)

aldettinger
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 9d40a37  CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5)
 discard a1727ab  CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_CLASS
     add 83031b6  Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"
     add df63426  CAMEL-13838: Add support for microprofile metrics
     add 4bdbb91  Replace hard coded versions in microprofile-config POM
     add 985ece4  Camel-AWS-SNS: Moving the logic of doStart for endpoint in doInit
     add fdfb397  Upgrade Jooq to version 3.11.12
     add 0352216  Upgrade Directory Watcher to version 0.9.6
     add 7f70b2e  update migration guide
     new 12013fc  CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_CLASS
     new ee69256  CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5)

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   (9d40a37)
            \
             N -- N -- N   refs/heads/CAMEL-13826 (ee69256)

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 2 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:
 MIGRATION.md                                       |   3 +-
 apache-camel/pom.xml                               |   5 +
 apache-camel/src/main/descriptors/common-bin.xml   |   1 +
 bom/camel-bom/pom.xml                              |   5 +
 .../camel/component/aws/sns/SnsEndpoint.java       |   4 +-
 components/camel-http-common/pom.xml               |   5 -
 .../org/apache/camel/http/common/HttpHelper.java   |   4 +-
 .../apache/camel/http/common/HttpHelperTest.java   |  50 ---
 components/camel-microprofile-config/pom.xml       |   4 +-
 .../pom.xml                                        |  32 +-
 .../main/docs/microprofile-metrics-component.adoc  | 413 +++++++++++++++++++++
 .../AbstractMicroProfileMetricsProducer.java       | 135 +++++++
 .../metrics/MicroProfileMetricsComponent.java      |  61 +++
 .../metrics/MicroProfileMetricsConstants.java      |  54 +++
 .../MicroProfileMetricsCounterProducer.java        |  49 +++
 .../metrics/MicroProfileMetricsEndpoint.java       | 210 +++++++++++
 .../metrics/MicroProfileMetricsGaugeProducer.java  |  53 +++
 .../metrics/MicroProfileMetricsHelper.java         | 118 ++++++
 .../MicroProfileMetricsHistogramProducer.java      |  47 +++
 .../MicroProfileMetricsMeteredProducer.java        |  49 +++
 .../metrics/MicroProfileMetricsService.java        |  54 +++
 .../metrics/MicroProfileMetricsTimerProducer.java  |  93 +++++
 .../microprofile/metrics/TimerAction.java          |  22 ++
 .../AbstractMicroProfileMetricsEventNotifier.java  |  83 +++++
 ...oProfileMetricsEventNotifierNamingStrategy.java |  42 +++
 .../MicroProfileMetricsEventNotifierService.java   |  24 ++
 .../MicroProfileMetricsExchangeEventNotifier.java  |  94 +++++
 ...MetricsExchangeEventNotifierNamingStrategy.java |  48 +++
 .../MicroProfileMetricsRouteEventNotifier.java     |  76 ++++
 ...ileMetricsRouteEventNotifierNamingStrategy.java |  55 +++
 .../history/MicroProfileMetricsMessageHistory.java |  52 +++
 .../MicroProfileMetricsMessageHistoryFactory.java  | 136 +++++++
 ...ProfileMetricsMessageHistoryNamingStrategy.java |  44 +++
 .../MicroProfileMetricsMessageHistoryService.java  |  26 ++
 .../policy/MicroProfileMetricsRoutePolicy.java     | 120 ++++++
 .../MicroProfileMetricsRoutePolicyFactory.java     |  53 +++
 ...croProfileMetricsRoutePolicyNamingStrategy.java |  45 +++
 .../MicroProfileMetricsRoutePolicyService.java     |  26 ++
 .../metrics/MicroProfileMetricsCounterTest.java    |  82 ++++
 .../MicroProfileMetricsCustomRegistryTest.java     |  64 ++++
 .../metrics/MicroProfileMetricsEndpointTest.java   |  79 ++++
 .../metrics/MicroProfileMetricsGaugeTest.java      |  83 +++++
 .../metrics/MicroProfileMetricsHelperTest.java     |  74 ++++
 .../metrics/MicroProfileMetricsHistogramTest.java  |  62 ++++
 .../metrics/MicroProfileMetricsMetadataTest.java   |  88 +++++
 .../metrics/MicroProfileMetricsMeterTest.java      |  72 ++++
 .../metrics/MicroProfileMetricsTagTest.java        | 109 ++++++
 .../metrics/MicroProfileMetricsTestSupport.java    |  98 +++++
 .../metrics/MicroProfileMetricsTimerTest.java      |  71 ++++
 ...croProfileMetricsExchangeEventNotifierTest.java |  82 ++++
 .../MicroProfileMetricsRouteEventNotifierTest.java |  78 ++++
 ...eMetricsExceptionInRouteMessageHistoryTest.java |  93 +++++
 .../MicroProfileMetricsMessageHistoryTest.java     | 110 ++++++
 ...ileMetricsRoutePolicyMulticastSubRouteTest.java |  74 ++++
 ...MicroProfileMetricsRoutePolicySubRouteTest.java |  70 ++++
 .../policy/MicroProfileMetricsRoutePolicyTest.java |  95 +++++
 .../src/test/resources/log4j2.properties           |  28 ++
 components/pom.xml                                 |   1 +
 components/readme.adoc                             |   5 +-
 .../MicroProfileMetricsEndpointBuilderFactory.java | 300 +++++++++++++++
 docs/components/modules/ROOT/nav.adoc              |   1 +
 .../ROOT/pages/microprofile-metrics-component.adoc | 413 +++++++++++++++++++++
 parent/pom.xml                                     |  13 +-
 .../pom.xml                                        |   1 +
 .../camel-spring-boot-dependencies/pom.xml         |   5 +
 .../maven/packaging/SpringBootStarterMojo.java     |   3 +-
 66 files changed, 4566 insertions(+), 83 deletions(-)
 delete mode 100644 components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java
 copy components/{camel-microprofile-config => camel-microprofile-metrics}/pom.xml (75%)
 create mode 100644 components/camel-microprofile-metrics/src/main/docs/microprofile-metrics-component.adoc
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/AbstractMicroProfileMetricsProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsComponent.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsConstants.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsCounterProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpoint.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsGaugeProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsHelper.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsHistogramProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsMeteredProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsService.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsTimerProducer.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/TimerAction.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/AbstractMicroProfileMetricsEventNotifier.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/MicroProfileMetricsEventNotifierNamingStrategy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/MicroProfileMetricsEventNotifierService.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/exchange/MicroProfileMetricsExchangeEventNotifier.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/exchange/MicroProfileMetricsExchangeEventNotifierNamingStrategy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/route/MicroProfileMetricsRouteEventNotifier.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/event/notifier/route/MicroProfileMetricsRouteEventNotifierNamingStrategy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsMessageHistory.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsMessageHistoryFactory.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsMessageHistoryNamingStrategy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsMessageHistoryService.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyFactory.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyNamingStrategy.java
 create mode 100644 components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyService.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsCounterTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsCustomRegistryTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpointTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsGaugeTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsHelperTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsHistogramTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsMetadataTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsMeterTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsTagTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsTestSupport.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsTimerTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/event/notifier/exchange/MicroProfileMetricsExchangeEventNotifierTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/event/notifier/route/MicroProfileMetricsRouteEventNotifierTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsExceptionInRouteMessageHistoryTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/message/history/MicroProfileMetricsMessageHistoryTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyMulticastSubRouteTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicySubRouteTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyTest.java
 create mode 100644 components/camel-microprofile-metrics/src/test/resources/log4j2.properties
 create mode 100644 core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MicroProfileMetricsEndpointBuilderFactory.java
 create mode 100644 docs/components/modules/ROOT/pages/microprofile-metrics-component.adoc

Reply | Threaded
Open this post in threaded view
|

[camel] 01/02: CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_CLASS

aldettinger
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 12013fc680d9882087b94b2cfabca08b9d67f5f6
Author: aldettinger <[hidden email]>
AuthorDate: Tue Aug 20 17:33:30 2019 +0200

    CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_CLASS
---
 .../src/main/docs/test-junit5.adoc                 |  3 +++
 .../apache/camel/test/junit5/CamelTestSupport.java | 25 ++++++++++++++--------
 .../CreateCamelContextPerTestFalseTest.java        |  7 ++----
 .../CreateCamelContextPerTestTrueTest.java         |  5 -----
 .../FilterCreateCamelContextPerClassTest.java      | 10 ++-------
 5 files changed, 23 insertions(+), 27 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 0ae295f..f31ff75 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -62,6 +62,9 @@ Projects using `camel-test` would need to use `camel-test-junit5`. For instance,
 * `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()`
+* Overrides of `isCreateCamelContextPerClass()` returning `false` should be removed
+* Overrides of `isCreateCamelContextPerClass()` returning `true` should be replaced by `@TestInstance(Lifecycle.PER_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:
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 1818a98..083f3fc 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
@@ -66,8 +66,10 @@ import org.apache.camel.util.TimeUtils;
 import org.apache.camel.util.URISupport;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
 import org.junit.jupiter.api.extension.AfterAllCallback;
 import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
@@ -82,7 +84,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 implements BeforeEachCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback {
+public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCallback, BeforeAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback {
 
     /**
      * JVM system property which can be set to true to turn on dumping route
@@ -112,6 +114,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 boolean isCreateCamelContextPerClass = false;
     private CamelRouteCoverageDumper routeCoverageDumper = new CamelRouteCoverageDumper();
     // CHECKSTYLE:ON
 
@@ -135,6 +138,11 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     @Override
+    public void beforeAll(ExtensionContext context) {
+        isCreateCamelContextPerClass = context.getTestInstanceLifecycle().filter(lc -> lc.equals(Lifecycle.PER_CLASS)).isPresent();
+    }
+
+    @Override
     public void afterAll(ExtensionContext context) {
         CamelTestSupport support = INSTANCE.get();
         if (support != null && support.isCreateCamelContextPerClass()) {
@@ -197,12 +205,11 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
     }
 
     /**
-     * Override to control whether {@link CamelContext} should be setup per test
-     * or per class.
+     * Tells whether {@link CamelContext} should be setup per test or per class.
      * <p/>
-     * By default it will be setup/teardown per test (per test method). If you
-     * want to re-use {@link CamelContext} between test methods you can override
-     * this method and return <tt>true</tt>
+     * By default it will be setup/teardown per test method. This method returns
+     * <code>true</code> when the camel test class is annotated
+     * with @TestInstance(TestInstance.Lifecycle.PER_CLASS).
      * <p/>
      * <b>Important:</b> Use this with care as the {@link CamelContext} will
      * carry over state from previous tests, such as endpoints, components etc.
@@ -214,8 +221,8 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
      *
      * @return <tt>true</tt> per class, <tt>false</tt> per test.
      */
-    public boolean isCreateCamelContextPerClass() {
-        return false;
+    public final boolean isCreateCamelContextPerClass() {
+        return isCreateCamelContextPerClass;
     }
 
     /**
@@ -539,7 +546,7 @@ public abstract class CamelTestSupport implements BeforeEachCallback, AfterAllCa
         LOG.info("********************************************************************************");
 
         if (isCreateCamelContextPerClass()) {
-            // will tear down test specially in CamelTearDownRule
+            // will tear down test specially in afterAll callback
         } else {
             LOG.debug("tearDown()");
             doStopTemplates(consumer, template, fluentTemplate);
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 34c8591..149edb9 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
@@ -27,12 +27,14 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@TestInstance(TestInstance.Lifecycle.PER_METHOD)
 public class CreateCamelContextPerTestFalseTest extends CamelTestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(CreateCamelContextPerTestFalseTest.class);
@@ -47,11 +49,6 @@ public class CreateCamelContextPerTestFalseTest extends CamelTestSupport {
     protected ProducerTemplate template;
 
     @Override
-    public boolean isCreateCamelContextPerClass() {
-        return false;
-    }
-
-    @Override
     protected CamelContext createCamelContext() throws Exception {
         LOG.info("createCamelContext()");
         CREATED_CONTEXTS.incrementAndGet();
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 a234455..222fe62 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
@@ -52,11 +52,6 @@ public class CreateCamelContextPerTestTrueTest extends CamelTestSupport {
     protected ProducerTemplate template;
 
     @Override
-    public boolean isCreateCamelContextPerClass() {
-        return true;
-    }
-
-    @Override
     protected CamelContext createCamelContext() throws Exception {
         LOG.info("createCamelContext()");
         CREATED_CONTEXTS.incrementAndGet();
diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/FilterCreateCamelContextPerClassTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/FilterCreateCamelContextPerClassTest.java
index 0f5be29..be38b86 100644
--- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/FilterCreateCamelContextPerClassTest.java
+++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/FilterCreateCamelContextPerClassTest.java
@@ -19,21 +19,15 @@ package org.apache.camel.test.junit5.patterns;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
 
 /**
  * Tests filtering using Camel Test
  */
 // START SNIPPET: example
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class FilterCreateCamelContextPerClassTest extends CamelTestSupport {
 
-    @Override
-    public boolean isCreateCamelContextPerClass() {
-        // we override this method and return true, to tell Camel test-kit that
-        // it should only create CamelContext once (per class), so we will
-        // re-use the CamelContext between each test method in this class
-        return true;
-    }
-
     @Test
     public void testSendMatchingMessage() throws Exception {
         String expectedBody = "<matched/>";

Reply | Threaded
Open this post in threaded view
|

[camel] 02/02: CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5)

aldettinger
In reply to this post by aldettinger
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 ee6925674c44e09afd12f9c2ec39a06a57e0d608
Author: aldettinger <[hidden email]>
AuthorDate: Wed Aug 21 17:31:13 2019 +0200

    CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5)
---
 components/camel-test/pom.xml                             |  4 ++++
 components/camel-xstream/pom.xml                          |  5 +++++
 .../dataformat/xstream/MarshalDomainObjectJSONTest.java   |  4 +++-
 .../camel/dataformat/xstream/MarshalDomainObjectTest.java |  8 +++++---
 .../xstream/XStreamDataFormatOmitFieldsTest.java          | 15 +++++++++------
 .../XStreamDataFormatPermissionsSystemPropertyTest.java   | 13 ++++++++-----
 .../xstream/XStreamDataFormatPermissionsTest.java         |  7 +++++--
 parent/pom.xml                                            |  4 ++--
 .../camel-spring-boot-dependencies-generator/pom.xml      |  1 +
 9 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/components/camel-test/pom.xml b/components/camel-test/pom.xml
index 2e70437..aa6acfa 100644
--- a/components/camel-test/pom.xml
+++ b/components/camel-test/pom.xml
@@ -54,6 +54,10 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>
diff --git a/components/camel-xstream/pom.xml b/components/camel-xstream/pom.xml
index d3fa5d7..99dad32 100644
--- a/components/camel-xstream/pom.xml
+++ b/components/camel-xstream/pom.xml
@@ -77,6 +77,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
             <artifactId>camel-spring</artifactId>
             <scope>test</scope>
         </dependency>
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java
index 6f6ad86..2e6fe37 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java
@@ -19,7 +19,9 @@ package org.apache.camel.dataformat.xstream;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.model.dataformat.JsonLibrary;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class MarshalDomainObjectJSONTest extends MarshalDomainObjectTest {
     
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
index 8e429d5..2096c85 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java
@@ -18,8 +18,10 @@ package org.apache.camel.dataformat.xstream;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-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;
 
 /**
  * Marshal tests with domain objects.
@@ -58,7 +60,7 @@ public class MarshalDomainObjectTest extends CamelTestSupport {
 
         String body1 = mock.getExchanges().get(0).getIn().getBody(String.class);
         String body2 = mock.getExchanges().get(1).getIn().getBody(String.class);
-        assertEquals("The body should marshalled to the same", body1, body2);
+        assertEquals(body1, body2, "The body should marshalled to the same");
     }
 
     @Test
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java
index b6d34e2..b9df598 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java
@@ -21,8 +21,11 @@ import java.util.Map;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class XStreamDataFormatOmitFieldsTest extends CamelTestSupport {
 
@@ -40,10 +43,10 @@ public class XStreamDataFormatOmitFieldsTest extends CamelTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);        
-        assertTrue("Should contain name field", body.contains("<name>"));
-        assertFalse("Should not contain price field", body.contains("price"));
-        assertTrue("Should contain amount field", body.contains("<amount>"));
+        String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
+        assertTrue(body.contains("<name>"), "Should contain name field");
+        assertFalse(body.contains("price"), "Should not contain price field");
+        assertTrue(body.contains("<amount>"), "Should contain amount field");
     }
     
 
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java
index 99f83d6..acf39a4 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java
@@ -16,20 +16,23 @@
  */
 package org.apache.camel.dataformat.xstream;
 import com.thoughtworks.xstream.XStream;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class XStreamDataFormatPermissionsSystemPropertyTest extends XStreamDataFormatPermissionsTest {
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         // clear the default permissions system property
         // see AbstractXStreamWrapper.PERMISSIONS_PROPERTY_DEFAULT
         XStreamTestUtils.setPermissionSystemProperty("*");
     }
 
-    @AfterClass
+    @AfterAll
     public static void cleanup() {
         XStreamTestUtils.revertPermissionSystemProperty();
     }
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java
index 425be60..ee8a274 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java
@@ -18,8 +18,11 @@ package org.apache.camel.dataformat.xstream;
 
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.security.ForbiddenClassException;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class XStreamDataFormatPermissionsTest extends CamelTestSupport {
     protected static final String XML_PURCHASE_ORDER =
diff --git a/parent/pom.xml b/parent/pom.xml
index 9bf50b0..3c84977 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -4794,8 +4794,8 @@
                 <version>${junit-jupiter-version}</version>
             </dependency>
             <dependency>
-                <groupId>org.junit.jupiter</groupId>
-                <artifactId>junit-jupiter-vintage</artifactId>
+                <groupId>org.junit.vintage</groupId>
+                <artifactId>junit-vintage-engine</artifactId>
                 <version>${junit-jupiter-version}</version>
             </dependency>
             <dependency>
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml
index 38b5af6..9e5cc33 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml
@@ -160,6 +160,7 @@
                             <exclude>javax.servlet:javax.servlet-api</exclude>
                             <exclude>junit:*</exclude>
                             <exclude>org.junit.jupiter:*</exclude>
+                            <exclude>org.junit.vintage:*</exclude>
                             <exclude>net.sf.ehcache:ehcache</exclude>
 
                             <exclude>xml-apis:*</exclude>