From 81620ca1c96784eac14dea04ddc53d0157f28a4f Mon Sep 17 00:00:00 2001 From: Harsh J Date: Sat, 6 Jul 2013 02:16:27 +0000 Subject: [PATCH] HADOOP-8844. Add a plaintext fs -text test-case. Contributed by Akira AJISAKA. (harsh) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1500190 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/TestDFSShell.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index db002a4b70..f14e91818a 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -102,6 +102,9 @@ Trunk (Unreleased) HADOOP-9540. Expose the InMemoryS3 and S3N FilesystemStores implementations for Unit testing. (Hari via stevel) + HADOOP-8844. Add a plaintext fs -text test-case. + (Akira AJISAKA via harsh) + BUG FIXES HADOOP-9451. Fault single-layer config if node group topology is enabled. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java index cf62cd5257..b4dc041452 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSShell.java @@ -676,6 +676,22 @@ private void textTest(Path root, Configuration conf) throws Exception { assertTrue("Output doesn't match input", Arrays.equals(writebytes, out.toByteArray())); out.reset(); + + // Test a plain text. + OutputStream pout = fs.create(new Path(root, "file.txt")); + writebytes = "bar".getBytes(); + pout.write(writebytes); + pout.close(); + out = new ByteArrayOutputStream(); + System.setOut(new PrintStream(out)); + argv = new String[2]; + argv[0] = "-text"; + argv[1] = new Path(root, "file.txt").toString(); + ret = ToolRunner.run(new FsShell(conf), argv); + assertEquals("'-text " + argv[1] + " returned " + ret, 0, ret); + assertTrue("Output doesn't match input", + Arrays.equals(writebytes, out.toByteArray())); + out.reset(); } finally { if (null != bak) { System.setOut(bak);