hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgho...@apache.org
Subject svn commit: r937903 - in /hadoop/hdfs/trunk: CHANGES.txt src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
Date Sun, 25 Apr 2010 22:41:57 GMT
Author: jghoman
Date: Sun Apr 25 22:41:57 2010
New Revision: 937903

URL: http://svn.apache.org/viewvc?rev=937903&view=rev
Log:
HDFS-666. Unit test for FsShell -text. (cdouglas via jghoman)

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=937903&r1=937902&r2=937903&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Sun Apr 25 22:41:57 2010
@@ -148,6 +148,8 @@ Trunk (unreleased changes)
     HDFS-1047. Install/deploy source jars to Maven repo. 
     (Patrick Angeles via jghoman)
 
+    HDFS-666. Unit test for FsShell -text. (cdouglas via jghoman)
+
   OPTIMIZATIONS
 
     HDFS-946. NameNode should not return full path name when lisitng a

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java?rev=937903&r1=937902&r2=937903&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java Sun Apr 25 22:41:57
2010
@@ -541,11 +541,27 @@ public class TestDFSShell extends TestCa
   public void testText() throws Exception {
     Configuration conf = new HdfsConfiguration();
     MiniDFSCluster cluster = null;
-    PrintStream bak = null;
     try {
       cluster = new MiniDFSCluster(conf, 2, true, null);
-      FileSystem fs = cluster.getFileSystem();
-      Path root = new Path("/texttest");
+      final FileSystem dfs = cluster.getFileSystem();
+      textTest(new Path("/texttest").makeQualified(dfs.getUri(),
+            dfs.getWorkingDirectory()), conf);
+
+      conf.set("fs.default.name", dfs.getUri().toString());
+      final FileSystem lfs = FileSystem.getLocal(conf);
+      textTest(new Path(TEST_ROOT_DIR, "texttest").makeQualified(lfs.getUri(),
+            lfs.getWorkingDirectory()), conf);
+    } finally {
+      if (null != cluster) {
+        cluster.shutdown();
+      }
+    }
+  }
+
+  private void textTest(Path root, Configuration conf) throws Exception {
+    PrintStream bak = null;
+    try {
+      final FileSystem fs = root.getFileSystem(conf);
       fs.mkdirs(root);
       OutputStream zout = new GZIPOutputStream(
           fs.create(new Path(root, "file.gz")));
@@ -564,21 +580,17 @@ public class TestDFSShell extends TestCa
 
       String[] argv = new String[2];
       argv[0] = "-text";
-      argv[1] = new Path(root, "file.gz").toUri().getPath();
-      int ret = ToolRunner.run(new FsShell(), argv);
-      assertTrue("-text returned -1", 0 >= ret);
+      argv[1] = new Path(root, "file.gz").toString();
+      int ret = ToolRunner.run(new FsShell(conf), argv);
+      assertEquals("'-text " + argv[1] + " returned " + ret, 0, ret);
       file.reset();
       out.reset();
       assertTrue("Output doesn't match input",
           Arrays.equals(file.toByteArray(), out.toByteArray()));
-
     } finally {
       if (null != bak) {
         System.setOut(bak);
       }
-      if (null != cluster) {
-        cluster.shutdown();
-      }
     }
   }
 
@@ -697,7 +709,8 @@ public class TestDFSShell extends TestCa
 
       final FileSystem localfs = FileSystem.getLocal(conf);
       Path localpath = new Path(TEST_ROOT_DIR, "testcount");
-      localpath = localpath.makeQualified(localfs);
+      localpath = localpath.makeQualified(localfs.getUri(),
+          localfs.getWorkingDirectory());
       localfs.mkdirs(localpath);
       
       final String localstr = localpath.toString();



Mime
View raw message