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/06 18:16:03 UTC

(camel) branch main updated (436a4dec683 -> f3cdc897a94)

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

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


    from 436a4dec683 (chores) camel-lumberjack: cleanup multi-thread test
     new 50a50e83599 CAMEL-20479: delay broker configuration
     new aec00edea82 CAMEL-20479: use a semi-random directory for the broker instance
     new c06efa3eee2 CAMEL-20479: allow reusing VM-based broker instances
     new 7c41c15258d CAMEL-20477: stop using a broker with custom configuration for tests that need a common one
     new a97943c4015 CAMEL-20479: do not reuse forks for non-concurrent integration tests
     new b6363f78eb2 CAMEL-20479: fix broken JMS tests
     new 62a3aeb93a5 CAMEL-20479: fixed CXF test affected by delaying broker configuration
     new f3cdc897a94 CAMEL-20479: fixed SJMS2 test affected by delaying broker configuration

The 8 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:
 .../cxf/jms/CxfEndpointJMSConsumerTest.java        |  3 +-
 components/camel-jms/pom.xml                       |  2 +-
 ...RequestReplyExclusiveReplyToConcurrentTest.java |  8 ++-
 .../JmsAddAndRemoveRouteManagementIT.java          |  2 +-
 .../JmsDestinationProducedHeaderIT.java            |  7 +++
 ...ueueTimeoutUseMessageIDAsCorrelationIDTest.java |  3 +
 .../JmsToDSendDynamicTwoDisabledIT.java            |  7 +++
 .../spring/AbstractSpringJMSITSupport.java         |  2 +-
 .../spring/CamelBrokerClientITSupport.java         | 51 -----------------
 .../integration/spring/JmsConsumerShutdownIT.java  | 25 ++++++++-
 .../jms/integration/spring/SpringJMSBasic.java}    | 20 ++++---
 .../issues/AdviceWithTransactionIssueIT.java       |  4 +-
 .../AsyncJmsProducerExceptionInTXManualIT.java     |  4 +-
 .../spring/issues/FileToJmsIssueIT.java            |  4 +-
 ...ndToMultipleDestinationsWithSameEndpointIT.java |  4 +-
 .../spring/issues/JmsSpringValidatorIT.java        |  4 +-
 .../spring/polling/JmsPollingConsumerSpringIT.java |  4 +-
 .../spring/tx/JMSNestedTransactionRollbackIT.java  |  4 +-
 .../issues/JmsInOutPersistentReplyQueueTest.java   | 10 +++-
 ...tReplyTemporaryRefreshFailureOnStartupTest.java | 51 +++++++++++------
 .../integration/spring/JmsConsumerShutdownIT.xml   |  2 +-
 .../{camelBrokerClient.xml => SpringJMSBasic.xml}  |  2 +-
 .../spring/issues/AdviceWithTransactionIssueIT.xml |  2 +-
 .../integration/spring/issues/FileToJmsIssueIT.xml |  2 +-
 .../spring/issues/JmsSpringValidatorIT.xml         |  2 +-
 .../spring/polling/JmsPollingConsumerIT.xml        |  2 +-
 .../spring/tx/JMSNestedTransactionRollbackIT.xml   |  2 +-
 .../component/sjms2/Sjms2ComponentRestartTest.java |  2 +-
 .../services/AbstractArtemisEmbeddedService.java   | 65 +++++++++++++++++++---
 .../infra/artemis/services/ArtemisAMQPService.java |  3 -
 .../services/ArtemisEmbeddedServiceBuilder.java    | 10 ++--
 .../infra/artemis/services/ArtemisVMService.java   | 11 ++++
 32 files changed, 204 insertions(+), 120 deletions(-)
 delete mode 100644 components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/CamelBrokerClientITSupport.java
 copy components/{camel-infinispan/camel-infinispan-embedded/src/test/java/org/apache/camel/component/infinispan/embedded/spring/SpringInfinispanEmbeddedIdempotentRepositoryCamelTest.java => camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.java} (66%)
 rename components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/{camelBrokerClient.xml => SpringJMSBasic.xml} (96%)


(camel) 01/08: CAMEL-20479: delay broker configuration

Posted by or...@apache.org.
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 50a50e83599023ac9b3ed8924719180bcc6c18aa
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Feb 28 11:14:30 2024 +0100

    CAMEL-20479: delay broker configuration
    
    Delay configuring broker to the moment it is about to start to reduce the incidence of trying to reuse acceptors
---
 .../services/AbstractArtemisEmbeddedService.java   | 22 ++++++++++++++++++----
 .../infra/artemis/services/ArtemisAMQPService.java |  3 ---
 .../services/ArtemisEmbeddedServiceBuilder.java    | 10 ++++------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
index 058344c3581..9e3bb4dd4e0 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
@@ -45,16 +45,23 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
 
     protected final EmbeddedActiveMQ embeddedBrokerService;
     private final Configuration artemisConfiguration;
+    private Consumer<Configuration> customConfigurator;
+    private final int port;
 
     public AbstractArtemisEmbeddedService() {
         this(AvailablePortFinder.getNextAvailable());
     }
 
+    /**
+     * This is needed for some tests that check reliability of the components by defining the port in advance, trying to connect
+     * first starting the service later
+     * @param port the port to use
+     */
     protected AbstractArtemisEmbeddedService(int port) {
         embeddedBrokerService = new EmbeddedActiveMQ();
         artemisConfiguration = new ConfigurationImpl();
 
-        embeddedBrokerService.setConfiguration(configure(port));
+        this.port = port;
     }
 
     private synchronized Configuration configure(int port) {
@@ -67,13 +74,18 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
         artemisConfiguration.setJMXManagementEnabled(false);
         artemisConfiguration.setMaxDiskUsage(98);
 
-        return configure(artemisConfiguration, port, brokerId);
+        final Configuration config = configure(artemisConfiguration, port, brokerId);
+        if (customConfigurator != null) {
+            customConfigurator.accept(config);
+        }
+
+        return config;
     }
 
     protected abstract Configuration configure(Configuration artemisConfiguration, int port, int brokerId);
 
-    public void customConfiguration(Consumer<Configuration> configuration) {
-        configuration.accept(artemisConfiguration);
+    public void customConfiguration(Consumer<Configuration> configurator) {
+        this.customConfigurator = configurator;
     }
 
     @Override
@@ -103,6 +115,8 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
     public synchronized void initialize() {
         try {
             if (embeddedBrokerService.getActiveMQServer() == null || !embeddedBrokerService.getActiveMQServer().isStarted()) {
+                embeddedBrokerService.setConfiguration(configure(port));
+
                 embeddedBrokerService.start();
 
                 embeddedBrokerService.getActiveMQServer().waitForActivation(20, TimeUnit.SECONDS);
diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisAMQPService.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisAMQPService.java
index b5e9c023ae4..eed04d75b06 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisAMQPService.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisAMQPService.java
@@ -29,9 +29,6 @@ public class ArtemisAMQPService extends AbstractArtemisEmbeddedService {
     private String brokerURL;
     private int amqpPort;
 
-    public ArtemisAMQPService() {
-    }
-
     @Override
     protected Configuration configure(Configuration artemisConfiguration, int port, int brokerId) {
         amqpPort = port;
diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisEmbeddedServiceBuilder.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisEmbeddedServiceBuilder.java
index 4285e5c3e9a..b4ffbad9be6 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisEmbeddedServiceBuilder.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisEmbeddedServiceBuilder.java
@@ -23,7 +23,7 @@ import org.apache.activemq.artemis.core.config.Configuration;
 public class ArtemisEmbeddedServiceBuilder {
 
     private boolean isPersistent;
-    private Consumer<Configuration> artemisConfiguration;
+    private Consumer<Configuration> customConfigurator;
 
     public ArtemisEmbeddedServiceBuilder() {
     }
@@ -34,8 +34,8 @@ public class ArtemisEmbeddedServiceBuilder {
         return this;
     }
 
-    public ArtemisEmbeddedServiceBuilder withCustomConfiguration(Consumer<Configuration> configuration) {
-        artemisConfiguration = configuration;
+    public ArtemisEmbeddedServiceBuilder withCustomConfiguration(Consumer<Configuration> customConfigurator) {
+        this.customConfigurator = customConfigurator;
 
         return this;
     }
@@ -48,9 +48,7 @@ public class ArtemisEmbeddedServiceBuilder {
             artemisService = new ArtemisVMService();
         }
 
-        if (artemisService != null) {
-            artemisService.customConfiguration(artemisConfiguration);
-        }
+        artemisService.customConfiguration(customConfigurator);
 
         return artemisService;
     }


(camel) 06/08: CAMEL-20479: fix broken JMS tests

Posted by or...@apache.org.
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 b6363f78eb20bc9a3fcf6957c8a522265128dda7
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 12:01:00 2024 +0100

    CAMEL-20479: fix broken JMS tests
    
    - isolate unsafe tests
    - fixed tests
---
 .../jms/JmsRequestReplyExclusiveReplyToConcurrentTest.java     |  8 ++++++--
 .../jms/integration/JmsAddAndRemoveRouteManagementIT.java      |  2 +-
 .../jms/integration/JmsDestinationProducedHeaderIT.java        |  7 +++++++
 ...tFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest.java |  3 +++
 .../jms/integration/JmsToDSendDynamicTwoDisabledIT.java        |  7 +++++++
 .../jms/integration/spring/JmsConsumerShutdownIT.java          |  6 ++++++
 .../component/jms/issues/JmsInOutPersistentReplyQueueTest.java | 10 +++++++++-
 7 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyExclusiveReplyToConcurrentTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyExclusiveReplyToConcurrentTest.java
index 62b2705935d..061e640b748 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyExclusiveReplyToConcurrentTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyExclusiveReplyToConcurrentTest.java
@@ -31,9 +31,10 @@ import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.parallel.Isolated;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +42,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-@Isolated("Creates multiple threads")
+/**
+ * Creates multiple threads
+ */
+@Tags({ @Tag("not-parallel"), @Tag("spring") })
 public class JmsRequestReplyExclusiveReplyToConcurrentTest extends AbstractJMSTest {
 
     @Order(2)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsAddAndRemoveRouteManagementIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsAddAndRemoveRouteManagementIT.java
index c377131cc53..59c57374e83 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsAddAndRemoveRouteManagementIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsAddAndRemoveRouteManagementIT.java
@@ -42,7 +42,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
- * Test that all thread pools is removed when adding and removing a route dynamically. This test manipulates the thread
+ * Test that all thread pools are removed when adding and removing a route dynamically. This test manipulates the thread
  * pools, so it's not a good candidate for running in parallel.
  */
 @Tags({ @Tag("not-parallel") })
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDestinationProducedHeaderIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDestinationProducedHeaderIT.java
index cafa3c18611..a304b4d9863 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDestinationProducedHeaderIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsDestinationProducedHeaderIT.java
@@ -20,10 +20,17 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.AbstractPersistentJMSTest;
 import org.apache.camel.component.jms.JmsConstants;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+/**
+ * This test computes the number of components, so it could be affected by other tests. Therefore, it's run in
+ * isolation.
+ */
+@Tags({ @Tag("not-parallel"), @Tag("spring") })
 public class JmsDestinationProducedHeaderIT extends AbstractPersistentJMSTest {
 
     @Test
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsInOutFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsInOutFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest.java
index bf08487d3d6..e5920485efa 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsInOutFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsInOutFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest.java
@@ -21,7 +21,10 @@ import java.time.Duration;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.JmsInOutFixedReplyQueueTimeoutTest;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Tags;
 
+@Tags({ @Tag("not-parallel"), @Tag("spring") })
 public class JmsInOutFixedReplyQueueTimeoutUseMessageIDAsCorrelationIDTest extends JmsInOutFixedReplyQueueTimeoutTest {
 
     @Override
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsToDSendDynamicTwoDisabledIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsToDSendDynamicTwoDisabledIT.java
index 7c283688d26..119e52c14af 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsToDSendDynamicTwoDisabledIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/JmsToDSendDynamicTwoDisabledIT.java
@@ -18,10 +18,17 @@ package org.apache.camel.component.jms.integration;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.AbstractPersistentJMSTest;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+/**
+ * This test computes the number of components, so it could be affected by other tests. Therefore, it's run in
+ * isolation.
+ */
+@Tags({ @Tag("not-parallel"), @Tag("spring") })
 public class JmsToDSendDynamicTwoDisabledIT extends AbstractPersistentJMSTest {
 
     @Test
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
index 22cafe28d99..026810164ee 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
@@ -26,11 +26,17 @@ import org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilde
 import org.apache.camel.test.infra.artemis.services.ArtemisService;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.test.annotation.DirtiesContext;
 
+/**
+ * This test configures the context shutdown strategy, so we run it in isolation to avoid messing up with others
+ */
+@Tags({ @Tag("not-parallel"), @Tag("spring") })
 public final class JmsConsumerShutdownIT extends CamelSpringTestSupport {
     @RegisterExtension
     public static ArtemisService service = new ArtemisEmbeddedServiceBuilder()
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
index a93141b7132..488f011c12a 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.jms.issues;
 
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ExchangePattern;
@@ -25,6 +28,7 @@ import org.apache.camel.component.jms.AbstractJMSTest;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.infra.core.CamelContextExtension;
 import org.apache.camel.test.infra.core.DefaultCamelContextExtension;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Tag;
@@ -32,7 +36,7 @@ import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-// Not parallel due to processing some part of the route concurrently (may be delayed when running on the test threads)
+// Due to processing some part of the route concurrently (may be delayed when running on the test threads)
 @Tags({ @Tag("not-parallel") })
 public class JmsInOutPersistentReplyQueueTest extends AbstractJMSTest {
 
@@ -42,6 +46,7 @@ public class JmsInOutPersistentReplyQueueTest extends AbstractJMSTest {
     protected CamelContext context;
     protected ProducerTemplate template;
     protected ConsumerTemplate consumer;
+    private final CountDownLatch latch = new CountDownLatch(4);
 
     @Test
     public void testInOutPersistentReplyQueue() throws Exception {
@@ -52,6 +57,8 @@ public class JmsInOutPersistentReplyQueueTest extends AbstractJMSTest {
         template.sendBody("seda:start", "C");
         template.sendBody("seda:start", "D");
 
+        Assertions.assertTrue(latch.await(5, TimeUnit.SECONDS));
+
         MockEndpoint.assertIsSatisfied(context);
     }
 
@@ -72,6 +79,7 @@ public class JmsInOutPersistentReplyQueueTest extends AbstractJMSTest {
                         .threads(5)
                         .log("Reply ${body}")
                         .delay(2000)
+                        .process(e -> latch.countDown())
                         .to("mock:result");
 
                 from("activemq:queue:JmsInOutPersistentReplyQueueTest")


(camel) 05/08: CAMEL-20479: do not reuse forks for non-concurrent integration tests

Posted by or...@apache.org.
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 a97943c4015ee6caf9981db1bd3fa107ca2a6956
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 11:50:34 2024 +0100

    CAMEL-20479: do not reuse forks for non-concurrent integration tests
---
 components/camel-jms/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-jms/pom.xml b/components/camel-jms/pom.xml
index 4e19b9630b3..361601263f8 100644
--- a/components/camel-jms/pom.xml
+++ b/components/camel-jms/pom.xml
@@ -244,7 +244,7 @@
                                 </goals>
                                 <configuration>
                                     <forkCount>4</forkCount>
-                                    <reuseForks>true</reuseForks>
+                                    <reuseForks>false</reuseForks>
                                     <groups>not-parallel</groups>
                                     <forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
                                 </configuration>


(camel) 03/08: CAMEL-20479: allow reusing VM-based broker instances

Posted by or...@apache.org.
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 c06efa3eee20797d1a384829440a52d36b990948
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 10:42:46 2024 +0100

    CAMEL-20479: allow reusing VM-based broker instances
    
    - fixed tests that were incorrectly reusing broker instances
---
 ...tReplyTemporaryRefreshFailureOnStartupTest.java | 51 +++++++++++++++-------
 .../services/AbstractArtemisEmbeddedService.java   | 19 ++++++--
 .../infra/artemis/services/ArtemisVMService.java   | 11 +++++
 3 files changed, 61 insertions(+), 20 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/temp/JmsRequestReplyTemporaryRefreshFailureOnStartupTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/temp/JmsRequestReplyTemporaryRefreshFailureOnStartupTest.java
index cd3c32347f3..6164e47b8f0 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/temp/JmsRequestReplyTemporaryRefreshFailureOnStartupTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/temp/JmsRequestReplyTemporaryRefreshFailureOnStartupTest.java
@@ -26,33 +26,39 @@ import org.apache.camel.ExchangePattern;
 import org.apache.camel.builder.RouteBuilder;
 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.infra.artemis.services.ArtemisVMService;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.TestMethodOrder;
 
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @Tags({ @Tag("not-parallel") })
-public class JmsRequestReplyTemporaryRefreshFailureOnStartupTest extends CamelTestSupport {
+public final class JmsRequestReplyTemporaryRefreshFailureOnStartupTest extends CamelTestSupport {
 
-    @RegisterExtension
-    public ArtemisService service = ArtemisServiceFactory.createVMService();
+    public static ArtemisService service = new ArtemisVMService.ReusableArtemisVMService();
 
-    private String brokerName;
     private final Long recoveryInterval = 1000L;
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
-        brokerName = "test-broker-" + System.currentTimeMillis();
+        service.initialize();
+
         CamelContext camelContext = super.createCamelContext();
 
         ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(service.serviceAddress());
         camelContext.addComponent("jms", jmsComponentAutoAcknowledge(connectionFactory));
 
+        service.shutdown();
+
         return camelContext;
     }
 
@@ -73,26 +79,39 @@ public class JmsRequestReplyTemporaryRefreshFailureOnStartupTest extends CamelTe
         };
     }
 
+    @DisplayName("Test that throws and exception on connection failure")
     @Test
+    @Order(1)
     public void testTemporaryRefreshFailureOnStartup() throws Exception {
         //the first message will fail
         //the second message must be handled
         MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
-        mockEndpoint.expectedMessageCount(1);
+        mockEndpoint.expectedMessageCount(0);
 
         //the first request will return with an error
         //because the broker is not started yet
-        try {
-            template.requestBody("direct:start", "ping");
-        } catch (Exception exception) {
+        Assertions.assertThrows(Exception.class,
+                () -> template.requestBody("direct:start", "ping"));
+
+        mockEndpoint.assertIsSatisfied();
+    }
 
-        }
+    @DisplayName("Test that reconnects after dealing with an exception on connection failure")
+    @Test
+    @Order(2)
+    public void testTemporaryRefreshFailureOnStartupReconnect() throws Exception {
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
+        mockEndpoint.reset();
+        mockEndpoint.expectedMessageCount(1);
 
-        Awaitility.await().untilAsserted(() -> {
-            template.asyncRequestBody("direct:start", "ping");
+        service.initialize();
 
-            MockEndpoint.assertIsSatisfied(context, 10, TimeUnit.SECONDS);
-        });
+        Awaitility.await()
+                .atMost(15, TimeUnit.SECONDS)
+                .untilAsserted(() -> {
+                    Assertions.assertDoesNotThrow(() -> template.requestBody("direct:start", "ping"));
+                });
 
+        mockEndpoint.assertIsSatisfied();
     }
 }
diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
index 740f242752b..526877af8f3 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
@@ -54,8 +54,9 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
     }
 
     /**
-     * This is needed for some tests that check reliability of the components by defining the port in advance, trying to connect
-     * first starting the service later
+     * This is needed for some tests that check reliability of the components by defining the port in advance, trying to
+     * connect first starting the service later
+     *
      * @param port the port to use
      */
     protected AbstractArtemisEmbeddedService(int port) {
@@ -66,8 +67,7 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
     }
 
     private synchronized Configuration configure(int port) {
-        final int brokerId = BROKER_COUNT.intValue();
-        BROKER_COUNT.increment();
+        final int brokerId = computeBrokerId();
 
         // Base configuration
         artemisConfiguration.setSecurityEnabled(false);
@@ -86,6 +86,17 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
         return config;
     }
 
+    /**
+     * Computes the current broker ID to use.
+     *
+     * @return the broker ID to use
+     */
+    protected int computeBrokerId() {
+        final int brokerId = BROKER_COUNT.intValue();
+        BROKER_COUNT.increment();
+        return brokerId;
+    }
+
     private static File createInstance(int brokerId) {
         File instanceDir = null;
         final File target = new File("target");
diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisVMService.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisVMService.java
index c9d070b0fe2..6a916cef8a3 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisVMService.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisVMService.java
@@ -30,6 +30,17 @@ public class ArtemisVMService extends AbstractArtemisEmbeddedService {
 
     private String brokerURL;
 
+    /**
+     * This class should rarely be used. It is intended for some tests that check for reliability operations and require
+     * using the same broker ID between start/stop cycles.
+     */
+    public static class ReusableArtemisVMService extends ArtemisVMService {
+        @Override
+        protected int computeBrokerId() {
+            return 0;
+        }
+    }
+
     @Override
     protected Configuration configure(Configuration configuration, int port, int brokerId) {
         brokerURL = "vm://" + brokerId;


(camel) 08/08: CAMEL-20479: fixed SJMS2 test affected by delaying broker configuration

Posted by or...@apache.org.
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 f3cdc897a94f69b769b713879de2940cc11b26a0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 18:13:56 2024 +0100

    CAMEL-20479: fixed SJMS2 test affected by delaying broker configuration
---
 .../org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
index 654f6f797c1..e7c9985c5cf 100644
--- a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
 public class Sjms2ComponentRestartTest extends CamelTestSupport {
 
     @RegisterExtension
-    public ArtemisService service = ArtemisServiceFactory.createVMService();
+    public static ArtemisService service = ArtemisServiceFactory.createSingletonVMService();
 
     @BindToRegistry("activemqCF")
     private ActiveMQConnectionFactory connectionFactory


(camel) 07/08: CAMEL-20479: fixed CXF test affected by delaying broker configuration

Posted by or...@apache.org.
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 62a3aeb93a585d9d64345f76ac465d9b6d2b5130
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 17:06:12 2024 +0100

    CAMEL-20479: fixed CXF test affected by delaying broker configuration
---
 .../org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
index d696f840607..5d09bcbc801 100644
--- a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
+++ b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
@@ -35,7 +35,8 @@ public class CxfEndpointJMSConsumerTest extends CamelSpringTestSupport {
 
     @RegisterExtension
     private static ArtemisService broker = ArtemisServiceFactory.createVMService();
-    static {
+
+    CxfEndpointJMSConsumerTest() {
         System.setProperty("CxfEndpointJMSConsumerTest.serviceAddress", broker.serviceAddress());
     }
 


(camel) 04/08: CAMEL-20477: stop using a broker with custom configuration for tests that need a common one

Posted by or...@apache.org.
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 7c41c15258d403caf2eb1bd0b323d7f233062311
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 11:19:30 2024 +0100

    CAMEL-20477: stop using a broker with custom configuration for tests that need a common one
---
 .../spring/AbstractSpringJMSITSupport.java         |  2 +-
 .../integration/spring/JmsConsumerShutdownIT.java  | 19 ++++++++++++++++-
 ...kerClientITSupport.java => SpringJMSBasic.java} | 24 +++++-----------------
 .../issues/AdviceWithTransactionIssueIT.java       |  4 ++--
 .../AsyncJmsProducerExceptionInTXManualIT.java     |  4 ++--
 .../spring/issues/FileToJmsIssueIT.java            |  4 ++--
 ...ndToMultipleDestinationsWithSameEndpointIT.java |  4 ++--
 .../spring/issues/JmsSpringValidatorIT.java        |  4 ++--
 .../spring/polling/JmsPollingConsumerSpringIT.java |  4 ++--
 .../spring/tx/JMSNestedTransactionRollbackIT.java  |  4 ++--
 .../integration/spring/JmsConsumerShutdownIT.xml   |  2 +-
 .../{camelBrokerClient.xml => SpringJMSBasic.xml}  |  2 +-
 .../spring/issues/AdviceWithTransactionIssueIT.xml |  2 +-
 .../integration/spring/issues/FileToJmsIssueIT.xml |  2 +-
 .../spring/issues/JmsSpringValidatorIT.xml         |  2 +-
 .../spring/polling/JmsPollingConsumerIT.xml        |  2 +-
 .../spring/tx/JMSNestedTransactionRollbackIT.xml   |  2 +-
 17 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/AbstractSpringJMSITSupport.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/AbstractSpringJMSITSupport.java
index fca0815ed6a..038caf56695 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/AbstractSpringJMSITSupport.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/AbstractSpringJMSITSupport.java
@@ -29,7 +29,7 @@ import org.springframework.context.support.AbstractApplicationContext;
 public abstract class AbstractSpringJMSITSupport extends CamelSpringTestSupport {
 
     @RegisterExtension
-    public static ArtemisService service = ArtemisServiceFactory.createVMService();
+    public static ArtemisService service = ArtemisServiceFactory.createSingletonVMService();
 
     /**
      * Used by spring xml configurations
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
index 88d7eaa5eef..22cafe28d99 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.java
@@ -16,17 +16,30 @@
  */
 package org.apache.camel.component.jms.integration.spring;
 
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilder;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.test.annotation.DirtiesContext;
 
-public class JmsConsumerShutdownIT extends CamelBrokerClientITSupport {
+public final class JmsConsumerShutdownIT extends CamelSpringTestSupport {
+    @RegisterExtension
+    public static ArtemisService service = new ArtemisEmbeddedServiceBuilder()
+            .withCustomConfiguration(configuration -> {
+                AddressSettings addressSettings = new AddressSettings();
+                addressSettings.setMaxSizeMessages(5);
+                configuration.addAddressSetting("#", addressSettings);
+            })
+            .build();
 
     @Produce("jms:start")
     protected ProducerTemplate activemq;
@@ -46,6 +59,10 @@ public class JmsConsumerShutdownIT extends CamelBrokerClientITSupport {
                 "org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.xml");
     }
 
+    public static String getServiceAddress() {
+        return service.serviceAddress();
+    }
+
     @Test
     @DirtiesContext
     void testJmsConsumerShutdownWithMessageInFlight() throws InterruptedException {
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/CamelBrokerClientITSupport.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.java
similarity index 57%
rename from components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/CamelBrokerClientITSupport.java
rename to components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.java
index 4a8c2a9fb71..696bc3e506f 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/CamelBrokerClientITSupport.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.java
@@ -16,27 +16,13 @@
  */
 package org.apache.camel.component.jms.integration.spring;
 
-import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
-import org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilder;
-import org.apache.camel.test.infra.artemis.services.ArtemisService;
-import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Tags;
-import org.junit.jupiter.api.extension.RegisterExtension;
 import org.springframework.context.support.AbstractApplicationContext;
 
-@Tags({ @Tag("not-parallel"), @Tag("spring") })
-public abstract class CamelBrokerClientITSupport extends CamelSpringTestSupport {
-
-    @RegisterExtension
-    public static ArtemisService service = new ArtemisEmbeddedServiceBuilder()
-            .withCustomConfiguration(configuration -> {
-                AddressSettings addressSettings = new AddressSettings();
-                addressSettings.setMaxSizeMessages(50);
-                configuration.addAddressSetting("#", addressSettings);
-            })
-            .build();
+/**
+ * For tests that need a basic Spring camel context without additional configuration
+ */
+public abstract class SpringJMSBasic extends AbstractSpringJMSITSupport {
 
     public static String getServiceAddress() {
         return service.serviceAddress();
@@ -46,6 +32,6 @@ public abstract class CamelBrokerClientITSupport extends CamelSpringTestSupport
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext(
                 new String[] {
-                        "classpath:org/apache/camel/component/jms/integration/spring/camelBrokerClient.xml" });
+                        "classpath:org/apache/camel/component/jms/integration/spring/SpringJMSBasic.xml" });
     }
 }
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.java
index c0cf6f4a1be..d4a2bd7606a 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.java
@@ -18,13 +18,13 @@ package org.apache.camel.component.jms.integration.spring.issues;
 
 import org.apache.camel.builder.AdviceWith;
 import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 
-public class AdviceWithTransactionIssueIT extends CamelBrokerClientITSupport {
+public class AdviceWithTransactionIssueIT extends SpringJMSBasic {
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AsyncJmsProducerExceptionInTXManualIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AsyncJmsProducerExceptionInTXManualIT.java
index 3650ca85555..8b6b5678be2 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AsyncJmsProducerExceptionInTXManualIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/AsyncJmsProducerExceptionInTXManualIT.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jms.integration.spring.issues;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.fail;
  * @see <a href="https://activemq.apache.org/producer-flow-control.html">ActiveMQ flow control</a>
  */
 @Disabled("Cannot reproduce with Artemis")
-class AsyncJmsProducerExceptionInTXManualIT extends CamelBrokerClientITSupport {
+class AsyncJmsProducerExceptionInTXManualIT extends SpringJMSBasic {
 
     @BeforeAll
     static void setSystemProperties() {
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.java
index ce3757b1796..9c5b0868cc5 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.jms.integration.spring.issues;
 
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.junit.jupiter.api.Tag;
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 
 @Tags({ @Tag("not-parallel"), @Tag("spring") })
-public class FileToJmsIssueIT extends CamelBrokerClientITSupport {
+public class FileToJmsIssueIT extends SpringJMSBasic {
 
     @EndpointInject("mock:result")
     protected MockEndpoint result;
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSendToMultipleDestinationsWithSameEndpointIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSendToMultipleDestinationsWithSameEndpointIT.java
index 196d73cb558..311fe5a2099 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSendToMultipleDestinationsWithSameEndpointIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSendToMultipleDestinationsWithSameEndpointIT.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.jms.integration.spring.issues;
 
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.component.jms.JmsConstants;
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 // This one does not run well in parallel: it becomes flaky
 @Tags({ @Tag("not-parallel") })
-public class JmsSendToMultipleDestinationsWithSameEndpointIT extends CamelBrokerClientITSupport {
+public class JmsSendToMultipleDestinationsWithSameEndpointIT extends SpringJMSBasic {
 
     private static final Logger LOG = LoggerFactory.getLogger(JmsSendToMultipleDestinationsWithSameEndpointIT.class);
     private static final String URI = "activemq:queue:JmsSendToMultipleDestinationsWithSameEndpointIT?autoStartup=false";
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.java
index eeb2babeb25..353fb0c6fdf 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.java
@@ -16,13 +16,13 @@
  */
 package org.apache.camel.component.jms.integration.spring.issues;
 
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class JmsSpringValidatorIT extends CamelBrokerClientITSupport {
+public class JmsSpringValidatorIT extends SpringJMSBasic {
 
     @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerSpringIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerSpringIT.java
index e107db29e02..8e004e3dbc9 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerSpringIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerSpringIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Handler;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Tags;
@@ -33,7 +33,7 @@ import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 @Tags({ @Tag("not-parallel"), @Tag("spring") })
-public class JmsPollingConsumerSpringIT extends CamelBrokerClientITSupport {
+public class JmsPollingConsumerSpringIT extends SpringJMSBasic {
 
     @Produce("jms:JmsPollingConsumerSpringITStartConsumer")
     protected ProducerTemplate startConsumer;
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.java
index 4e7d365ad9e..30baa08f17f 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.java
@@ -16,12 +16,12 @@
  */
 package org.apache.camel.component.jms.integration.spring.tx;
 
-import org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport;
+import org.apache.camel.component.jms.integration.spring.SpringJMSBasic;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class JMSNestedTransactionRollbackIT extends CamelBrokerClientITSupport {
+public class JMSNestedTransactionRollbackIT extends SpringJMSBasic {
 
     @Override
     protected ClassPathXmlApplicationContext createApplicationContext() {
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.xml
index 97d4b9dad5a..78ddded96e4 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/JmsConsumerShutdownIT.xml
@@ -26,7 +26,7 @@
 
     <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
         <property name="brokerURL">
-            <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+            <bean class="org.apache.camel.component.jms.integration.spring.JmsConsumerShutdownIT" factory-method="getServiceAddress"/>
         </property>
     </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/camelBrokerClient.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.xml
similarity index 96%
rename from components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/camelBrokerClient.xml
rename to components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.xml
index 2dfe1747531..b130af13328 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/camelBrokerClient.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/SpringJMSBasic.xml
@@ -30,7 +30,7 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/came
 
     <bean class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory" id="activeMQConnectionFactory">
         <property name="brokerURL">
-            <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+            <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
         </property>
     </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.xml
index a5127d00f73..3fb79be2a9a 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/AdviceWithTransactionIssueIT.xml
@@ -30,7 +30,7 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/came
 
   <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
     <property name="brokerURL">
-      <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+      <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
     </property>
   </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.xml
index 292455ff8db..3588d4ff80f 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/FileToJmsIssueIT.xml
@@ -30,7 +30,7 @@
 
     <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
         <property name="brokerURL">
-            <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+            <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
         </property>
     </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.xml
index 8a91e9e725e..e8d2f718123 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/issues/JmsSpringValidatorIT.xml
@@ -25,7 +25,7 @@
 
     <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
         <property name="brokerURL">
-            <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+            <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
         </property>
     </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerIT.xml
index 01d7524f2e9..359094ed408 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/polling/JmsPollingConsumerIT.xml
@@ -30,7 +30,7 @@
 
     <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
         <property name="brokerURL">
-            <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+            <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
         </property>
     </bean>
 
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.xml
index 9867974f90d..4b650678a33 100644
--- a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.xml
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JMSNestedTransactionRollbackIT.xml
@@ -32,7 +32,7 @@
 
   <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
     <property name="brokerURL">
-      <bean class="org.apache.camel.component.jms.integration.spring.CamelBrokerClientITSupport" factory-method="getServiceAddress"/>
+      <bean class="org.apache.camel.component.jms.integration.spring.SpringJMSBasic" factory-method="getServiceAddress"/>
     </property>
   </bean>
 


(camel) 02/08: CAMEL-20479: use a semi-random directory for the broker instance

Posted by or...@apache.org.
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 aec00edea8205aa31d44d3ebbe31040c8a2478d4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 6 09:18:49 2024 +0100

    CAMEL-20479: use a semi-random directory for the broker instance
---
 .../services/AbstractArtemisEmbeddedService.java   | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
index 9e3bb4dd4e0..740f242752b 100644
--- a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
@@ -17,6 +17,7 @@
 package org.apache.camel.test.infra.artemis.services;
 
 import java.io.File;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.LongAdder;
 import java.util.function.Consumer;
@@ -70,7 +71,10 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
 
         // Base configuration
         artemisConfiguration.setSecurityEnabled(false);
-        artemisConfiguration.setBrokerInstance(new File("target", "artemis-" + brokerId));
+
+        final File instanceDir = createInstance(brokerId);
+
+        artemisConfiguration.setBrokerInstance(instanceDir);
         artemisConfiguration.setJMXManagementEnabled(false);
         artemisConfiguration.setMaxDiskUsage(98);
 
@@ -82,6 +86,28 @@ public abstract class AbstractArtemisEmbeddedService implements ArtemisService,
         return config;
     }
 
+    private static File createInstance(int brokerId) {
+        File instanceDir = null;
+        final File target = new File("target");
+        final File brokerDir = new File(target, "artemis");
+        do {
+            final String subPath = getRandomSubPath();
+
+            instanceDir = new File(brokerDir, brokerId + "-" + subPath);
+        } while (instanceDir.exists());
+
+        return instanceDir;
+    }
+
+    private static String getRandomSubPath() {
+        final int size = 12;
+
+        return ThreadLocalRandom.current().ints(97, 122)
+                .limit(size)
+                .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
+                .toString();
+    }
+
     protected abstract Configuration configure(Configuration artemisConfiguration, int port, int brokerId);
 
     public void customConfiguration(Consumer<Configuration> configurator) {