[2/3] hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)

2015-05-19 Thread aajisaka
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 

[1/3] hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw)

2015-05-19 Thread aajisaka
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 6dee42f6d - fb49967e9


HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via 
aw)

(cherry picked from commit 30b797ee9df30260314eeadffc7d51492871b352)

Conflicts:
hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm


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

Branch: refs/heads/branch-2
Commit: 3d0e2e54a19937996aecdb2773d6fcc919e591e3
Parents: 6dee42f
Author: Allen Wittenauer a...@apache.org
Authored: Mon Feb 9 12:50:44 2015 -0800
Committer: Akira Ajisaka aajis...@apache.org
Committed: Tue May 19 17:38:22 2015 +0900

--
 hadoop-common-project/hadoop-common/CHANGES.txt |   3 +
 .../java/org/apache/hadoop/fs/shell/Ls.java | 187 ---
 .../src/test/resources/testConf.xml |  34 +++-
 .../src/test/resources/testHDFSConf.xml | 148 +++
 4 files changed, 343 insertions(+), 29 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d0e2e54/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 3205a4a..93304dc 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -19,6 +19,9 @@ Release 2.8.0 - UNRELEASED
 
 HADOOP-11949. Add user-provided plugins to test-patch (Sean Busbey via aw)
 
+HADOOP-8934. Shell command ls should include sort options (Jonathan Allen
+via aw)
+
   IMPROVEMENTS
 
 HADOOP-6842. hadoop fs -text does not give a useful text representation

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3d0e2e54/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
--
diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
index c7e80b6..0e46700 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
@@ -20,6 +20,8 @@ package org.apache.hadoop.fs.shell;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.LinkedList;
 import org.apache.hadoop.util.StringUtils;
@@ -40,29 +42,59 @@ class Ls extends FsCommand {
 factory.addClass(Ls.class, -ls);
 factory.addClass(Lsr.class, -lsr);
   }
-  
+
+  private static final String OPTION_DIRECTORY = d;
+  private static final String OPTION_HUMAN = h;
+  private static final String OPTION_RECURSIVE = R;
+  private static final String OPTION_REVERSE = r;
+  private static final String OPTION_MTIME = t;
+  private static final String OPTION_ATIME = u;
+  private static final String OPTION_SIZE = S;
+
   public static final String NAME = ls;
-  public static final String USAGE = [-d] [-h] [-R] [path ...];
+  public static final String USAGE = [- + OPTION_DIRECTORY + ] [-
+  + OPTION_HUMAN + ]  + [- + OPTION_RECURSIVE + ] [- + OPTION_MTIME
+  + ] [- + OPTION_SIZE + ] [- + OPTION_REVERSE + ]  + [-
+  + OPTION_ATIME + ] [path ...];
+
   public static final String DESCRIPTION =
-   List the contents that match the specified file pattern. 
If  +
-   path is not specified, the contents of /user/currentUser 
 +
-   will be listed. Directory entries are of the form:\n +
-   \tpermissions - userId groupId sizeOfDirectory(in bytes) 
modificationDate(-MM-dd HH:mm) directoryName\n\n +
-   and file entries are of the form:\n +
-   \tpermissions numberOfReplicas userId groupId 
sizeOfFile(in bytes) modificationDate(-MM-dd HH:mm) fileName\n +
-   -d:  Directories are listed as plain files.\n +
-   -h:  Formats the sizes of files in a human-readable 
fashion  +
-   rather than a number of bytes.\n +
-   -R:  Recursively list the contents of directories.;
- 
-  
-
-  protected final SimpleDateFormat dateFormat =
+  List the contents that match the specified file pattern. If  +
+  path is not specified, the contents of /user/currentUser  +
+  will be listed. For a directory a list of its direct children  +
+  is 

[06/50] [abbrv] hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)

2015-02-11 Thread zjshen
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)

2015-02-09 Thread aw
Repository: hadoop
Updated Branches:
  refs/heads/trunk ab934e859 - 30b797ee9


HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via 
aw)


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

Branch: refs/heads/trunk
Commit: 30b797ee9df30260314eeadffc7d51492871b352
Parents: ab934e8
Author: Allen Wittenauer a...@apache.org
Authored: Mon Feb 9 12:50:44 2015 -0800
Committer: Allen Wittenauer a...@apache.org
Committed: Mon Feb 9 12:50:44 2015 -0800

--
 hadoop-common-project/hadoop-common/CHANGES.txt |   3 +
 .../java/org/apache/hadoop/fs/shell/Ls.java | 187 ---
 .../src/site/apt/FileSystemShell.apt.vm |  22 ++-
 .../src/test/resources/testConf.xml |  34 +++-
 .../src/test/resources/testHDFSConf.xml | 148 +++
 5 files changed, 361 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/30b797ee/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 b02e695..55baf8a 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -24,6 +24,9 @@ Trunk (Unreleased)
 
 HADOOP-11485. Pluggable shell integration (aw)
 
+HADOOP-8934. Shell command ls should include sort options (Jonathan Allen
+via aw)
+
   IMPROVEMENTS
 
 HADOOP-8017. Configure hadoop-main pom to get rid of M2E plugin execution

http://git-wip-us.apache.org/repos/asf/hadoop/blob/30b797ee/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
--
diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
index c7e80b6..0e46700 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java
@@ -20,6 +20,8 @@ package org.apache.hadoop.fs.shell;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.LinkedList;
 import org.apache.hadoop.util.StringUtils;
@@ -40,29 +42,59 @@ class Ls extends FsCommand {
 factory.addClass(Ls.class, -ls);
 factory.addClass(Lsr.class, -lsr);
   }
-  
+
+  private static final String OPTION_DIRECTORY = d;
+  private static final String OPTION_HUMAN = h;
+  private static final String OPTION_RECURSIVE = R;
+  private static final String OPTION_REVERSE = r;
+  private static final String OPTION_MTIME = t;
+  private static final String OPTION_ATIME = u;
+  private static final String OPTION_SIZE = S;
+
   public static final String NAME = ls;
-  public static final String USAGE = [-d] [-h] [-R] [path ...];
+  public static final String USAGE = [- + OPTION_DIRECTORY + ] [-
+  + OPTION_HUMAN + ]  + [- + OPTION_RECURSIVE + ] [- + OPTION_MTIME
+  + ] [- + OPTION_SIZE + ] [- + OPTION_REVERSE + ]  + [-
+  + OPTION_ATIME + ] [path ...];
+
   public static final String DESCRIPTION =
-   List the contents that match the specified file pattern. 
If  +
-   path is not specified, the contents of /user/currentUser 
 +
-   will be listed. Directory entries are of the form:\n +
-   \tpermissions - userId groupId sizeOfDirectory(in bytes) 
modificationDate(-MM-dd HH:mm) directoryName\n\n +
-   and file entries are of the form:\n +
-   \tpermissions numberOfReplicas userId groupId 
sizeOfFile(in bytes) modificationDate(-MM-dd HH:mm) fileName\n +
-   -d:  Directories are listed as plain files.\n +
-   -h:  Formats the sizes of files in a human-readable 
fashion  +
-   rather than a number of bytes.\n +
-   -R:  Recursively list the contents of directories.;
- 
-  
-
-  protected final SimpleDateFormat dateFormat =
+  List the contents that match the specified file pattern. If  +
+  path is not specified, the contents of /user/currentUser  +
+  will be listed. For a directory a list of its direct children  +
+  is returned (unless - + OPTION_DIRECTORY +
+   option is specified).\n\n +
+  Directory entries are of the form:\n +
+  

hadoop git commit: HADOOP-8934. Shell command ls should include sort options (Jonathan Allen via aw) (missed file)

2015-02-09 Thread aw
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