commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject cvs commit: jakarta-commons/io/src/test/org/apache/commons/io FileUtilsTestCase.java
Date Fri, 12 Mar 2004 22:22:25 GMT
jeremias    2004/03/12 14:22:25

  Modified:    io/src/test/org/apache/commons/io FileUtilsTestCase.java
  Log:
  File copy operations now preserve the file date by default. An additional copyFile variant
enables to disable this feature.
  Suggested by: Craig Doremus <craig.at.maine.com> in Bugzilla #27615
  
  Revision  Changes    Path
  1.13      +38 -1     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- FileUtilsTestCase.java	12 Mar 2004 21:44:47 -0000	1.12
  +++ FileUtilsTestCase.java	12 Mar 2004 22:22:25 -0000	1.13
  @@ -249,16 +249,41 @@
   
       public void testCopyFile1() throws Exception {
           File destination = new File(getTestDirectory(), "copy1.txt");
  +        
  +        Thread.sleep(200); //This is to slow things down so we can catch if 
  +                           //the lastModified date is not ok
  +        
           FileUtils.copyFile(testFile1, destination);
           assertTrue("Check Exist", destination.exists());
           assertTrue("Check Full copy", destination.length() == testFile1Size);
  +        assertTrue("Check last modified date preserved", 
  +            testFile1.lastModified() == destination.lastModified());    
       }
   
       public void testCopyFile2() throws Exception {
           File destination = new File(getTestDirectory(), "copy2.txt");
  +        
  +        Thread.sleep(200); //This is to slow things down so we can catch if 
  +                           //the lastModified date is not ok
  +        
           FileUtils.copyFile(testFile1, destination);
           assertTrue("Check Exist", destination.exists());
           assertTrue("Check Full copy", destination.length() == testFile2Size);
  +        assertTrue("Check last modified date preserved", 
  +            testFile1.lastModified() == destination.lastModified());    
  +    }
  +
  +    public void testCopyFile2WithoutFileDatePreservation() throws Exception {
  +        File destination = new File(getTestDirectory(), "copy2.txt");
  +        
  +        Thread.sleep(200); //This is to slow things down so we can catch if 
  +                           //the lastModified date is not ok
  +        
  +        FileUtils.copyFile(testFile1, destination, false);
  +        assertTrue("Check Exist", destination.exists());
  +        assertTrue("Check Full copy", destination.length() == testFile2Size);
  +        assertTrue("Check last modified date modified", 
  +            testFile1.lastModified() != destination.lastModified());    
       }
   
       // forceDelete
  @@ -286,9 +311,15 @@
           if (!directory.exists())
               directory.mkdirs();
           File destination = new File(directory, testFile1.getName());
  +        
  +        Thread.sleep(200); //This is to slow things down so we can catch if 
  +                           //the lastModified date is not ok
  +        
           FileUtils.copyFileToDirectory(testFile1, directory);
           assertTrue("Check Exist", destination.exists());
           assertTrue("Check Full copy", destination.length() == testFile1Size);
  +        assertTrue("Check last modified date preserved", 
  +            testFile1.lastModified() == destination.lastModified());    
       }
   
       public void testCopyFile2ToDir() throws Exception {
  @@ -296,9 +327,15 @@
           if (!directory.exists())
               directory.mkdirs();
           File destination = new File(directory, testFile1.getName());
  +        
  +        Thread.sleep(200); //This is to slow things down so we can catch if 
  +                           //the lastModified date is not ok
  +        
           FileUtils.copyFileToDirectory(testFile1, directory);
           assertTrue("Check Exist", destination.exists());
           assertTrue("Check Full copy", destination.length() == testFile2Size);
  +        assertTrue("Check last modified date preserved", 
  +            testFile1.lastModified() == destination.lastModified());    
       }
   
       // forceDelete
  
  
  

---------------------------------------------------------------------
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