You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2006/01/14 17:56:01 UTC

svn commit: r369049 - in /jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io: FileUtilsFileNewerTestCase.java filefilter/FileFilterTestCase.java

Author: scolebourne
Date: Sat Jan 14 08:55:58 2006
New Revision: 369049

URL: http://svn.apache.org/viewcvs?rev=369049&view=rev
Log:
Fix tests to handle last modified date behaviour on Win2k
bug 38130, from Niall Pemberton

Modified:
    jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsFileNewerTestCase.java
    jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsFileNewerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsFileNewerTestCase.java?rev=369049&r1=369048&r2=369049&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsFileNewerTestCase.java (original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsFileNewerTestCase.java Sat Jan 14 08:55:58 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * Copyright 2003-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,11 +67,11 @@
             throw new IllegalStateException("The m_testFile1 should exist");
 
         long fileLastModified = m_testFile1.lastModified();
-        final long ONE_SECOND = 1000;
+        final long TWO_SECOND = 2000;
 
-        testIsFileNewer("one second earlier is not newer" , m_testFile1, fileLastModified + ONE_SECOND, false);
+        testIsFileNewer("two second earlier is not newer" , m_testFile1, fileLastModified + TWO_SECOND, false);
         testIsFileNewer("same time is not newer" , m_testFile1, fileLastModified, false);
-        testIsFileNewer("one second later is newer" , m_testFile1, fileLastModified - ONE_SECOND, true);
+        testIsFileNewer("two second later is newer" , m_testFile1, fileLastModified - TWO_SECOND, true);
     }
 
     /**
@@ -86,7 +86,7 @@
         if (imaginaryFile.exists())
             throw new IllegalStateException("The imaginary File exists");
 
-        testIsFileNewer("imaginary file can be newer" , imaginaryFile, 0, false);
+        testIsFileNewer("imaginary file can be newer" , imaginaryFile, m_testFile2.lastModified(), false);
     }
 
     /**
@@ -118,8 +118,7 @@
         File temporaryFile = m_testFile2;
 
         temporaryFile.setLastModified(time);
-        if (temporaryFile.lastModified() != time)
-            throw new IllegalStateException("The temporary file hasn't the right last modification date");
+        assertEquals("The temporary file hasn't the right last modification date", time, temporaryFile.lastModified());
         assertEquals(description + " - file", wantedResult, FileUtils.isFileNewer(file, temporaryFile));
     }
 

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=369049&r1=369048&r2=369049&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java (original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java Sat Jan 14 08:55:58 2006
@@ -461,7 +461,7 @@
     public void testAgeFilter() throws Exception {
         File oldFile = new File(getTestDirectory(), "old.txt");
         createFile(oldFile, 0);
-        spin();
+        spin(oldFile.lastModified());
         long now = System.currentTimeMillis();
         IOFileFilter filter1 = FileFilterUtils.ageFileFilter(now);
         IOFileFilter filter2 = FileFilterUtils.ageFileFilter(now, true);
@@ -475,7 +475,7 @@
         IOFileFilter filter7 = FileFilterUtils.ageFileFilter(reference);
         IOFileFilter filter8 = FileFilterUtils.ageFileFilter(reference, true);
         IOFileFilter filter9 = FileFilterUtils.ageFileFilter(reference, false);
-        spin();
+        spin(reference.lastModified());
         File newFile = new File(getTestDirectory(), "new.txt");
         createFile(newFile, 0);
 
@@ -523,8 +523,7 @@
         }
     }
 
-    private void spin() {
-        long now = System.currentTimeMillis();
+    private void spin(long now) {
         while (System.currentTimeMillis() <= now);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org