From cbcf28c32c670046ef2dd205a8789c22041a3374 Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 6 Mar 2009 12:20:29 +0000 Subject: [PATCH] fix broken test on Linux by sleeping --- .../LastModifiedResourceComparatorTests.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/LastModifiedResourceComparatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/LastModifiedResourceComparatorTests.java index 0d2e5c8ae..194027be4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/LastModifiedResourceComparatorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/LastModifiedResourceComparatorTests.java @@ -57,17 +57,21 @@ public class LastModifiedResourceComparatorTests { } @Test - public void testCompareNewWithOldAfterCopy() throws IOException { - File temp1 = File.createTempFile(getClass().getSimpleName(), ".txt"); - temp1.deleteOnExit(); - File temp2 = File.createTempFile(getClass().getSimpleName(), ".txt"); - temp2.deleteOnExit(); - assertTrue(temp1.exists() && temp2.exists()); + public void testCompareNewWithOldAfterCopy() throws Exception { + File temp1 = new File("target/temp1.txt"); + File temp2 = new File("target/temp2.txt"); + if (temp1.exists()) temp1.delete(); + if (temp2.exists()) temp2.delete(); + 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 // copy... 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))); } }