This is an automated email from the ASF dual-hosted git repository.

apupier 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 0902d342d4d2 CAMEL-25881: camel-mina-sftp, camel-ftp - fix flaky 
SftpSimpleConsumeNoStartingDirIT
0902d342d4d2 is described below

commit 0902d342d4d2c91c8bff598ead21d4ea1ab07bbd
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Nov 9 11:36:21 2026 +0100

    CAMEL-25881: camel-mina-sftp, camel-ftp - fix flaky 
SftpSimpleConsumeNoStartingDirIT
    
    Remove arbitrary delay=10000 from the SFTP consumer URI, which caused 
MockEndpoint.assertIsSatisfied(context) to time out when the first poll was 
delayed under heavy test execution load.
    
    Also ensure test files are cleaned up in a finally block.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../SftpSimpleConsumeNoStartingDirIT.java          | 25 ++++++++++++----------
 .../sftp/SftpSimpleConsumeNoStartingDirIT.java     | 25 ++++++++++++----------
 2 files changed, 28 insertions(+), 22 deletions(-)

diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
index 4ba566a5e61d..c5213e0f9e22 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
@@ -30,20 +30,23 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
 
     @Test
     public void testSftpSimpleConsume() throws Exception {
-        // create files using regular file
         File file = new File("a.txt");
-        FileOutputStream fos = new FileOutputStream(file, false);
-        fos.write("ABC".getBytes());
-        fos.close();
-
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
+        try {
+            // create files using regular file
+            try (FileOutputStream fos = new FileOutputStream(file, false)) {
+                fos.write("ABC".getBytes());
+            }
 
-        context.getRouteController().startRoute("foo");
+            MockEndpoint mock = getMockEndpoint("mock:result");
+            mock.expectedMessageCount(1);
 
-        MockEndpoint.assertIsSatisfied(context);
+            context.getRouteController().startRoute("foo");
 
-        FileUtil.deleteFile(file);
+            MockEndpoint.assertIsSatisfied(context);
+        } finally {
+            FileUtil.deleteFile(file);
+            FileUtil.deleteFile(new File(".camel/a.txt"));
+        }
     }
 
     @Override
@@ -52,7 +55,7 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
             @Override
             public void configure() {
                 from("sftp://localhost:{{ftp.server.port}}/";
-                     + 
"?fileName=a.txt&username=admin&password=admin&delay=10000&disconnect=true&knownHostsFile="
+                     + 
"?fileName=a.txt&username=admin&password=admin&disconnect=true&knownHostsFile="
                      + service.getKnownHostsFile()).routeId("foo")
                         .autoStartup(false).to("log:result", "mock:result");
             }
diff --git 
a/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpSimpleConsumeNoStartingDirIT.java
 
b/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpSimpleConsumeNoStartingDirIT.java
index 99ee1d866fbe..dfd7189e2157 100644
--- 
a/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpSimpleConsumeNoStartingDirIT.java
+++ 
b/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpSimpleConsumeNoStartingDirIT.java
@@ -30,20 +30,23 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
 
     @Test
     public void testSftpSimpleConsume() throws Exception {
-        // create files using regular file
         File file = new File("a.txt");
-        FileOutputStream fos = new FileOutputStream(file, false);
-        fos.write("ABC".getBytes());
-        fos.close();
-
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
+        try {
+            // create files using regular file
+            try (FileOutputStream fos = new FileOutputStream(file, false)) {
+                fos.write("ABC".getBytes());
+            }
 
-        context.getRouteController().startRoute("foo");
+            MockEndpoint mock = getMockEndpoint("mock:result");
+            mock.expectedMessageCount(1);
 
-        MockEndpoint.assertIsSatisfied(context);
+            context.getRouteController().startRoute("foo");
 
-        FileUtil.deleteFile(file);
+            MockEndpoint.assertIsSatisfied(context);
+        } finally {
+            FileUtil.deleteFile(file);
+            FileUtil.deleteFile(new File(".camel/a.txt"));
+        }
     }
 
     @Override
@@ -52,7 +55,7 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
             @Override
             public void configure() {
                 from("mina-sftp://localhost:{{ftp.server.port}}/";
-                     + 
"?fileName=a.txt&username=admin&password=admin&delay=10000&disconnect=true&knownHostsFile="
+                     + 
"?fileName=a.txt&username=admin&password=admin&disconnect=true&knownHostsFile="
                      + service.getKnownHostsFile()).routeId("foo")
                         .autoStartup(false).to("log:result", "mock:result");
             }

Reply via email to