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/23 07:27:04 UTC

[camel] branch CAMEL-13826 updated (124646a -> f169f19)

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.


    from 124646a  camel-http-common - Fix typos in HttpHelper
     new 8c2dc9b  CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_CLASS
     new 29c5e52  CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5)
     new f169f19  CAMEL-13826: Added a comment in the doc about the possibility to migrate per camel test

The 3 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:
 .../src/main/docs/test-junit5.adoc                 |  5 +++++
 .../apache/camel/test/junit5/CamelTestSupport.java | 25 ++++++++++++++--------
 .../CreateCamelContextPerTestFalseTest.java        |  7 ++----
 .../CreateCamelContextPerTestTrueTest.java         |  5 -----
 .../FilterCreateCamelContextPerClassTest.java      | 10 ++-------
 components/camel-test/pom.xml                      |  4 ++++
 components/camel-xstream/pom.xml                   |  5 +++++
 .../xstream/MarshalDomainObjectJSONTest.java       |  4 +++-
 .../xstream/MarshalDomainObjectTest.java           |  8 ++++---
 .../xstream/XStreamDataFormatOmitFieldsTest.java   | 15 +++++++------
 ...eamDataFormatPermissionsSystemPropertyTest.java | 13 ++++++-----
 .../xstream/XStreamDataFormatPermissionsTest.java  |  7 ++++--
 parent/pom.xml                                     |  4 ++--
 .../pom.xml                                        |  1 +
 14 files changed, 67 insertions(+), 46 deletions(-)


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

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 29c5e52d49d60d3571a1f38e41c9de62a02166d9
Author: aldettinger <al...@gmail.com>
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>


[camel] 03/03: CAMEL-13826: Added a comment in the doc about the possibility to migrate per camel test

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 f169f194ba8934d6aa1176e4150facd07a0a19c1
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Aug 22 17:39:28 2019 +0200

    CAMEL-13826: Added a comment in the doc about the possibility to migrate per camel test
---
 components/camel-test-junit5/src/main/docs/test-junit5.adoc | 2 ++
 1 file changed, 2 insertions(+)

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 f31ff75..858e3b7 100644
--- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc
+++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc
@@ -57,6 +57,8 @@ Projects using `camel-test` would need to use `camel-test-junit5`. For instance,
 </dependency>
 ----
 
+Tips: Note that it's possible to reference both `camel-test` and `camel-test-junit5` thus allowing to migrate camel tests once at a time.
+
 === 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`


[camel] 01/03: CAMEL-13826: Merged CamelTestSupport.isCreateCamelContextPerClass() into JUnit 5 Lifecycle.PER_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 8c2dc9b8153d5b78635fec12c8b947cf0ee5aa95
Author: aldettinger <al...@gmail.com>
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/>";