Skip to content
Permalink
Browse files
Add timeouts to tests
  • Loading branch information
sebbASF committed Jul 27, 2021
1 parent 99af5c3 commit aadb2342bfdce6ca9881a2815d9276a7a0b23c72
Showing 1 changed file with 11 additions and 9 deletions.
@@ -91,6 +91,8 @@ private static String getTestHomeDirectory() {
return System.getProperty("test.basedir", "target/test-classes/org/apache/commons/net/test-data");
}

private static final long TEST_TIMEOUT = 5000; // individual test timeout

private static final long startTime = System.nanoTime();
private static void trace(String msg) {
System.err.println(msg + " " + (System.nanoTime() - startTime));
@@ -232,7 +234,7 @@ private void retrieveFile(final String pathname) throws SocketException, IOExcep
}
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testHasFeature() throws SocketException, IOException {
trace(">>testHasFeature");
loginClient().disconnect();
@@ -252,34 +254,34 @@ private void testListFiles(final String pathname) throws SocketException, IOExce
}
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testListFilesPathNameEmpty() throws SocketException, IOException {
trace(">>testListFilesPathNameEmpty");
testListFiles("");
trace("<<testListFilesPathNameEmpty");
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testListFilesPathNameJunk() throws SocketException, IOException {
trace(">>testListFilesPathNameJunk");
testListFiles(" Junk ");
trace("<<testListFilesPathNameJunk");
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testListFilesPathNameNull() throws SocketException, IOException {
trace(">>testListFilesPathNameNull");
testListFiles(null);
trace("<<testListFilesPathNameNull");
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testListFilesPathNameRoot() throws SocketException, IOException {
trace(">>testListFilesPathNameRoot");
testListFiles("/");
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testMdtmCalendar() throws SocketException, IOException {
trace(">>testMdtmCalendar");
testMdtmCalendar("/file.txt");
@@ -322,7 +324,7 @@ private void testMdtmFile(final String pathname) throws SocketException, IOExcep
}
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testMdtmInstant() throws SocketException, IOException {
trace(">>testMdtmInstant");
testMdtmInstant("/file.txt");
@@ -345,7 +347,7 @@ private void testMdtmInstant(final String pathname) throws SocketException, IOEx
}
}

@Test
@Test(timeout = TEST_TIMEOUT)
public void testOpenClose() throws SocketException, IOException {
trace(">>testOpenClose");
final FTPSClient ftpsClient = loginClient();
@@ -360,7 +362,7 @@ public void testOpenClose() throws SocketException, IOException {
trace("<<testOpenClose");
}

// @Test looks like this may be the hang?
@Test(timeout = TEST_TIMEOUT)
public void testRetrieveFilePathNameRoot() throws SocketException, IOException {
trace(">>testRetrieveFilePathNameRoot");
retrieveFile("/file.txt");

0 comments on commit aadb234

Please sign in to comment.