diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java index a8fa8c2f..cce37aaf 100644 --- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java @@ -368,9 +368,7 @@ void copyIfModifiedWhenSourceIsNewer() throws Exception { // Place destination File destination = new File(getTestDirectory() + "/temp/copy1.txt"); FileUtils.copyFile(testFile1, destination); - - // Make sure source is newer - reallySleep(1000); + destination.setLastModified(System.currentTimeMillis() - 10_000L); // Place source File source = new File(getTestDirectory(), "copy1.txt"); @@ -390,9 +388,7 @@ void copyIfModifiedWhenSourceIsOlder() throws Exception { // Place source File source = new File(getTestDirectory() + "copy1.txt"); FileUtils.copyFile(testFile1, source); - - // Make sure destination is newer - reallySleep(1000); + source.setLastModified(System.currentTimeMillis() - 10_000L); // Place destination File destination = new File(getTestDirectory(), "/temp/copy1.txt"); @@ -1338,18 +1334,4 @@ void createTempFile() { last = current; } } - - /** - * Because windows(tm) quite frequently sleeps less than the advertised time - * - * @param time The amount of time to sleep - */ - private void reallySleep(int time) throws InterruptedException { - long until = System.currentTimeMillis() + time; - Thread.sleep(time); - while (System.currentTimeMillis() < until) { - Thread.sleep(time / 10); - Thread.yield(); - } - } }