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 90e696a5615d CAMEL-23220: Replace Thread.sleep() with Awaitility in
camel-atom tests (#22875)
90e696a5615d is described below
commit 90e696a5615d206d2ff5815d3c0609baf6de0b41
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Apr 30 18:46:02 2026 +0200
CAMEL-23220: Replace Thread.sleep() with Awaitility in camel-atom tests
(#22875)
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../component/atom/AtomGoodBlogDefaultIdempotencyTest.java | 13 +++++++------
...mGoodBlogsRepositoryItempotencyCustomRepositoryTest.java | 5 +----
.../atom/AtomGoodBlogsRepositoryItempotencyTest.java | 5 +----
3 files changed, 9 insertions(+), 14 deletions(-)
diff --git
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogDefaultIdempotencyTest.java
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogDefaultIdempotencyTest.java
index e1bcb7e34cd2..e5269968caee 100644
---
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogDefaultIdempotencyTest.java
+++
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogDefaultIdempotencyTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.atom;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -24,6 +26,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -84,13 +88,10 @@ public class AtomGoodBlogDefaultIdempotencyTest {
// Get the mock endpoint
MockEndpoint mock = context.getEndpoint("mock:result",
MockEndpoint.class);
- Thread.sleep(5000);
-
- // There should be at least two good blog entries from the feed
- mock.expectedMessageCount(7);
- // Assert
- mock.assertIsSatisfied();
+ // Wait for the polling consumer to read all 7 entries from the feed
+ await().atMost(10, TimeUnit.SECONDS)
+ .untilAsserted(() -> assertEquals(7,
mock.getReceivedCounter()));
// stop Camel after use
context.stop();
diff --git
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyCustomRepositoryTest.java
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyCustomRepositoryTest.java
index af34c9b695f7..96897ca922e1 100644
---
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyCustomRepositoryTest.java
+++
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyCustomRepositoryTest.java
@@ -101,11 +101,8 @@ public class
AtomGoodBlogsRepositoryItempotencyCustomRepositoryTest {
// There should be at only three good blog entries, not already in
customRepository
mock.expectedMessageCount(3);
- // Make sure that the component has time for several reads
- Thread.sleep(3000);
-
// Assert
- mock.assertIsSatisfied(3000);
+ mock.assertIsSatisfied(10000);
// stop Camel after use
context.stop();
diff --git
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyTest.java
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyTest.java
index 78b66e44fe25..73d14254b017 100644
---
a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyTest.java
+++
b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsRepositoryItempotencyTest.java
@@ -94,11 +94,8 @@ public class AtomGoodBlogsRepositoryItempotencyTest {
// There should be at least two good blog entries from the feed
mock.expectedMessageCount(7);
- // Make sure that the component has time for several reads
- Thread.sleep(3000);
-
// Assert
- mock.assertIsSatisfied(3000);
+ mock.assertIsSatisfied(10000);
// stop Camel after use
context.stop();