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
commit 7239aff82c984e0794acc4b07417bbfd086e741c Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Fri Jun 3 14:00:15 2022 +0200 (chores) camel-atom: removed usages of Thread.sleep --- components/camel-atom/pom.xml | 5 +++++ .../atom/AtomPollingConsumerIdleMessageTest.java | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/camel-atom/pom.xml b/components/camel-atom/pom.xml index 76651ddbcb2..a472bd9d171 100644 --- a/components/camel-atom/pom.xml +++ b/components/camel-atom/pom.xml @@ -197,5 +197,10 @@ <version>${jetty-version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java index 15bd11b7e32..835bfc762f3 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java @@ -16,9 +16,12 @@ */ package org.apache.camel.component.atom; +import java.time.Duration; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; +import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -33,13 +36,15 @@ import static org.junit.jupiter.api.Assertions.assertNull; public class AtomPollingConsumerIdleMessageTest extends CamelTestSupport { @Test - void testConsumeIdleMessages() throws Exception { - Thread.sleep(110); - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(2); - assertMockEndpointsSatisfied(); - assertNull(mock.getExchanges().get(0).getIn().getBody()); - assertNull(mock.getExchanges().get(1).getIn().getBody()); + void testConsumeIdleMessages() { + Awaitility.await().atMost(Duration.ofMillis(500)).untilAsserted(() -> { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(2); + assertMockEndpointsSatisfied(); + + assertNull(mock.getExchanges().get(0).getIn().getBody()); + assertNull(mock.getExchanges().get(1).getIn().getBody()); + }); } @Override