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/07/02 12:24:43 UTC
(camel) branch main updated: CAMEL-20493: Fixed JMS test that was not reliable concurrent.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 9bf9cd5a092 CAMEL-20493: Fixed JMS test that was not reliable concurrent.
9bf9cd5a092 is described below
commit 9bf9cd5a09295b6d33ca47a39e3d36dabd525970
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 2 14:24:25 2024 +0200
CAMEL-20493: Fixed JMS test that was not reliable concurrent.
---
.../jms/JmsProducerConcurrentWithReplyTest.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerConcurrentWithReplyTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerConcurrentWithReplyTest.java
index 7ee9f388f51..3beee6f0fc8 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerConcurrentWithReplyTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerConcurrentWithReplyTest.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext;
@@ -33,7 +32,7 @@ import org.apache.camel.test.infra.core.DefaultCamelContextExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.Isolated;
@@ -58,12 +57,12 @@ public class JmsProducerConcurrentWithReplyTest extends AbstractJMSTest {
executor.shutdownNow();
}
- @Test
+ @RepeatedTest(50)
public void testNoConcurrentProducers() throws Exception {
doSendMessages(1, 1);
}
- @Test
+ @RepeatedTest(50)
public void testConcurrentProducers() throws Exception {
doSendMessages(200, 5);
}
@@ -73,18 +72,19 @@ public class JmsProducerConcurrentWithReplyTest extends AbstractJMSTest {
getMockEndpoint("mock:result").expectsNoDuplicates(body());
executor = Executors.newFixedThreadPool(poolSize);
- final List<Future<String>> futures = new ArrayList<>();
+ final List<String> data = new ArrayList<>(files);
for (int i = 0; i < files; i++) {
final int index = i;
- Future<String> out = executor.submit(() -> template.requestBody("direct:start", "Message " + index, String.class));
- futures.add(out);
+ executor.submit(() -> {
+ String out = template.requestBody("direct:start", "Message " + index, String.class);
+ data.add(index, out);
+ });
}
MockEndpoint.assertIsSatisfied(context, 20, TimeUnit.SECONDS);
- for (int i = 0; i < futures.size(); i++) {
- Object out = futures.get(i).get(5, TimeUnit.SECONDS);
- assertEquals("Bye Message " + i, out);
+ for (int i = 0; i < data.size(); i++) {
+ assertEquals("Bye Message " + i, data.get(i));
}
}