You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by le...@apache.org on 2015/07/01 02:40:16 UTC

hadoop git commit: HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command name using reflection. (Lei Xu)

Repository: hadoop
Updated Branches:
  refs/heads/branch-2 f7ba3c004 -> fad478e7c


 HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command name using reflection. (Lei Xu)

(cherry picked from commit 47fab573bcb7b1129648499571b518f7b9773f89)

Conflicts:
	hadoop-common-project/hadoop-common/CHANGES.txt
	hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java


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

Branch: refs/heads/branch-2
Commit: fad478e7ce3763f02ecd97341c624a09f3f1f7e9
Parents: f7ba3c0
Author: Lei Xu <le...@apache.org>
Authored: Tue Jun 30 17:26:49 2015 -0700
Committer: Lei Xu <le...@apache.org>
Committed: Tue Jun 30 17:37:52 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 +
 .../apache/hadoop/fs/TestFsShellReturnCode.java | 60 +++++++++++++++-----
 .../org/apache/hadoop/fs/shell/TestMove.java    |  1 +
 3 files changed, 49 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fad478e7/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index a16463d..3b11a94 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -422,6 +422,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12116. Fix unrecommended syntax usages in hadoop/hdfs/yarn script for
     cygwin in branch-2. (Li Lu via cnauroth)
 
+    HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command
+    name using reflection. (lei)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fad478e7/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
index c68def6..cd606dd 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.fs;
 
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -381,19 +382,34 @@ public class TestFsShellReturnCode {
     }
     
   }
-  
+
+  /**
+   * Faked Chown class for {@link testChownUserAndGroupValidity()}.
+   *
+   * The test only covers argument parsing, so override to skip processing.
+   */
+  private static class FakeChown extends FsShellPermissions.Chown {
+    public static String NAME = "chown";
+    @Override
+    protected void processArgument(PathData item) {
+    }
+  }
+
   /**
    * Tests combinations of valid and invalid user and group arguments to chown.
    */
   @Test
   public void testChownUserAndGroupValidity() {
-    // This test only covers argument parsing, so override to skip processing.
-    FsCommand chown = new FsShellPermissions.Chown() {
-      @Override
-      protected void processArgument(PathData item) {
-      }
-    };
-    chown.setConf(new Configuration());
+    testChownUserAndGroupValidity(true);
+    testChownUserAndGroupValidity(false);
+  }
+
+  private void testChownUserAndGroupValidity(boolean enableWarning) {
+    Configuration conf = new Configuration();
+    conf.setBoolean(
+        HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY, enableWarning);
+    FsCommand chown = new FakeChown();
+    chown.setConf(conf);
 
     // The following are valid (no exception expected).
     chown.run("user", "/path");
@@ -418,17 +434,31 @@ public class TestFsShellReturnCode {
   }
 
   /**
+   * Faked Chgrp class for {@link testChgrpGroupValidity()}.
+   * The test only covers argument parsing, so override to skip processing.
+   */
+  private static class FakeChgrp extends FsShellPermissions.Chgrp {
+    public static String NAME = "chgrp";
+    @Override
+    protected void processArgument(PathData item) {
+    }
+  }
+
+  /**
    * Tests valid and invalid group arguments to chgrp.
    */
   @Test
   public void testChgrpGroupValidity() {
-    // This test only covers argument parsing, so override to skip processing.
-    FsCommand chgrp = new FsShellPermissions.Chgrp() {
-      @Override
-      protected void processArgument(PathData item) {
-      }
-    };
-    chgrp.setConf(new Configuration());
+    testChgrpGroupValidity(true);
+    testChgrpGroupValidity(false);
+  }
+
+  private void testChgrpGroupValidity(boolean enableWarning) {
+    Configuration conf = new Configuration();
+    conf.setBoolean(
+        HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY, enableWarning);
+    FsShellPermissions.Chgrp chgrp = new FakeChgrp();
+    chgrp.setConf(conf);
 
     // The following are valid (no exception expected).
     chgrp.run("group", "/path");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fad478e7/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java
index 6599edf..94930e5 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java
@@ -114,6 +114,7 @@ public class TestMove {
   }
     
   private static class InstrumentedRenameCommand extends MoveCommands.Rename {
+    public static String NAME = "InstrumentedRename";
     private Exception error = null;
     @Override
     public void displayError(Exception e) {