Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions src/test/java/org/codehaus/plexus/util/FileUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,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");
Expand All @@ -383,9 +381,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");
Expand Down Expand Up @@ -1342,18 +1338,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();
}
}
}
Loading