HADOOP-9791. Merging change r1524631 from trunk
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1524633 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ce1a859a8
commit
fe3e796ed5
|
@ -81,6 +81,9 @@ Release 2.3.0 - UNRELEASED
|
||||||
HADOOP-9929. Insufficient permissions for a path reported as File Not
|
HADOOP-9929. Insufficient permissions for a path reported as File Not
|
||||||
Found. (Contributed by Colin Patrick McCabe)
|
Found. (Contributed by Colin Patrick McCabe)
|
||||||
|
|
||||||
|
HADOOP-9791. Add a test case covering long paths for new FileUtil access
|
||||||
|
check methods (ivanmi)
|
||||||
|
|
||||||
Release 2.2.0 - UNRELEASED
|
Release 2.2.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -254,6 +254,45 @@ public class TestNativeIO {
|
||||||
File testFile = new File(TEST_DIR, "testfileaccess");
|
File testFile = new File(TEST_DIR, "testfileaccess");
|
||||||
assertTrue(testFile.createNewFile());
|
assertTrue(testFile.createNewFile());
|
||||||
|
|
||||||
|
// Validate ACCESS_READ
|
||||||
|
FileUtil.setReadable(testFile, false);
|
||||||
|
assertFalse(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_READ));
|
||||||
|
|
||||||
|
FileUtil.setReadable(testFile, true);
|
||||||
|
assertTrue(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_READ));
|
||||||
|
|
||||||
|
// Validate ACCESS_WRITE
|
||||||
|
FileUtil.setWritable(testFile, false);
|
||||||
|
assertFalse(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_WRITE));
|
||||||
|
|
||||||
|
FileUtil.setWritable(testFile, true);
|
||||||
|
assertTrue(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_WRITE));
|
||||||
|
|
||||||
|
// Validate ACCESS_EXECUTE
|
||||||
|
FileUtil.setExecutable(testFile, false);
|
||||||
|
assertFalse(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_EXECUTE));
|
||||||
|
|
||||||
|
FileUtil.setExecutable(testFile, true);
|
||||||
|
assertTrue(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
NativeIO.Windows.AccessRight.ACCESS_EXECUTE));
|
||||||
|
|
||||||
|
// Validate that access checks work as expected for long paths
|
||||||
|
|
||||||
|
// Assemble a path longer then 260 chars (MAX_PATH)
|
||||||
|
String testFileRelativePath = "";
|
||||||
|
for (int i = 0; i < 15; ++i) {
|
||||||
|
testFileRelativePath += "testfileaccessfolder\\";
|
||||||
|
}
|
||||||
|
testFileRelativePath += "testfileaccess";
|
||||||
|
testFile = new File(TEST_DIR, testFileRelativePath);
|
||||||
|
assertTrue(testFile.getParentFile().mkdirs());
|
||||||
|
assertTrue(testFile.createNewFile());
|
||||||
|
|
||||||
// Validate ACCESS_READ
|
// Validate ACCESS_READ
|
||||||
FileUtil.setReadable(testFile, false);
|
FileUtil.setReadable(testFile, false);
|
||||||
assertFalse(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
assertFalse(NativeIO.Windows.access(testFile.getAbsolutePath(),
|
||||||
|
|
Loading…
Reference in New Issue