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
The following commit(s) were added to refs/heads/main by this push: new 588ec10128c CAMEL-19539: Replace Thread.sleep in tests (#10822) 588ec10128c is described below commit 588ec10128cbe4a47f9bd473ccebf5b6cec46576 Author: nstefeko <98893136+nstef...@users.noreply.github.com> AuthorDate: Tue Jul 25 18:30:58 2023 +0200 CAMEL-19539: Replace Thread.sleep in tests (#10822) --- .../netty/NettyConsumerClientModeReconnectTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConsumerClientModeReconnectTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConsumerClientModeReconnectTest.java index 743d9c3ca74..9cdcf3ab553 100644 --- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConsumerClientModeReconnectTest.java +++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConsumerClientModeReconnectTest.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.netty; +import java.util.concurrent.TimeUnit; + import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -35,6 +37,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; +import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,15 +68,16 @@ public class NettyConsumerClientModeReconnectTest extends BaseNettyTest { LOG.info(">>> starting Camel route while Netty server is not ready"); context.getRouteController().startRoute("client"); - Thread.sleep(500); - + Awaitility.await().atMost(5, TimeUnit.SECONDS) + .until(receive::isStarted); LOG.info(">>> starting Netty server"); startNettyServer(); - MockEndpoint.assertIsSatisfied(context); LOG.info(">>> routing done"); - Thread.sleep(500); + Awaitility.await().atMost(5, TimeUnit.SECONDS) + .untilAsserted(() -> MockEndpoint.assertIsSatisfied(context)); + } finally { LOG.info(">>> shutting down Netty server"); shutdownServer();