You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/06 12:57:18 UTC

(camel) 01/01: CAMEL-20522: camel-test - CamelTestSupport does not call tearDown for each test method in some test classes

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

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

commit db3a14cd06d54d32b619c18a9c99f41dd22ba825
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 6 10:35:49 2024 +0100

    CAMEL-20522: camel-test - CamelTestSupport does not call tearDown for each test method in some test classes
---
 .../main/java/org/apache/camel/test/junit5/CamelTestSupport.java    | 6 ++----
 .../apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java  | 2 --
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index 53bc6fe693a..a15d23d34bb 100644
--- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -65,8 +65,6 @@ import org.apache.camel.util.StopWatch;
 import org.apache.camel.util.StringHelper;
 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.AfterEachCallback;
@@ -140,11 +138,13 @@ public abstract class CamelTestSupport
     public void beforeEach(ExtensionContext context) throws Exception {
         currentTestName = context.getDisplayName();
         globalStore = context.getStore(ExtensionContext.Namespace.GLOBAL);
+        setUp();
     }
 
     @Override
     public void afterEach(ExtensionContext context) throws Exception {
         DefaultCamelContext.clearOptions();
+        tearDown();
     }
 
     @Override
@@ -341,7 +341,6 @@ public abstract class CamelTestSupport
         THREAD_SERVICE.set(camelContextService);
     }
 
-    @BeforeEach
     public void setUp() throws Exception {
         LOG.info(SEPARATOR);
         LOG.info("Testing: {} ({})", currentTestName, getClass().getName());
@@ -563,7 +562,6 @@ public abstract class CamelTestSupport
         return System.getProperty(ROUTE_COVERAGE_ENABLED, "false").equalsIgnoreCase("true") || isDumpRouteCoverage();
     }
 
-    @AfterEach
     public void tearDown() throws Exception {
         long time = watch.taken();
 
diff --git a/components/camel-test/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java b/components/camel-test/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
index 80756406e9c..2f30ae8d5c8 100644
--- a/components/camel-test/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
+++ b/components/camel-test/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/IsMockEndpointsFileTest.java
@@ -20,7 +20,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 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;
@@ -28,7 +27,6 @@ import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
 public class IsMockEndpointsFileTest extends CamelTestSupport {
 
     @Override
-    @BeforeEach
     public void setUp() throws Exception {
         deleteDirectory("target/input");
         deleteDirectory("target/messages");