harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r477184 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
Date Mon, 20 Nov 2006 14:12:31 GMT
Author: pyang
Date: Mon Nov 20 06:12:30 2006
New Revision: 477184

URL: http://svn.apache.org/viewvc?view=rev&rev=477184
Log:
Apply test patch for HARMONY-2157 ([classlib][luni]not able to make a directory whose length
is greater than 248)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java?view=diff&rev=477184&r1=477183&r2=477184
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
Mon Nov 20 06:12:30 2006
@@ -1770,9 +1770,10 @@
 	}
 
 	/**
+	 * @throws IOException 
 	 * @tests java.io.File#mkdir()
 	 */
-	public void test_mkdir() {
+	public void test_mkdir() throws IOException {
 		// Test for method boolean java.io.File.mkdir()
 
 		String base = System.getProperty("user.dir");
@@ -1790,16 +1791,31 @@
 				dirExists = false;
 			}
 		}
-		try {
-			assertTrue("mkdir failed", dir.mkdir() && dir.exists());
-		} finally {
-			dir.delete();
-		}
+		
+		assertTrue("mkdir failed", dir.mkdir() && dir.exists());
+        dir.deleteOnExit();
+
+        // Test make a long path
+        String longDirName = "abcdefghijklmnopqrstuvwx";// 24 chars
+        StringBuilder sb = new StringBuilder(dir + File.separator);
+        while (dir.getCanonicalPath().length() < 256 - longDirName.length()) {
+            sb.append(longDirName + File.separator);
+            dir = new File(sb.toString());
+            assertTrue("mkdir failed", dir.mkdir() && dir.exists());
+            dir.deleteOnExit();
+        }
+        while (dir.getCanonicalPath().length() < 256) {
+            sb.append(0);
+            dir = new File(sb.toString());
+            assertTrue("mkdir " + dir.getCanonicalPath().length() + " failed",
+                    dir.mkdir() && dir.exists());
+            dir.deleteOnExit();
+        }
 	}
 
 	/**
-	 * @tests java.io.File#mkdirs()
-	 */
+     * @tests java.io.File#mkdirs()
+     */
 	public void test_mkdirs() {
 		// Test for method boolean java.io.File.mkdirs()
 



Mime
View raw message