HADOOP-14843. Improve FsPermission symbolic parsing unit test coverage. Contributed by Bharat Viswanadham

(cherry picked from commit 86f4d1c66c)

Conflicts:
	hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
This commit is contained in:
Jason Lowe 2017-09-12 16:51:08 -05:00
parent 10803bf08d
commit c314a66353
1 changed files with 56 additions and 0 deletions

View File

@ -132,6 +132,62 @@ public class TestFsPermission extends TestCase {
}
}
public void testFsSymbolicConstructorWithNormalInput() {
// Test cases for symbolic representation
//Added both Octal and short representation to show with sticky bit
assertEquals(777, new FsPermission("+rwx").toOctal());
assertEquals(0777, new FsPermission("+rwx").toShort());
assertEquals(444, new FsPermission("+r").toOctal());
assertEquals(0444, new FsPermission("+r").toShort());
assertEquals(222, new FsPermission("+w").toOctal());
assertEquals(0222, new FsPermission("+w").toShort());
assertEquals(111, new FsPermission("+x").toOctal());
assertEquals(0111, new FsPermission("+x").toShort());
assertEquals(666, new FsPermission("+rw").toOctal());
assertEquals(0666, new FsPermission("+rw").toShort());
assertEquals(333, new FsPermission("+wx").toOctal());
assertEquals(0333, new FsPermission("+wx").toShort());
assertEquals(555, new FsPermission("+rx").toOctal());
assertEquals(0555, new FsPermission("+rx").toShort());
// Test case is to test with repeated values in mode.
// Repeated value in input will be ignored as duplicate.
assertEquals(666, new FsPermission("+rwr").toOctal());
assertEquals(0666, new FsPermission("+rwr").toShort());
assertEquals(000, new FsPermission("-rwr").toOctal());
assertEquals(0000, new FsPermission("-rwr").toShort());
assertEquals(1666, new FsPermission("+rwrt").toOctal());
assertEquals(01666, new FsPermission("+rwrt").toShort());
assertEquals(000, new FsPermission("-rwrt").toOctal());
assertEquals(0000, new FsPermission("-rwrt").toShort());
assertEquals(1777, new FsPermission("+rwxt").toOctal());
assertEquals(01777, new FsPermission("+rwxt").toShort());
assertEquals(000, new FsPermission("-rt").toOctal());
assertEquals(0000, new FsPermission("-rt").toShort());
assertEquals(000, new FsPermission("-rwx").toOctal());
assertEquals(0000, new FsPermission("-rwx").toShort());
}
public void testSymbolicPermission() {
for (int i = 0; i < SYMBOLIC.length; ++i) {
short val = 0777;