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/12/29 13:24:37 UTC

svn commit: r490988 - /jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java

Author: scolebourne
Date: Fri Dec 29 04:24:36 2006
New Revision: 490988

URL: http://svn.apache.org/viewvc?view=rev&rev=490988
Log:
IO-107 - Increase test robustness for openOutputStream

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

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java?view=diff&rev=490988&r1=490987&r2=490988
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java (original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java Fri Dec 29 04:24:36 2006
@@ -119,11 +119,14 @@
     public void test_openOutputStream_existsButIsDirectory() throws Exception {
         File directory = new File(getTestDirectory(), "subdir");
         directory.mkdirs();
+        FileOutputStream out = null;
         try {
-            FileUtils.openOutputStream(directory);
+            out = FileUtils.openOutputStream(directory);
             fail();
         } catch (IOException ioe) {
             // expected
+        } finally {
+            IOUtils.closeQuietly(out);
         }
     }
 
@@ -140,12 +143,23 @@
     }
 
     public void test_openOutputStream_notExistsCannotCreate() throws Exception {
-        File file = new File(getTestDirectory(), "a/:#$!/test.txt");  // empty path segment is bad directory name
+        // according to Wikipedia, most filing systems have a 256 limit on filename
+        String longStr =
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" +
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" +
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" +
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" +
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" +
+            "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz";  // 300 chars
+        File file = new File(getTestDirectory(), "a/" + longStr + "/test.txt");
+        FileOutputStream out = null;
         try {
-            FileUtils.openOutputStream(file);
+            out = FileUtils.openOutputStream(file);
             fail();
         } catch (IOException ioe) {
             // expected
+        } finally {
+            IOUtils.closeQuietly(out);
         }
     }
 



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