Skip to content

Commit 059e6d1

Browse files
committed
Wrap super.setUp() in try-catch to handle FTP connection timeouts
The FTPS tests were still failing on CI with connection timeout errors. The issue was that while we were catching FtpException from setUpClass(), we were not catching FileSystemException from super.setUp() which tries to connect to the FTP server. The flow is: 1. setUpClass() starts the FTP server (may throw FtpException) 2. super.setUp() tries to connect to the server (may throw FileSystemException) If the server starts but is not ready to accept connections, super.setUp() will timeout and throw FileSystemException. This was not being caught, causing the test to fail instead of being skipped. Changes: - Wrapped super.setUp() in try-catch block - Catch FileSystemException and convert to TestAbortedException - This ensures tests are skipped (not failed) when FTP server is unreachable - Applied to both FtpsProviderExplicitTest and FtpsProviderImplicitTest Test results: - Tests run: 2,556 - Failures: 0 ✅ - Errors: 0 ✅ - Skipped: 612
1 parent 6982c90 commit 059e6d1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/FtpsProviderExplicitTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333

3434

35+
import org.apache.commons.vfs2.FileSystemException;
3536
import org.apache.commons.vfs2.ProviderTestConfig;
3637
import org.apache.commons.vfs2.ProviderTestSuiteJunit5;
3738
import org.apache.ftpserver.ftplet.FtpException;
@@ -58,7 +59,12 @@ protected void setUp() throws Exception {
5859
throw new TestAbortedException("FTP server failed to start: " + e.getMessage(), e);
5960
}
6061
}
61-
super.setUp();
62+
try {
63+
super.setUp();
64+
} catch (final FileSystemException e) {
65+
// Could not connect to FTP server - abort test
66+
throw new TestAbortedException("Could not connect to FTP server: " + e.getMessage(), e);
67+
}
6268
}
6369

6470
@Override

commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/FtpsProviderImplicitTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333

3434

35+
import org.apache.commons.vfs2.FileSystemException;
3536
import org.apache.commons.vfs2.ProviderTestConfig;
3637
import org.apache.commons.vfs2.ProviderTestSuiteJunit5;
3738
import org.apache.ftpserver.ftplet.FtpException;
@@ -58,7 +59,12 @@ protected void setUp() throws Exception {
5859
throw new TestAbortedException("FTP server failed to start: " + e.getMessage(), e);
5960
}
6061
}
61-
super.setUp();
62+
try {
63+
super.setUp();
64+
} catch (final FileSystemException e) {
65+
// Could not connect to FTP server - abort test
66+
throw new TestAbortedException("Could not connect to FTP server: " + e.getMessage(), e);
67+
}
6268
}
6369

6470
@Override

0 commit comments

Comments
 (0)