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

jamesnetherton pushed a commit to branch 3.20.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/3.20.x by this push:
     new f96cce27ca Rework CallbackUtil.MockExtensionContext to not implement 
JUnit ExtensionContext
f96cce27ca is described below

commit f96cce27ca8bfafa34433a36fc724b63ae123d23
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Fri May 9 11:21:14 2025 +0100

    Rework CallbackUtil.MockExtensionContext to not implement JUnit 
ExtensionContext
    
    Fixes #7349
---
 .../camel/quarkus/test/AfterAllCallback.java       |  6 +-
 .../camel/quarkus/test/BeforeEachCallback.java     |  4 +-
 .../apache/camel/quarkus/test/CallbackUtil.java    | 92 +---------------------
 .../quarkus/test/CamelQuarkusTestSupport.java      |  7 +-
 4 files changed, 10 insertions(+), 99 deletions(-)

diff --git 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/AfterAllCallback.java
 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/AfterAllCallback.java
index ca01e45172..dc1c21631c 100644
--- 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/AfterAllCallback.java
+++ 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/AfterAllCallback.java
@@ -18,7 +18,6 @@ package org.apache.camel.quarkus.test;
 
 import io.quarkus.test.junit.callback.QuarkusTestAfterAllCallback;
 import io.quarkus.test.junit.callback.QuarkusTestContext;
-import org.junit.jupiter.api.extension.ExtensionContext;
 
 public class AfterAllCallback implements QuarkusTestAfterAllCallback {
 
@@ -28,10 +27,7 @@ public class AfterAllCallback implements 
QuarkusTestAfterAllCallback {
             CamelQuarkusTestSupport testInstance = (CamelQuarkusTestSupport) 
context.getTestInstance();
 
             if (CallbackUtil.isPerClass(testInstance)) {
-                ExtensionContext mockContext = new 
CallbackUtil.MockExtensionContext(CallbackUtil.getLifecycle(testInstance),
-                        null);
-
-                testInstance.internalAfterAll(context, mockContext);
+                testInstance.internalAfterAll();
                 CallbackUtil.resetContext(testInstance);
             }
 
diff --git 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java
 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java
index 93ac9e34e7..cf46ddcb6a 100644
--- 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java
+++ 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java
@@ -22,7 +22,7 @@ import java.util.stream.Collectors;
 
 import io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback;
 import io.quarkus.test.junit.callback.QuarkusTestMethodContext;
-import org.junit.jupiter.api.extension.ExtensionContext;
+import org.apache.camel.quarkus.test.CallbackUtil.MockExtensionContext;
 
 public class BeforeEachCallback implements QuarkusTestBeforeEachCallback {
 
@@ -30,7 +30,7 @@ public class BeforeEachCallback implements 
QuarkusTestBeforeEachCallback {
     public void beforeEach(QuarkusTestMethodContext context) {
         if (context.getTestInstance() instanceof CamelQuarkusTestSupport) {
             CamelQuarkusTestSupport testInstance = (CamelQuarkusTestSupport) 
context.getTestInstance();
-            ExtensionContext mockContext = new 
CallbackUtil.MockExtensionContext(CallbackUtil.getLifecycle(testInstance),
+            MockExtensionContext mockContext = new 
MockExtensionContext(CallbackUtil.getLifecycle(testInstance),
                     getDisplayName(context.getTestMethod()));
 
             try {
diff --git 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CallbackUtil.java
 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CallbackUtil.java
index 10f32a3298..033d336b9f 100644
--- 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CallbackUtil.java
+++ 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CallbackUtil.java
@@ -16,19 +16,12 @@
  */
 package org.apache.camel.quarkus.test;
 
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Function;
 
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.TestInstance;
-import org.junit.jupiter.api.extension.ExecutableInvoker;
 import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.TestInstances;
-import org.junit.jupiter.api.parallel.ExecutionMode;
 import org.junit.jupiter.engine.execution.NamespaceAwareStore;
 import org.junit.platform.engine.support.store.NamespacedHierarchicalStore;
 
@@ -69,8 +62,7 @@ public class CallbackUtil {
         MockEndpoint.resetMocks(testInstance.context());
     }
 
-    static class MockExtensionContext implements ExtensionContext {
-
+    static class MockExtensionContext {
         private final Optional<TestInstance.Lifecycle> lifecycle;
         private final String currentTestName;
         private final ExtensionContext.Store globalStore;
@@ -82,97 +74,19 @@ public class CallbackUtil {
                     ExtensionContext.Namespace.GLOBAL);
         }
 
-        @Override
-        public Optional<ExtensionContext> getParent() {
-            return Optional.empty();
-        }
-
-        @Override
-        public ExtensionContext getRoot() {
-            return null;
-        }
-
-        @Override
-        public String getUniqueId() {
-            return null;
-        }
-
-        @Override
         public String getDisplayName() {
             return currentTestName;
         }
 
-        @Override
-        public Set<String> getTags() {
-            return null;
-        }
-
-        @Override
-        public Optional<AnnotatedElement> getElement() {
-            return Optional.empty();
-        }
-
-        @Override
-        public Optional<Class<?>> getTestClass() {
-            return Optional.empty();
-        }
-
-        @Override
         public Optional<TestInstance.Lifecycle> getTestInstanceLifecycle() {
             return lifecycle;
         }
 
-        @Override
-        public Optional<Object> getTestInstance() {
-            return Optional.empty();
-        }
-
-        @Override
-        public Optional<TestInstances> getTestInstances() {
-            return Optional.empty();
-        }
-
-        @Override
-        public Optional<Method> getTestMethod() {
-            return Optional.empty();
-        }
-
-        @Override
-        public Optional<Throwable> getExecutionException() {
-            return Optional.empty();
-        }
-
-        @Override
-        public Optional<String> getConfigurationParameter(String key) {
-            return Optional.empty();
-        }
-
-        @Override
-        public <T> Optional<T> getConfigurationParameter(String key, 
Function<String, T> transformer) {
-            return Optional.empty();
-        }
-
-        @Override
-        public void publishReportEntry(Map<String, String> map) {
-
-        }
-
-        @Override
-        public Store getStore(Namespace namespace) {
-            if (namespace == Namespace.GLOBAL) {
+        public ExtensionContext.Store getStore(ExtensionContext.Namespace 
namespace) {
+            if (namespace == ExtensionContext.Namespace.GLOBAL) {
                 return globalStore;
             }
             return null;
         }
-
-        @Override
-        public ExecutionMode getExecutionMode() {
-            return null;
-        }
-
-        @Override
-        public ExecutableInvoker getExecutableInvoker() {
-            return null;
-        }
     }
 }
diff --git 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
index 01d8af84d4..06274cadf9 100644
--- 
a/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
+++ 
b/test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
@@ -37,6 +37,7 @@ import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.quarkus.core.FastCamelContext;
+import org.apache.camel.quarkus.test.CallbackUtil.MockExtensionContext;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.test.junit5.AbstractTestSupport;
 import org.apache.camel.test.junit5.CamelContextConfiguration;
@@ -329,7 +330,7 @@ public class CamelQuarkusTestSupport extends 
AbstractTestSupport
         return new RoutesBuilder[] { createRouteBuilder() };
     }
 
-    void internalAfterAll(QuarkusTestContext context, ExtensionContext 
extensionContext) {
+    void internalAfterAll() {
         try {
             if (testConfiguration().isCreateCamelContextPerClass()) {
                 //call all clear and release methods, stop is not called as it 
is disabled on the camelContextManagers
@@ -344,7 +345,7 @@ public class CamelQuarkusTestSupport extends 
AbstractTestSupport
         }
     }
 
-    void internalBeforeAll(ExtensionContext context) {
+    void internalBeforeAll(MockExtensionContext context) {
         final boolean perClassPresent = context.getTestInstanceLifecycle()
                 .filter(lc -> 
lc.equals(TestInstance.Lifecycle.PER_CLASS)).isPresent();
         if (perClassPresent) {
@@ -358,7 +359,7 @@ public class CamelQuarkusTestSupport extends 
AbstractTestSupport
         contextManager.setGlobalStore(globalStore);
     }
 
-    void internalBeforeEach(ExtensionContext context) throws Exception {
+    void internalBeforeEach(MockExtensionContext context) throws Exception {
         if (contextManager == null) {
             LOG.trace("Creating a transient context manager for {}", 
context.getDisplayName());
             contextManager = 
contextManagerFactory.createContextManager(ContextManagerFactory.Type.BEFORE_EACH,

Reply via email to