Skip to content

Commit

Permalink
CAMEL-19535 - camel-master: replace Thread.sleep in tests. (apache#13676
Browse files Browse the repository at this point in the history
)

Co-authored-by: Vaishnavi R <[email protected]>
  • Loading branch information
VaishnaviR18 and Vaishnavi R authored Apr 3, 2024
1 parent d2a403c commit 9f118bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions components/camel-master/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
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;
Expand Down Expand Up @@ -87,8 +89,8 @@ public void configure() {

// 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();

Expand Down

0 comments on commit 9f118bf

Please sign in to comment.