commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r919101 - in /commons/proper/io/trunk/src: java/org/apache/commons/io/FileUtils.java test/org/apache/commons/io/FileUtilsTestCase.java
Date Thu, 04 Mar 2010 18:07:31 GMT
Author: sebb
Date: Thu Mar  4 18:07:30 2010
New Revision: 919101

URL: http://svn.apache.org/viewvc?rev=919101&view=rev
Log:
IO-231 FileUtils generate wrong exception message in isFileNewer method

Modified:
    commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java

Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java?rev=919101&r1=919100&r2=919101&view=diff
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java (original)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java Thu Mar  4 18:07:30
2010
@@ -1596,7 +1596,7 @@
         }
         if (!reference.exists()) {
             throw new IllegalArgumentException("The reference file '"
-                    + file + "' doesn't exist");
+                    + reference + "' doesn't exist");
         }
         return isFileNewer(file, reference.lastModified());
     }
@@ -1663,7 +1663,7 @@
         }
         if (!reference.exists()) {
             throw new IllegalArgumentException("The reference file '"
-                    + file + "' doesn't exist");
+                    + reference + "' doesn't exist");
         }
         return isFileOlder(file, reference.lastModified());
     }

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java?rev=919101&r1=919100&r2=919101&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java Thu Mar
 4 18:07:30 2010
@@ -542,6 +542,14 @@
         assertTrue("New File - Newer - Date", FileUtils.isFileNewer(newFile, date));
         assertTrue("New File - Newer - Mili", FileUtils.isFileNewer(newFile, now));
         assertFalse("Invalid - Newer - File", FileUtils.isFileNewer(invalidFile, reference));
+        final String invalidFileName = invalidFile.getName();
+        try {
+            FileUtils.isFileNewer(newFile, invalidFile);
+            fail("Should have cause IllegalArgumentException");
+        } catch (IllegalArgumentException iae){
+            final String message = iae.getMessage();
+            assertTrue("Message should contain: "+invalidFileName+ " but was: "+message,message.contains(invalidFileName));
+        }
         
         // Test isFileOlder()
         assertTrue("Old File - Older - File", FileUtils.isFileOlder(oldFile, reference));
@@ -551,6 +559,13 @@
         assertFalse("New File - Older - Date", FileUtils.isFileOlder(newFile, date));
         assertFalse("New File - Older - Mili", FileUtils.isFileOlder(newFile, now));
         assertFalse("Invalid - Older - File", FileUtils.isFileOlder(invalidFile, reference));
+        try {
+            FileUtils.isFileOlder(newFile, invalidFile);
+            fail("Should have cause IllegalArgumentException");
+        } catch (IllegalArgumentException iae){
+            final String message = iae.getMessage();
+            assertTrue("Message should contain: "+invalidFileName+ " but was: "+message,message.contains(invalidFileName));
+        }
         
         
         // ----- Test isFileNewer() exceptions -----



Mime
View raw message