You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/10 09:31:59 UTC

[camel] branch main updated: CAMEL-19684: fixed FileWatchComponentTest test (#11063)

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 5a11f33a6fb CAMEL-19684: fixed FileWatchComponentTest test (#11063)
5a11f33a6fb is described below

commit 5a11f33a6fb4510fb7b4c388ff6ce0a0e635258e
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Aug 10 11:31:53 2023 +0200

    CAMEL-19684: fixed FileWatchComponentTest test (#11063)
---
 components/camel-file-watch/pom.xml                           |  7 +++++++
 .../camel/component/file/watch/FileWatchComponentTest.java    | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/components/camel-file-watch/pom.xml b/components/camel-file-watch/pom.xml
index 81cfb42e06b..e9d5f4dc093 100644
--- a/components/camel-file-watch/pom.xml
+++ b/components/camel-file-watch/pom.xml
@@ -49,5 +49,12 @@
             <artifactId>camel-test-spring-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-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java
index 22765424c11..fc0c3696d40 100644
--- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java
+++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java
@@ -22,10 +22,12 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardOpenOption;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.file.watch.constants.FileEventEnum;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.awaitility.Awaitility;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -92,8 +94,13 @@ public class FileWatchComponentTest extends FileWatchComponentTestBase {
         createFile(b.toFile(), "inB.txt");
         createFile(b.toFile(), "inB.java");
 
-        all.expectedMessageCount(8); // 2 directories, 6 files
-        all.assertIsSatisfied();
+        /*
+        On systems with slow IO, the time of creation and the time of notification may not be the reliably aligned (i.e; the
+        notification may be sent while the creation is still in progress).
+        As such, we have to be lenient checking for the expected number of exchanges received.
+         */
+        all.expectedMinimumMessageCount(8); // 2 directories, 6 files
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> all.assertIsSatisfied());
 
         onlyTxtAnywhere.expectedMessageCount(3); // 3 txt files
         onlyTxtAnywhere.assertIsSatisfied();