This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push: new 381265c Enable tests previously dependent on sleep 381265c is described below commit 381265c3ebd6fe1bacbd45c4e84b467e68a9ba90 Author: Sebb <s...@apache.org> AuthorDate: Fri Aug 7 21:39:04 2020 +0100 Enable tests previously dependent on sleep --- .../org/apache/commons/io/FileUtilsTestCase.java | 25 ++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index 31cb7af..cc8ed7d 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -1679,23 +1679,16 @@ public class FileUtilsTestCase { } final File destination = new File(directory, testFile1.getName()); - //Thread.sleep(LAST_MODIFIED_DELAY); - //This is to slow things down so we can catch if - //the lastModified date is not ok + backDateFile10Minutes(testFile1); FileUtils.copyFileToDirectory(testFile1, directory); assertTrue(destination.exists(), "Check Exist"); assertEquals(testFile1Size, destination.length(), "Check Full copy"); - /* disabled: Thread.sleep doesn't work reliantly for this case - assertTrue("Check last modified date preserved", - testFile1.lastModified() == destination.lastModified());*/ + assertEquals(testFile1.lastModified(), destination.lastModified(), "Check last modified date preserved"); - try { - FileUtils.copyFileToDirectory(destination, directory); - fail("Should not be able to copy a file into the same directory as itself"); - } catch (final IOException ioe) { - //we want that, cannot copy to the same directory as the original file - } + assertThrows(IOException.class, + () -> FileUtils.copyFileToDirectory(destination, directory), + "Should not be able to copy a file into the same directory as itself"); } @Test @@ -1706,16 +1699,12 @@ public class FileUtilsTestCase { } final File destination = new File(directory, testFile1.getName()); - //Thread.sleep(LAST_MODIFIED_DELAY); - //This is to slow things down so we can catch if - //the lastModified date is not ok + backDateFile10Minutes(testFile1); FileUtils.copyFileToDirectory(testFile1, directory); assertTrue(destination.exists(), "Check Exist"); assertEquals(testFile2Size, destination.length(), "Check Full copy"); - /* disabled: Thread.sleep doesn't work reliantly for this case - assertTrue("Check last modified date preserved", - testFile1.lastModified() == destination.lastModified());*/ + assertEquals(testFile1.lastModified(), destination.lastModified(), "Check last modified date preserved"); } // forceDelete