hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject hadoop git commit: HADOOP-14843. Improve FsPermission symbolic parsing unit test coverage. Contributed by Bharat Viswanadham
Date Tue, 12 Sep 2017 21:54:49 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 99e7b2644 -> 4e147f7e9


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

(cherry picked from commit 86f4d1c66c8b541465ff769e5d951305c41c715c)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4e147f7e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4e147f7e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4e147f7e

Branch: refs/heads/branch-3.0
Commit: 4e147f7e96cf84d25bf3fc8590ceb39b68e2b465
Parents: 99e7b26
Author: Jason Lowe <jlowe@apache.org>
Authored: Tue Sep 12 16:51:08 2017 -0500
Committer: Jason Lowe <jlowe@apache.org>
Committed: Tue Sep 12 16:52:39 2017 -0500

----------------------------------------------------------------------
 .../hadoop/fs/permission/TestFsPermission.java  | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e147f7e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
index a22985d..afddf80 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
@@ -139,6 +139,63 @@ public class TestFsPermission {
   }
 
   @Test
+  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());
+
+  }
+
+
+  @Test
   public void testSymbolicPermission() {
     for (int i = 0; i < SYMBOLIC.length; ++i) {
       short val = 0777;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message