Skip to content

Commit

Permalink
Add timeouts to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Jul 27, 2021
1 parent 99af5c3 commit aadb234
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java
Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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();
Expand All @@ -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");
Expand Down

0 comments on commit aadb234

Please sign in to comment.