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 9f118bfcb19 CAMEL-19535 - camel-master: replace Thread.sleep in tests. 
(#13676)
9f118bfcb19 is described below

commit 9f118bfcb1954528c943b147cc3cc9e3fff6cd8b
Author: Vaishnavi R <66722776+vaishnavi...@users.noreply.github.com>
AuthorDate: Wed Apr 3 10:07:51 2024 +0530

    CAMEL-19535 - camel-master: replace Thread.sleep in tests. (#13676)
    
    Co-authored-by: Vaishnavi R <v...@var-thinkpadp1gen4i.remote.csb>
---
 components/camel-master/pom.xml                                     | 6 ++++++
 .../java/org/apache/camel/component/master/MasterComponentTest.java | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/components/camel-master/pom.xml b/components/camel-master/pom.xml
index ce6dc0ee244..0562969a959 100644
--- a/components/camel-master/pom.xml
+++ b/components/camel-master/pom.xml
@@ -52,6 +52,12 @@
             <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <version>${awaitility-version}</version>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 </project>
diff --git 
a/components/camel-master/src/test/java/org/apache/camel/component/master/MasterComponentTest.java
 
b/components/camel-master/src/test/java/org/apache/camel/component/master/MasterComponentTest.java
index 4bb0db10b61..5fa7240cf08 100644
--- 
a/components/camel-master/src/test/java/org/apache/camel/component/master/MasterComponentTest.java
+++ 
b/components/camel-master/src/test/java/org/apache/camel/component/master/MasterComponentTest.java
@@ -28,6 +28,8 @@ import java.util.stream.IntStream;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.file.cluster.FileLockClusterService;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,8 +89,8 @@ public class MasterComponentTest {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
-            context.start();
+            
Awaitility.await().pollDelay(ThreadLocalRandom.current().nextInt(500), 
TimeUnit.MILLISECONDS)
+                    .untilAsserted(() -> 
Assertions.assertDoesNotThrow(context::start));
 
             contextLatch.await();
 

Reply via email to