[2/3] hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)
HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file) (cherry picked from commit 576459801c4e21effc4e3bca796527896b6e4f4b) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/df6d242e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/df6d242e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/df6d242e Branch: refs/heads/branch-2 Commit: df6d242e2866311fe1e20dffc6d6077003978228 Parents: 3d0e2e5 Author: Allen Wittenauer a...@apache.org Authored: Mon Feb 9 12:54:25 2015 -0800 Committer: Akira Ajisaka aajis...@apache.org Committed: Tue May 19 17:39:12 2015 +0900 -- .../java/org/apache/hadoop/fs/shell/TestLs.java | 1308 ++ 1 file changed, 1308 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/df6d242e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java -- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java new file mode 100644 index 000..66403db --- /dev/null +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java @@ -0,0 +1,1308 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.fs.shell; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedList; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FilterFileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.AclEntry; +import org.apache.hadoop.fs.permission.AclStatus; +import org.apache.hadoop.fs.permission.FsPermission; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.InOrder; + +/** + * JUnit test class for {@link org.apache.hadoop.fs.shell.Ls} + * + */ +public class TestLs { + private static Configuration conf; + private static FileSystem mockFs; + + private static final Date NOW = new Date(); + + @BeforeClass + public static void setup() throws IOException { +conf = new Configuration(); +conf.set(fs.defaultFS, mockfs:///); +conf.setClass(fs.mockfs.impl, MockFileSystem.class, FileSystem.class); +mockFs = mock(FileSystem.class); + } + + @Before + public void resetMock() throws IOException { +reset(mockFs); +AclStatus mockAclStatus = mock(AclStatus.class); +when(mockAclStatus.getEntries()).thenReturn(new ArrayListAclEntry()); +when(mockFs.getAclStatus(any(Path.class))).thenReturn(mockAclStatus); + } + + // check that default options are correct + @Test + public void processOptionsNone() throws IOException { +LinkedListString options = new LinkedListString(); +Ls ls = new Ls(); +ls.processOptions(options); +assertTrue(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -d option is recognised + @Test + public void processOptionsDirectory() throws IOException { +LinkedListString options = new LinkedListString(); +options.add(-d); +Ls ls = new Ls(); +ls.processOptions(options); +assertFalse(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -h option is
[06/50] [abbrv] hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)
HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/57645980 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/57645980 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/57645980 Branch: refs/heads/YARN-2928 Commit: 576459801c4e21effc4e3bca796527896b6e4f4b Parents: 84cc071 Author: Allen Wittenauer a...@apache.org Authored: Mon Feb 9 12:54:25 2015 -0800 Committer: Allen Wittenauer a...@apache.org Committed: Mon Feb 9 12:54:25 2015 -0800 -- .../java/org/apache/hadoop/fs/shell/TestLs.java | 1308 ++ 1 file changed, 1308 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/57645980/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java -- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java new file mode 100644 index 000..66403db --- /dev/null +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java @@ -0,0 +1,1308 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.fs.shell; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedList; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FilterFileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.AclEntry; +import org.apache.hadoop.fs.permission.AclStatus; +import org.apache.hadoop.fs.permission.FsPermission; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.InOrder; + +/** + * JUnit test class for {@link org.apache.hadoop.fs.shell.Ls} + * + */ +public class TestLs { + private static Configuration conf; + private static FileSystem mockFs; + + private static final Date NOW = new Date(); + + @BeforeClass + public static void setup() throws IOException { +conf = new Configuration(); +conf.set(fs.defaultFS, mockfs:///); +conf.setClass(fs.mockfs.impl, MockFileSystem.class, FileSystem.class); +mockFs = mock(FileSystem.class); + } + + @Before + public void resetMock() throws IOException { +reset(mockFs); +AclStatus mockAclStatus = mock(AclStatus.class); +when(mockAclStatus.getEntries()).thenReturn(new ArrayListAclEntry()); +when(mockFs.getAclStatus(any(Path.class))).thenReturn(mockAclStatus); + } + + // check that default options are correct + @Test + public void processOptionsNone() throws IOException { +LinkedListString options = new LinkedListString(); +Ls ls = new Ls(); +ls.processOptions(options); +assertTrue(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -d option is recognised + @Test + public void processOptionsDirectory() throws IOException { +LinkedListString options = new LinkedListString(); +options.add(-d); +Ls ls = new Ls(); +ls.processOptions(options); +assertFalse(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -h option is recognised + @Test + public void processOptionsHuman() throws
hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)
Repository: hadoop Updated Branches: refs/heads/trunk 84cc071a7 - 576459801 HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/57645980 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/57645980 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/57645980 Branch: refs/heads/trunk Commit: 576459801c4e21effc4e3bca796527896b6e4f4b Parents: 84cc071 Author: Allen Wittenauer a...@apache.org Authored: Mon Feb 9 12:54:25 2015 -0800 Committer: Allen Wittenauer a...@apache.org Committed: Mon Feb 9 12:54:25 2015 -0800 -- .../java/org/apache/hadoop/fs/shell/TestLs.java | 1308 ++ 1 file changed, 1308 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/57645980/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java -- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java new file mode 100644 index 000..66403db --- /dev/null +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java @@ -0,0 +1,1308 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.fs.shell; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedList; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FilterFileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.AclEntry; +import org.apache.hadoop.fs.permission.AclStatus; +import org.apache.hadoop.fs.permission.FsPermission; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.InOrder; + +/** + * JUnit test class for {@link org.apache.hadoop.fs.shell.Ls} + * + */ +public class TestLs { + private static Configuration conf; + private static FileSystem mockFs; + + private static final Date NOW = new Date(); + + @BeforeClass + public static void setup() throws IOException { +conf = new Configuration(); +conf.set(fs.defaultFS, mockfs:///); +conf.setClass(fs.mockfs.impl, MockFileSystem.class, FileSystem.class); +mockFs = mock(FileSystem.class); + } + + @Before + public void resetMock() throws IOException { +reset(mockFs); +AclStatus mockAclStatus = mock(AclStatus.class); +when(mockAclStatus.getEntries()).thenReturn(new ArrayListAclEntry()); +when(mockFs.getAclStatus(any(Path.class))).thenReturn(mockAclStatus); + } + + // check that default options are correct + @Test + public void processOptionsNone() throws IOException { +LinkedListString options = new LinkedListString(); +Ls ls = new Ls(); +ls.processOptions(options); +assertTrue(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -d option is recognised + @Test + public void processOptionsDirectory() throws IOException { +LinkedListString options = new LinkedListString(); +options.add(-d); +Ls ls = new Ls(); +ls.processOptions(options); +assertFalse(ls.isDirRecurse()); +assertFalse(ls.isHumanReadable()); +assertFalse(ls.isRecursive()); +assertFalse(ls.isOrderReverse()); +assertFalse(ls.isOrderSize()); +assertFalse(ls.isOrderTime()); +assertFalse(ls.isUseAtime()); + } + + // check the -h option