for (int i = 4; i < 7; i++) {
String name = fileName; while (name.length() < MAX_LENGTH) {
testLongPath (i, name, false);
testLongPath (i, name, true);
name = getNextName(name);
}
}
// test long paths on windows // And these long pathes cannot be handled on Solaris and Mac platforms if (isWindows) {
String name = fileName; while (name.length() < MAX_LENGTH) {
testLongPath (20, name, false);
testLongPath (20, name, true);
name = getNextName(name);
}
}
}
//for getCanonicalPath testing on win32
File fu = new File(pathString + sep + fn.toUpperCase());
if (dirFile.exists()) {
System.err.println("Warning: Test directory structure exists already!"); return;
}
try {
Files.createDirectories(dirFile.toPath());
if (tryAbsolute)
dirFile = new File(dirFile.getCanonicalPath()); if (!dirFile.isDirectory()) thrownew RuntimeException ("File.isDirectory() failed");
f = new File(tPath); if (!f.createNewFile()) { thrownew RuntimeException ("File.createNewFile() failed");
}
if (!f.exists()) thrownew RuntimeException ("File.exists() failed"); if (!f.isFile()) thrownew RuntimeException ("File.isFile() failed"); if (!f.canRead()) thrownew RuntimeException ("File.canRead() failed"); if (!f.canWrite()) thrownew RuntimeException ("File.canWrite() failed");
if (!f.delete()) thrownew RuntimeException ("File.delete() failed");
FileOutputStream fos = new FileOutputStream(f);
fos.write(1);
fos.close();
if (f.length() != 1) thrownew RuntimeException ("File.length() failed"); long time = System.currentTimeMillis(); if (!f.setLastModified(time)) thrownew RuntimeException ("File.setLastModified() failed"); if (f.lastModified() == 0) { thrownew RuntimeException ("File.lastModified() failed");
}
String[] list = dirFile.list(); if (list == null || !fn.equals(list[0])) { thrownew RuntimeException ("File.list() failed");
}
if (isWindows &&
!fu.getCanonicalPath().equals(f.getCanonicalPath())) thrownew RuntimeException ("getCanonicalPath() failed");
char[] cc = tPath.toCharArray();
cc[cc.length-1] = 'B';
File nf = new File(new String(cc)); if (!f.renameTo(nf)) { /*there is a known issue that renameTo fails if (1)thepathisaUNCpathand (2)thepathlengthisbiggerthan1092 sodon'tstopifabovearetrue
*/
String abPath = f.getAbsolutePath(); if (!abPath.startsWith("\\\\") ||
abPath.length() < 1093) { thrownew RuntimeException ("File.renameTo() failed for lenth="
+ abPath.length());
}
} else { if (!nf.canRead()) thrownew RuntimeException ("Renamed file is not readable"); if (!nf.canWrite()) thrownew RuntimeException ("Renamed file is not writable"); if (nf.length() != 1) thrownew RuntimeException ("Renamed file's size is not correct"); if (!nf.renameTo(f)) {
created[0] = nf.getPath();
} /* add a script to test these two if we got a regression later if(!f.setReadOnly()) thrownewRuntimeException("File.setReadOnly()failed"); f.deleteOnExit();
*/
}
} finally { // Clean up for (int i = 0; i < max; i++) {
Path p = (new File(created[i])).toPath(); try {
Files.deleteIfExists(p); // Test if the file is really deleted and wait for 1 second at most for (int j = 0; j < 10 && Files.exists(p); j++) { Thread.sleep(100);
}
} catch (DirectoryNotEmptyException ex) { // Give up the clean-up, let jtreg handle it.
System.err.println("Dir, " + p + ", is not empty"); break;
}
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.