Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9D1071804A for ; Wed, 1 Jul 2015 10:46:04 +0000 (UTC) Received: (qmail 13144 invoked by uid 500); 1 Jul 2015 10:45:34 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 12724 invoked by uid 500); 1 Jul 2015 10:45:34 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 11398 invoked by uid 99); 1 Jul 2015 10:45:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2015 10:45:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5966E0508; Wed, 1 Jul 2015 10:45:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vvasudev@apache.org To: common-commits@hadoop.apache.org Date: Wed, 01 Jul 2015 10:46:20 -0000 Message-Id: <3da587709123454eb6e98f8a5f3ff4b9@git.apache.org> In-Reply-To: <83a8238545f945b08abdc9b5a131f831@git.apache.org> References: <83a8238545f945b08abdc9b5a131f831@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [49/50] hadoop git commit: HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command name using reflection. (Lei Xu) HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command name using reflection. (Lei Xu) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/532e38cb Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/532e38cb Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/532e38cb Branch: refs/heads/YARN-2139 Commit: 532e38cb7f70606c2c96d05259670e1e91d60ab3 Parents: b8e792c Author: Lei Xu Authored: Tue Jun 30 17:26:49 2015 -0700 Committer: Lei Xu Committed: Tue Jun 30 17:41:59 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/532e38cb/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 74d428f..39e2e5e 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -916,6 +916,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 (Eddy) Xu) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/532e38cb/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 dcc19df..a2276ec 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; @@ -402,7 +403,7 @@ public class TestFsShellReturnCode { // processing a file throws an interrupt, it should blow on first file assertEquals(1, InterruptCommand.processed); assertEquals(130, exitCode); - + exitCode = shell.run( new String[]{ "-testInterrupt", d.toString() }); // processing a file throws an interrupt, it should blow on file @@ -412,17 +413,32 @@ 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"); @@ -447,17 +463,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/532e38cb/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) {