commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/io/src/test/org/apache/commons/io FileUtilsTestCase.java
Date Sat, 24 Jul 2004 08:41:00 GMT
scolebourne    2004/07/24 01:41:00

  Modified:    io/src/test/org/apache/commons/io FileUtilsTestCase.java
  Log:
  Fix test case for Win98
  
  Revision  Changes    Path
  1.23      +13 -7     jakarta-commons/io/src/test/org/apache/commons/io/FileUtilsTestCase.java
  
  Index: FileUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/io/src/test/org/apache/commons/io/FileUtilsTestCase.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- FileUtilsTestCase.java	15 Jul 2004 09:49:53 -0000	1.22
  +++ FileUtilsTestCase.java	24 Jul 2004 08:41:00 -0000	1.23
  @@ -21,6 +21,7 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.net.URL;
  +import java.util.GregorianCalendar;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -456,19 +457,24 @@
           if (file.exists()) {
               file.delete();
           }
  -        assertTrue("Prerequisite failed, test file exists", !file.exists());
  +        assertTrue("Bad test: test file still exists", !file.exists());
           FileUtils.touch(file);
  -        assertTrue("FileUtils.touch() created file.", file.exists());
  +        assertTrue("FileUtils.touch() created file", file.exists());
           FileOutputStream out = new FileOutputStream(file) ;
           assertEquals("Created empty file.", 0, file.length());
           out.write(0) ;
           out.close();
  -        assertEquals("Wrote one byte to file.", 1, file.length());
  -        file.setLastModified(0) ;
  -        assertEquals("Set lastModified to 0.", 0, file.lastModified());
  +        assertEquals("Wrote one byte to file", 1, file.length());
  +        long y2k = new GregorianCalendar(2000, 0, 1).getTime().getTime();
  +        boolean res = file.setLastModified(y2k);  // 0L fails on Win98
  +        assertEquals("Bad test: set lastModified failed", true, res);
  +        assertEquals("Bad test: set lastModified set incorrect value", y2k, file.lastModified());
  +        long now = System.currentTimeMillis();
           FileUtils.touch(file) ;
           assertEquals("FileUtils.touch() didn't empty the file.", 1, file.length());
  -        assertFalse("FileUtils.touch() changed lastModified.", 0 == file.lastModified())
;        
  +        assertEquals("FileUtils.touch() changed lastModified", false, y2k == file.lastModified());
  +        assertEquals("FileUtils.touch() changed lastModified to more than now-3s", true,
file.lastModified() >= (now - 3000));
  +        assertEquals("FileUtils.touch() changed lastModified to less than now+3s", true,
file.lastModified() <= (now + 3000));
       }
   
       public void testReadFileToString() throws Exception {
  
  
  

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


Mime
View raw message