fix broken test on Linux by sleeping

This commit is contained in:
dsyer
2009-03-06 12:20:29 +00:00
parent f814c8b4be
commit cbcf28c32c

View File

@@ -57,17 +57,21 @@ public class LastModifiedResourceComparatorTests {
} }
@Test @Test
public void testCompareNewWithOldAfterCopy() throws IOException { public void testCompareNewWithOldAfterCopy() throws Exception {
File temp1 = File.createTempFile(getClass().getSimpleName(), ".txt"); File temp1 = new File("target/temp1.txt");
temp1.deleteOnExit(); File temp2 = new File("target/temp2.txt");
File temp2 = File.createTempFile(getClass().getSimpleName(), ".txt"); if (temp1.exists()) temp1.delete();
temp2.deleteOnExit(); if (temp2.exists()) temp2.delete();
assertTrue(temp1.exists() && temp2.exists()); temp1.getParentFile().mkdirs();
temp2.createNewFile();
assertTrue(!temp1.exists() && temp2.exists());
// For Linux sleep here otherwise files show same
// modified date
Thread.sleep(1000);
// Need to explicitly ask not to preserve the last modified date when we // Need to explicitly ask not to preserve the last modified date when we
// copy... // copy...
FileUtils.copyFile(new File("pom.xml"), temp1, false); FileUtils.copyFile(new File("pom.xml"), temp1, false);
// TODO: fails on Linux. Remove this whole class? assertEquals(1, comparator.compare(new FileSystemResource(temp1), new FileSystemResource(temp2)));
// assertEquals(1, comparator.compare(new FileSystemResource(temp1), new FileSystemResource(temp2)));
} }
} }