You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/03/14 08:24:59 UTC

(camel) 01/04: CAMEL-20447: fix SjmsComponentRestartTest test due to lifecycle requirements

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

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

commit dcfbe87142398e07e145274123bc8a89ee58a06a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 13 10:10:05 2024 +0100

    CAMEL-20447: fix SjmsComponentRestartTest test due to lifecycle requirements
---
 .../component/sjms/SjmsComponentRestartTest.java   | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsComponentRestartTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsComponentRestartTest.java
index 11a81f0c16a..16a7baccb90 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsComponentRestartTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsComponentRestartTest.java
@@ -23,17 +23,33 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.infra.artemis.services.ArtemisService;
 import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
 
 public class SjmsComponentRestartTest extends CamelTestSupport {
 
-    @RegisterExtension
-    public ArtemisService service = ArtemisServiceFactory.createSingletonVMService();
+    /*
+     * This one needs a custom lifecycle due to binding to registry via @BindToRegistry.
+     * The broker needs to be started earlier than usual.
+     */
+    public static ArtemisService service;
+
     @BindToRegistry("activemqCF")
     private ActiveMQConnectionFactory connectionFactory
             = new ActiveMQConnectionFactory(service.serviceAddress());
 
+    static {
+        service = ArtemisServiceFactory.createVMService();
+        service.initialize();
+    }
+
+    @AfterAll
+    public static void shutdownBroker() {
+        if (service != null) {
+            service.shutdown();
+        }
+    }
+
     @Override
     protected boolean useJmx() {
         return false;