orpiske commented on code in PR #10691: URL: https://github.com/apache/camel/pull/10691#discussion_r1263774971
########## core/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithSimpleExpressionTest.java: ########## @@ -16,108 +16,72 @@ */ package org.apache.camel.processor; -import java.util.concurrent.ExecutorService; +import java.time.Duration; import java.util.concurrent.Executors; +import java.util.concurrent.Phaser; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.apache.camel.ContextTestSupport; -import org.apache.camel.Header; import org.apache.camel.builder.RouteBuilder; +import org.awaitility.Awaitility; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +@Isolated("This test creates a larger thread pool, which may be too much on slower hosts") public class RecipientListWithSimpleExpressionTest extends ContextTestSupport { + private static final Logger LOG = LoggerFactory.getLogger(RecipientListWithSimpleExpressionTest.class); + private final ScheduledExecutorService executors = Executors.newScheduledThreadPool(10); + private final Phaser phaser = new Phaser(50); @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Test - public void testRecipientList() throws Exception { - context.addRoutes(new RouteBuilder() { + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { @Override - public void configure() throws Exception { + public void configure() { from("direct:start").recipientList(simple("mock:${in.header.queue}")); } - }); - context.start(); - template.start(); + }; + } - for (int i = 0; i < 10; i++) { - getMockEndpoint("mock:" + i).expectedMessageCount(50); - } + @BeforeEach + void sendMessages() { + // it may take a little while for the context to start on slower hosts + Awaitility.await().atMost(Duration.ofSeconds(2)).until(() -> context.getUptimeMillis() > 1000); // use concurrent producers to send a lot of messages - ExecutorService executors = Executors.newFixedThreadPool(10); for (int i = 0; i < 50; i++) { - executors.execute(new Runnable() { + final Runnable runOverRunnable = new Runnable() { + int i; + + @Override public void run() { - for (int i = 0; i < 10; i++) { - try { - template.sendBodyAndHeader("direct:start", "Hello " + i, "queue", i); - Thread.sleep(5); - } catch (Exception e) { - // ignore - } + System.out.println("Sending " + i); Review Comment: Leftover ... will remove. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org