hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r897029 [3/4] - in /hadoop/common/branches/HADOOP-6194: ./ bin/ src/contrib/cloud/ src/contrib/cloud/lib/ src/contrib/cloud/src/ src/contrib/cloud/src/integration-test/ src/contrib/cloud/src/py/ src/contrib/cloud/src/py/hadoop/ src/contrib/...
Date Thu, 07 Jan 2010 22:04:43 GMT
Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/TestCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/TestCLI.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/TestCLI.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/TestCLI.java Thu Jan  7 22:04:37 2010
@@ -18,433 +18,42 @@
 
 package org.apache.hadoop.cli;
 
-import java.io.File;
-import java.util.ArrayList;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.cli.util.CLITestData;
+import org.apache.hadoop.cli.util.CmdFactory;
 import org.apache.hadoop.cli.util.CommandExecutor;
-import org.apache.hadoop.cli.util.ComparatorBase;
-import org.apache.hadoop.cli.util.ComparatorData;
-import org.apache.hadoop.cli.util.CLITestData.TestCmd;
-import org.apache.hadoop.cli.util.CLITestData.TestCmd.CommandType;
-import org.apache.hadoop.cli.util.CommandExecutor.Result;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
-import org.apache.hadoop.util.StringUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Tests for the Command Line Interface (CLI)
  */
-public class TestCLI extends TestCase {
-  private static final Log LOG =
-    LogFactory.getLog(TestCLI.class.getName());
-  
-  // In this mode, it runs the command and compares the actual output
-  // with the expected output  
-  public static final String TESTMODE_TEST = "test"; // Run the tests
-  
-  // If it is set to nocompare, run the command and do not compare.
-  // This can be useful populate the testConfig.xml file the first time
-  // a new command is added
-  public static final String TESTMODE_NOCOMPARE = "nocompare";
-  public static final String TEST_CACHE_DATA_DIR =
-    System.getProperty("test.cache.data", "build/test/cache");
-  
-  //By default, run the tests. The other mode is to run the commands and not
-  // compare the output
-  protected String testMode = TESTMODE_TEST;
-  
-  // Storage for tests read in from the config file
-  protected ArrayList<CLITestData> testsFromConfigFile = null;
-  protected ArrayList<ComparatorData> testComparators = null;
-  protected String thisTestCaseName = null;
-  protected ComparatorData comparatorData = null;
-  protected Configuration conf = null;
-  protected String clitestDataDir = null;
-  protected String username = null;
-  
-  /**
-   * Read the test config file - testConfig.xml
-   */
-  protected void readTestConfigFile() {
-    String testConfigFile = getTestFile();
-    if (testsFromConfigFile == null) {
-      boolean success = false;
-      testConfigFile = TEST_CACHE_DATA_DIR + File.separator + testConfigFile;
-      try {
-        SAXParser p = (SAXParserFactory.newInstance()).newSAXParser();
-        p.parse(testConfigFile, new TestConfigFileParser());
-        success = true;
-      } catch (Exception e) {
-        LOG.info("File: " + testConfigFile + " not found");
-        success = false;
-      }
-      assertTrue("Error reading test config file", success);
-    }
-  }
-  
-  protected String getTestFile() {
-    return "testConf.xml";
-  }
-  
-  /*
-   * Setup
-   */
+public class TestCLI extends CLITestHelper {
+  @Before
+  @Override
   public void setUp() throws Exception {
-    // Read the testConfig.xml file
-    readTestConfigFile();
-    
-    conf = new Configuration();
-    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
-                    true);
-
-    clitestDataDir = new File(TEST_CACHE_DATA_DIR).
-    toURI().toString().replace(' ', '+');
+    super.setUp();
   }
-  
-  /**
-   * Tear down
-   */
+
+  @After
+  @Override
   public void tearDown() throws Exception {
-    displayResults();
-  }
-  
-  /**
-   * Expand the commands from the test config xml file
-   * @param cmd
-   * @return String expanded command
-   */
-  protected String expandCommand(final String cmd) {
-    String expCmd = cmd;
-    expCmd = expCmd.replaceAll("CLITEST_DATA", clitestDataDir);
-    expCmd = expCmd.replaceAll("USERNAME", username);
-    
-    return expCmd;
+    super.tearDown();
   }
-  
-  /**
-   * Display the summarized results
-   */
-  private void displayResults() {
-    LOG.info("Detailed results:");
-    LOG.info("----------------------------------\n");
-    
-    for (int i = 0; i < testsFromConfigFile.size(); i++) {
-      CLITestData td = testsFromConfigFile.get(i);
-      
-      boolean testResult = td.getTestResult();
-      
-      // Display the details only if there is a failure
-      if (!testResult) {
-        LOG.info("-------------------------------------------");
-        LOG.info("                    Test ID: [" + (i + 1) + "]");
-        LOG.info("           Test Description: [" + td.getTestDesc() + "]");
-        LOG.info("");
-
-        ArrayList<TestCmd> testCommands = td.getTestCommands();
-        for (TestCmd cmd : testCommands) {
-          LOG.info("              Test Commands: [" + 
-                   expandCommand(cmd.getCmd()) + "]");
-        }
-
-        LOG.info("");
-        ArrayList<TestCmd> cleanupCommands = td.getCleanupCommands();
-        for (TestCmd cmd : cleanupCommands) {
-          LOG.info("           Cleanup Commands: [" +
-                   expandCommand(cmd.getCmd()) + "]");
-        }
-
-        LOG.info("");
-        ArrayList<ComparatorData> compdata = td.getComparatorData();
-        for (ComparatorData cd : compdata) {
-          boolean resultBoolean = cd.getTestResult();
-          LOG.info("                 Comparator: [" + 
-                   cd.getComparatorType() + "]");
-          LOG.info("         Comparision result:   [" + 
-                   (resultBoolean ? "pass" : "fail") + "]");
-          LOG.info("            Expected output:   [" + 
-                   cd.getExpectedOutput() + "]");
-          LOG.info("              Actual output:   [" + 
-                   cd.getActualOutput() + "]");
-        }
-        LOG.info("");
-      }
-    }
-    
-    LOG.info("Summary results:");
-    LOG.info("----------------------------------\n");
-    
-    boolean overallResults = true;
-    int totalPass = 0;
-    int totalFail = 0;
-    int totalComparators = 0;
-    for (int i = 0; i < testsFromConfigFile.size(); i++) {
-      CLITestData td = testsFromConfigFile.get(i);
-      totalComparators += 
-    	  testsFromConfigFile.get(i).getComparatorData().size();
-      boolean resultBoolean = td.getTestResult();
-      if (resultBoolean) {
-        totalPass ++;
-      } else {
-        totalFail ++;
-      }
-      overallResults &= resultBoolean;
-    }
-    
-    
-    LOG.info("               Testing mode: " + testMode);
-    LOG.info("");
-    LOG.info("             Overall result: " + 
-    		(overallResults ? "+++ PASS +++" : "--- FAIL ---"));
-    if ((totalPass + totalFail) == 0) {
-      LOG.info("               # Tests pass: " + 0);
-      LOG.info("               # Tests fail: " + 0);
-    }
-    else 
-    {
-      LOG.info("               # Tests pass: " + totalPass +
-          " (" + (100 * totalPass / (totalPass + totalFail)) + "%)");
-      LOG.info("               # Tests fail: " + totalFail + 
-          " (" + (100 * totalFail / (totalPass + totalFail)) + "%)");
-    }
-    
-    LOG.info("         # Validations done: " + totalComparators + 
-    		" (each test may do multiple validations)");
-    
-    LOG.info("");
-    LOG.info("Failing tests:");
-    LOG.info("--------------");
-    int i = 0;
-    boolean foundTests = false;
-    for (i = 0; i < testsFromConfigFile.size(); i++) {
-      boolean resultBoolean = testsFromConfigFile.get(i).getTestResult();
-      if (!resultBoolean) {
-        LOG.info((i + 1) + ": " + 
-        		testsFromConfigFile.get(i).getTestDesc());
-        foundTests = true;
-      }
-    }
-    if (!foundTests) {
-    	LOG.info("NONE");
-    }
-    
-    foundTests = false;
-    LOG.info("");
-    LOG.info("Passing tests:");
-    LOG.info("--------------");
-    for (i = 0; i < testsFromConfigFile.size(); i++) {
-      boolean resultBoolean = testsFromConfigFile.get(i).getTestResult();
-      if (resultBoolean) {
-        LOG.info((i + 1) + ": " + 
-        		testsFromConfigFile.get(i).getTestDesc());
-        foundTests = true;
-      }
-    }
-    if (!foundTests) {
-    	LOG.info("NONE");
-    }
 
-    assertTrue("One of the tests failed. " +
-    		"See the Detailed results to identify " +
-    		"the command that failed", overallResults);
-    
+  @Override
+  protected CommandExecutor.Result execute(CLITestData.TestCmd cmd) throws Exception {
+    return CmdFactory.getCommandExecutor(cmd, "").executeCommand(cmd.getCmd());
   }
   
-  /**
-   * Compare the actual output with the expected output
-   * @param compdata
-   * @return
-   */
-  private boolean compareTestOutput(ComparatorData compdata, Result cmdResult) {
-    // Compare the output based on the comparator
-    String comparatorType = compdata.getComparatorType();
-    Class<?> comparatorClass = null;
-    
-    // If testMode is "test", then run the command and compare the output
-    // If testMode is "nocompare", then run the command and dump the output.
-    // Do not compare
-    
-    boolean compareOutput = false;
-    
-    if (testMode.equals(TESTMODE_TEST)) {
-      try {
-    	// Initialize the comparator class and run its compare method
-        comparatorClass = Class.forName("org.apache.hadoop.cli.util." + 
-          comparatorType);
-        ComparatorBase comp = (ComparatorBase) comparatorClass.newInstance();
-        compareOutput = comp.compare(cmdResult.getCommandOutput(), 
-          compdata.getExpectedOutput());
-      } catch (Exception e) {
-        LOG.info("Error in instantiating the comparator" + e);
-      }
-    }
-    
-    return compareOutput;
+  @Override
+  protected String getTestFile() {
+    return "testConf.xml";
   }
   
-  /***********************************
-   ************* TESTS
-   *********************************/
-  
+  @Test
+  @Override
   public void testAll() {
-    LOG.info("TestAll");
-    
-    // Run the tests defined in the testConf.xml config file.
-    for (int index = 0; index < testsFromConfigFile.size(); index++) {
-      
-      CLITestData testdata = (CLITestData) testsFromConfigFile.get(index);
-   
-      // Execute the test commands
-      ArrayList<TestCmd> testCommands = testdata.getTestCommands();
-      Result cmdResult = null;
-      for (TestCmd cmd : testCommands) {
-      try {
-        cmdResult = execute(cmd);
-      } catch (Exception e) {
-        fail(StringUtils.stringifyException(e));
-      }
-      }
-      
-      boolean overallTCResult = true;
-      // Run comparators
-      ArrayList<ComparatorData> compdata = testdata.getComparatorData();
-      for (ComparatorData cd : compdata) {
-        final String comptype = cd.getComparatorType();
-        
-        boolean compareOutput = false;
-        
-        if (! comptype.equalsIgnoreCase("none")) {
-          compareOutput = compareTestOutput(cd, cmdResult);
-          overallTCResult &= compareOutput;
-        }
-        
-        cd.setExitCode(cmdResult.getExitCode());
-        cd.setActualOutput(cmdResult.getCommandOutput());
-        cd.setTestResult(compareOutput);
-      }
-      testdata.setTestResult(overallTCResult);
-      
-      // Execute the cleanup commands
-      ArrayList<TestCmd> cleanupCommands = testdata.getCleanupCommands();
-      for (TestCmd cmd : cleanupCommands) {
-      try { 
-        execute(cmd);
-      } catch (Exception e) {
-        fail(StringUtils.stringifyException(e));
-      }
-      }
-    }
-  }
-  
-  protected CommandExecutor.Result execute(TestCmd cmd) throws Exception {
-    throw new Exception("Unknow type of Test command:"+ cmd.getType());
-  }
-  
-  /*
-   * Parser class for the test config xml file
-   */
-  class TestConfigFileParser extends DefaultHandler {
-    String charString = null;
-    CLITestData td = null;
-    ArrayList<TestCmd> testCommands = null;
-    ArrayList<TestCmd> cleanupCommands = null;
-    
-    @Override
-    public void startDocument() throws SAXException {
-      testsFromConfigFile = new ArrayList<CLITestData>();
-    }
-    
-    @Override
-    public void startElement(String uri, 
-    		String localName, 
-    		String qName, 
-    		Attributes attributes) throws SAXException {
-      if (qName.equals("test")) {
-        td = new CLITestData();
-      } else if (qName.equals("test-commands")) {
-        testCommands = new ArrayList<TestCmd>();
-      } else if (qName.equals("cleanup-commands")) {
-        cleanupCommands = new ArrayList<TestCmd>();
-      } else if (qName.equals("comparators")) {
-        testComparators = new ArrayList<ComparatorData>();
-      } else if (qName.equals("comparator")) {
-        comparatorData = new ComparatorData();
-      }
-      charString = "";
-    }
-    
-    @Override
-    public void endElement(String uri, 
-    		String localName, 
-    		String qName) throws SAXException {
-      if (qName.equals("description")) {
-        td.setTestDesc(charString);
-      } else if (qName.equals("test-commands")) {
-        td.setTestCommands(testCommands);
-        testCommands = null;
-      } else if (qName.equals("cleanup-commands")) {
-        td.setCleanupCommands(cleanupCommands);
-        cleanupCommands = null;
-      } else if (qName.equals("command")) {
-        if (testCommands != null) {
-          testCommands.add(new TestCmd(charString, CommandType.FS));
-        } else if (cleanupCommands != null) {
-          cleanupCommands.add(new TestCmd(charString, CommandType.FS));
-        }
-      } else if (qName.equals("dfs-admin-command")) {
-        if (testCommands != null) {
-          testCommands.add(new TestCmd(charString, CommandType.DFSADMIN));
-        } else if (cleanupCommands != null) {
-          cleanupCommands.add(new TestCmd(charString, CommandType.DFSADMIN));
-        } 
-      } else if (qName.equals("mr-admin-command")) {
-        if (testCommands != null) {
-          testCommands.add(new TestCmd(charString, CommandType.MRADMIN));
-        } else if (cleanupCommands != null) {
-          cleanupCommands.add(new TestCmd(charString, CommandType.MRADMIN));
-        } 
-      } else if (qName.equals("archive-command")) {
-        if (testCommands != null) {
-          testCommands.add(new TestCmd(charString, CommandType.ARCHIVE));
-        } else if (cleanupCommands != null) {
-          cleanupCommands.add(new TestCmd(charString, CommandType.ARCHIVE));
-        }
-      } else if (qName.equals("comparators")) {
-        td.setComparatorData(testComparators);
-      } else if (qName.equals("comparator")) {
-        testComparators.add(comparatorData);
-      } else if (qName.equals("type")) {
-        comparatorData.setComparatorType(charString);
-      } else if (qName.equals("expected-output")) {
-        comparatorData.setExpectedOutput(charString);
-      } else if (qName.equals("test")) {
-        testsFromConfigFile.add(td);
-        td = null;
-      } else if (qName.equals("mode")) {
-        testMode = charString;
-        if (!testMode.equals(TESTMODE_NOCOMPARE) &&
-            !testMode.equals(TESTMODE_TEST)) {
-          testMode = TESTMODE_TEST;
-        }
-      }
-    }
-    
-    @Override
-    public void characters(char[] ch, 
-    		int start, 
-    		int length) throws SAXException {
-      String s = new String(ch, start, length);
-      charString += s;
-    }
+    super.testAll();
   }
 }

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xml?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xml (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xml Thu Jan  7 22:04:37 2010
@@ -28,6 +28,21 @@
            TokenComparator
            -->
   <tests>
+    <!-- Tests for help -->
+    <test> <!-- TESTED -->
+      <description>help: check if fs help message is shown</description>
+      <test-commands>
+        <command>-help</command>
+      </test-commands>
+      <cleanup-commands>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>hadoop fs is the command to execute fs commands. The full syntax is</expected-output>
+        </comparator>
+      </comparators>
+    </test>
 
   </tests>
 </configuration>

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xsl
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xsl?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xsl (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/testConf.xsl Thu Jan  7 22:04:37 2010
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
 <!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -14,7 +15,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<?xml version="1.0" encoding="ISO-8859-1"?>
 
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/cli/util/CommandExecutor.java Thu Jan  7 22:04:37 2010
@@ -18,13 +18,13 @@
 
 package org.apache.hadoop.cli.util;
 
+import org.apache.hadoop.cli.CLITestHelper;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.PrintStream;
 import java.util.StringTokenizer;
 
-import org.apache.hadoop.cli.TestCLI;
-
 /**
  *
  * This class execute commands and captures the output
@@ -41,7 +41,7 @@
 
       args[i] = args[i].replaceAll(masterKey, master);
       args[i] = args[i].replaceAll("CLITEST_DATA", 
-        new File(TestCLI.TEST_CACHE_DATA_DIR).
+        new File(CLITestHelper.TEST_CACHE_DATA_DIR).
         toURI().toString().replace(' ', '+'));
       args[i] = args[i].replaceAll("USERNAME", System.getProperty("user.name"));
 

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/conf/TestConfiguration.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/conf/TestConfiguration.java Thu Jan  7 22:04:37 2010
@@ -24,7 +24,9 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Random;
+import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
 
@@ -364,6 +366,76 @@
     assertTrue(fail);
   }
 
+  public void testMap() throws IOException {
+    Configuration conf = new Configuration();
+
+    // manually create a map in the config; extract
+    // its values as a map object.
+    conf.set("foo.bar", "A");
+    conf.set("foo.baz", "B");
+    assertEquals("A", conf.get("foo.bar"));
+    assertEquals("B", conf.get("foo.baz"));
+
+    Map<String, String> out = conf.getMap("foo");
+    assertEquals("A", out.get("bar"));
+    assertEquals("B", out.get("baz"));
+
+    Map<String, String> in = new HashMap<String, String>();
+    in.put("yak", "123");
+    in.put("bop", "456");
+    conf.setMap("quux", in);
+
+    // Assert that we can extract individual entries in
+    // the nested map ok.
+    assertEquals("123", conf.get("quux.yak"));
+
+    // Assert that we can get the whole map back out again.
+    out = conf.getMap("quux");
+    assertEquals("123", out.get("yak"));
+    assertEquals("456", out.get("bop"));
+
+    // Test that substitution is handled by getMap().
+    conf.set("subparam", "foo");
+    conf.set("mymap.someprop", "AAA${subparam}BBB");
+    out = conf.getMap("mymap");
+    assertEquals("AAAfooBBB", out.get("someprop"));
+
+    // Test deprecation of maps.
+    Configuration.addDeprecation("oldfoo", new String[]{"newfoo"});
+    conf.set("newfoo.a", "A");
+    conf.set("newfoo.b", "B");
+    out = conf.getMap("oldfoo");
+    assertEquals("A", out.get("a"));
+    assertEquals("B", out.get("b"));
+  }
+
+  public void testPattern() throws IOException {
+    out = new BufferedWriter(new FileWriter(CONFIG));
+    startConfig();
+    appendProperty("test.pattern1", "");
+    appendProperty("test.pattern2", "(");
+    appendProperty("test.pattern3", "a+b");
+    endConfig();
+    Path fileResource = new Path(CONFIG);
+    conf.addResource(fileResource);
+
+    Pattern defaultPattern = Pattern.compile("x+");
+    // Return default if missing
+    assertEquals(defaultPattern.pattern(),
+                 conf.getPattern("xxxxx", defaultPattern).pattern());
+    // Return null if empty and default is null
+    assertNull(conf.getPattern("test.pattern1", null));
+    // Return default for empty
+    assertEquals(defaultPattern.pattern(),
+                 conf.getPattern("test.pattern1", defaultPattern).pattern());
+    // Return default for malformed
+    assertEquals(defaultPattern.pattern(),
+                 conf.getPattern("test.pattern2", defaultPattern).pattern());
+    // Works for correct patterns
+    assertEquals("a+b",
+                 conf.getPattern("test.pattern3", defaultPattern).pattern());
+  }
+
   public void testReload() throws IOException {
     out=new BufferedWriter(new FileWriter(CONFIG));
     startConfig();

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextCreateMkdirBaseTest.java Thu Jan  7 22:04:37 2010
@@ -19,14 +19,15 @@
 
 
 import java.io.IOException;
-import java.util.EnumSet;
 
-import org.apache.hadoop.fs.Options.CreateOpts;
 import org.apache.hadoop.util.StringUtils;
+import org.apache.log4j.Level;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+import org.apache.commons.logging.impl.Log4JLogger;
 
 /**
  * <p>
@@ -48,31 +49,13 @@
  * </p>
  */
 
-public class FileContextCreateMkdirBaseTest {
+public abstract class FileContextCreateMkdirBaseTest {
    
   protected static FileContext fc;
-  static final String TEST_ROOT_DIR = new Path(System.getProperty(
-      "test.build.data", "build/test/data")).toString().replace(' ', '_')
-      + "/test";
-  
-  
-  protected Path getTestRootRelativePath(String pathString) {
-    return fc.makeQualified(new Path(TEST_ROOT_DIR, pathString));
-  }
-  
-  private Path rootPath = null;
-  protected Path getTestRoot() {
-    if (rootPath == null) {
-      rootPath = fc.makeQualified(new Path(TEST_ROOT_DIR));
-    }
-    return rootPath;   
-  }
-
-
+      
   {
     try {
-      ((org.apache.commons.logging.impl.Log4JLogger)FileSystem.LOG).getLogger()
-      .setLevel(org.apache.log4j.Level.DEBUG);
+      ((Log4JLogger)FileSystem.LOG).getLogger().setLevel(Level.DEBUG);
     }
     catch(Exception e) {
       System.out.println("Cannot change log level\n"
@@ -81,15 +64,14 @@
   }
   
 
-
   @Before
   public void setUp() throws Exception {
-    fc.mkdir(getTestRoot(), FileContext.DEFAULT_PERM, true);
+    fc.mkdir(getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
   }
 
   @After
   public void tearDown() throws Exception {
-    fc.delete(getTestRoot(), true);
+    fc.delete(getTestRootPath(fc), true);
   }
   
   
@@ -100,7 +82,7 @@
   
   @Test
   public void testMkdirNonRecursiveWithExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("aDir");
+    Path f = getTestRootPath(fc, "aDir");
     fc.mkdir(f, FileContext.DEFAULT_PERM, false);
     Assert.assertTrue(fc.isDirectory(f));
   }
@@ -108,7 +90,7 @@
   @Test
   public void testMkdirNonRecursiveWithNonExistingDir() {
     try {
-      fc.mkdir(getTestRootRelativePath("NonExistant/aDir"),
+      fc.mkdir(getTestRootPath(fc,"NonExistant/aDir"),
           FileContext.DEFAULT_PERM, false);
       Assert.fail("Mkdir with non existing parent dir should have failed");
     } catch (IOException e) {
@@ -119,7 +101,7 @@
   
   @Test
   public void testMkdirRecursiveWithExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("aDir");
+    Path f = getTestRootPath(fc, "aDir");
     fc.mkdir(f, FileContext.DEFAULT_PERM, true);
     Assert.assertTrue(fc.isDirectory(f));
   }
@@ -127,7 +109,7 @@
   
   @Test
   public void testMkdirRecursiveWithNonExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("NonExistant2/aDir");
+    Path f = getTestRootPath(fc, "NonExistant2/aDir");
     fc.mkdir(f, FileContext.DEFAULT_PERM, true);
     Assert.assertTrue(fc.isDirectory(f));
   }
@@ -137,15 +119,15 @@
   ////////////////////////
   @Test
   public void testCreateNonRecursiveWithExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("foo");
-    createFile(f);
+    Path f = getTestRootPath(fc, "foo");
+    createFile(fc, f);
     Assert.assertTrue(fc.isFile(f));
   }
   
   @Test
   public void testCreateNonRecursiveWithNonExistingDir() {
     try {
-      createFile(getTestRootRelativePath("NonExisting/foo"));
+      createFileNonRecursive(fc, getTestRootPath(fc, "NonExisting/foo"));
       Assert.fail("Create with non existing parent dir should have failed");
     } catch (IOException e) {
       // As expected
@@ -155,36 +137,16 @@
   
   @Test
   public void testCreateRecursiveWithExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("foo");
-    createFile(f, CreateOpts.createParent());
+    Path f = getTestRootPath(fc,"foo");
+    createFile(fc, f);
     Assert.assertTrue(fc.isFile(f));
   }
   
   
   @Test
   public void testCreateRecursiveWithNonExistingDir() throws IOException {
-    Path f = getTestRootRelativePath("NonExisting/foo");
-    createFile(f, CreateOpts.createParent());
+    Path f = getTestRootPath(fc,"NonExisting/foo");
+    createFile(fc, f);
     Assert.assertTrue(fc.isFile(f));
   }
-  
-  
-  protected static int getBlockSize() {
-    return 1024;
-  }
-  
-  private static byte[] data = new byte[getBlockSize() * 2]; // two blocks of data
-  {
-    for (int i = 0; i < data.length; i++) {
-      data[i] = (byte) (i % 10);
-    }
-  }
-
-  protected void createFile(Path path, 
-      CreateOpts.CreateParent ... opt) throws IOException {
-    
-    FSDataOutputStream out = fc.create(path,EnumSet.of(CreateFlag.CREATE), opt);
-    out.write(data, 0, data.length);
-    out.close();
-  }
 }

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java Thu Jan  7 22:04:37 2010
@@ -30,6 +30,8 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+
 /**
  * <p>
  * A collection of tests for the {@link FileContext}.
@@ -55,38 +57,10 @@
   private static String TEST_DIR_AAA = "test/hadoop/aaa";
   private static String TEST_DIR_AXA = "test/hadoop/axa";
   private static String TEST_DIR_AXX = "test/hadoop/axx";
+  private static int numBlocks = 2;
   
   static  final String LOCAL_FS_ROOT_URI = "file:///tmp/test";
   
-  static final String TEST_ROOT_DIR = 
-    System.getProperty("test.build.data", "build/test/data").replace(' ', '_');
-  
-  
-  /** 
-   * we need to store the absRootDir because some tests may do a setWd and
-   * the TEST_ROOT_DIR may itself be relative.
-   */
-  String absTestRootDir = null;
-  protected String getAbsoluteTestRootDir() throws IOException {
-    if (absTestRootDir == null) {
-      if (TEST_ROOT_DIR.startsWith("/")) {
-        absTestRootDir = TEST_ROOT_DIR;
-      } else {
-        absTestRootDir = getDefaultWorkingDirectory().toString() +  "/"  + 
-                      TEST_ROOT_DIR; 
-      }
-    }
-    return absTestRootDir;
-  }
-  
-  protected Path getTestRootDir() throws IOException {
-    return fc.makeQualified(new Path(getAbsoluteTestRootDir()));
-  }
-  
-  protected Path getTestRootPath(String pathString) throws IOException {
-    return fc.makeQualified(new Path(getAbsoluteTestRootDir(), pathString));
-  }
-
   
   protected static FileContext fc;
   
@@ -106,31 +80,25 @@
     }     
   };
   
-  private static byte[] data = new byte[getBlockSize() * 2]; // two blocks of data
-  {
-    for (int i = 0; i < data.length; i++) {
-      data[i] = (byte) (i % 10);
-    }
-  }
+  private static byte[] data = getFileData(numBlocks,
+      getDefaultBlockSize());
   
   @Before
   public void setUp() throws Exception {
-    fc.mkdir(getTestRootPath("test"), FileContext.DEFAULT_PERM, true);
+    fc.mkdir(getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
   }
   
   @After
   public void tearDown() throws Exception {
-    fc.delete(getTestRootPath("test"), true);
+    fc.delete(getTestRootPath(fc, "test"), true);
     fc.delete(new Path(LOCAL_FS_ROOT_URI), true);
   }
   
-  protected static int getBlockSize() {
-    return 1024;
-  }
   
   protected Path getDefaultWorkingDirectory() throws IOException {
-    return getTestRootPath("/user/" + System.getProperty("user.name")).makeQualified(
-              fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory());
+    return getTestRootPath(fc,
+        "/user/" + System.getProperty("user.name")).makeQualified(
+        fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory());
   }
 
   protected boolean renameSupported() {
@@ -156,7 +124,7 @@
   public void testWorkingDirectory() throws Exception {
 
     // First we cd to our test root
-    Path workDir = new Path(getTestRootDir(), new Path("test"));
+    Path workDir = new Path(getTestRootDir(fc), new Path("test"));
     fc.setWorkingDirectory(workDir);
     Assert.assertEquals(workDir, fc.getWorkingDirectory());
 
@@ -169,7 +137,7 @@
     // cd using a relative path
 
     // Go back to our test root
-    workDir = new Path(getTestRootDir(), new Path("test"));
+    workDir = getTestRootPath(fc, "test");
     fc.setWorkingDirectory(workDir);
     Assert.assertEquals(workDir, fc.getWorkingDirectory());
     
@@ -177,10 +145,9 @@
     Path absoluteDir = new Path(workDir,"existingDir1");
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.setWorkingDirectory(relativeDir);
-    Assert.assertEquals(absoluteDir,
-                                        fc.getWorkingDirectory());
+    Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
     // cd using a absolute path
-    absoluteDir = getTestRootPath("test/existingDir2");
+    absoluteDir = getTestRootPath(fc, "test/existingDir2");
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.setWorkingDirectory(absoluteDir);
     Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
@@ -190,7 +157,7 @@
     fc.create(absolutePath, EnumSet.of(CreateFlag.CREATE)).close();
     fc.open(new Path("foo")).close();
 
-    absoluteDir = getTestRootPath("nonexistingPath");
+    absoluteDir = getTestRootPath(fc, "nonexistingPath");
     try {
       fc.setWorkingDirectory(absoluteDir);
       Assert.fail("cd to non existing dir should have failed");
@@ -209,7 +176,7 @@
   
   @Test
   public void testMkdirs() throws Exception {
-    Path testDir = getTestRootPath("test/hadoop");
+    Path testDir = getTestRootPath(fc, "test/hadoop");
     Assert.assertFalse(fc.exists(testDir));
     Assert.assertFalse(fc.isFile(testDir));
 
@@ -235,14 +202,14 @@
   
   @Test
   public void testMkdirsFailsForSubdirectoryOfExistingFile() throws Exception {
-    Path testDir = getTestRootPath("test/hadoop");
+    Path testDir = getTestRootPath(fc, "test/hadoop");
     Assert.assertFalse(fc.exists(testDir));
     fc.mkdir(testDir, FsPermission.getDefault(), true);
     Assert.assertTrue(fc.exists(testDir));
     
-    createFile(getTestRootPath("test/hadoop/file"));
+    createFile(getTestRootPath(fc, "test/hadoop/file"));
     
-    Path testSubDir = getTestRootPath("test/hadoop/file/subdir");
+    Path testSubDir = getTestRootPath(fc, "test/hadoop/file/subdir");
     try {
       fc.mkdir(testSubDir, FsPermission.getDefault(), true);
       Assert.fail("Should throw IOException.");
@@ -251,7 +218,7 @@
     }
     Assert.assertFalse(fc.exists(testSubDir));
     
-    Path testDeepSubDir = getTestRootPath("test/hadoop/file/deep/sub/dir");
+    Path testDeepSubDir = getTestRootPath(fc, "test/hadoop/file/deep/sub/dir");
     try {
       fc.mkdir(testDeepSubDir, FsPermission.getDefault(), true);
       Assert.fail("Should throw IOException.");
@@ -266,7 +233,7 @@
   public void testGetFileStatusThrowsExceptionForNonExistentFile() 
     throws Exception {
     try {
-      fc.getFileStatus(getTestRootPath("test/hadoop/file"));
+      fc.getFileStatus(getTestRootPath(fc, "test/hadoop/file"));
       Assert.fail("Should throw FileNotFoundException");
     } catch (FileNotFoundException e) {
       // expected
@@ -276,7 +243,7 @@
   public void testListStatusThrowsExceptionForNonExistentFile()
                                                     throws Exception {
     try {
-      fc.listStatus(getTestRootPath("test/hadoop/file"));
+      fc.listStatus(getTestRootPath(fc, "test/hadoop/file"));
       Assert.fail("Should throw FileNotFoundException");
     } catch (FileNotFoundException fnfe) {
       // expected
@@ -285,36 +252,41 @@
   
   @Test
   public void testListStatus() throws Exception {
-    Path[] testDirs = { getTestRootPath("test/hadoop/a"),
-                        getTestRootPath("test/hadoop/b"),
-                        getTestRootPath("test/hadoop/c/1"), };
+    Path[] testDirs = {
+        getTestRootPath(fc, "test/hadoop/a"),
+        getTestRootPath(fc, "test/hadoop/b"),
+        getTestRootPath(fc, "test/hadoop/c/1"), };
     Assert.assertFalse(fc.exists(testDirs[0]));
 
     for (Path path : testDirs) {
       fc.mkdir(path, FsPermission.getDefault(), true);
     }
 
-    FileStatus[] paths = fc.listStatus(getTestRootPath("test"));
+    FileStatus[] paths = fc.listStatus(getTestRootPath(fc, "test"));
     Assert.assertEquals(1, paths.length);
-    Assert.assertEquals(getTestRootPath("test/hadoop"), paths[0].getPath());
+    Assert.assertEquals(getTestRootPath(fc, "test/hadoop"), paths[0].getPath());
 
-    paths = fc.listStatus(getTestRootPath("test/hadoop"));
+    paths = fc.listStatus(getTestRootPath(fc, "test/hadoop"));
     Assert.assertEquals(3, paths.length);
 
-    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/a"), paths));
-    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/b"), paths));
-    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop/c"), paths));
-  
-    paths = fc.listStatus(getTestRootPath("test/hadoop/a"));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, "test/hadoop/a"),
+        paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, "test/hadoop/b"),
+        paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, "test/hadoop/c"),
+        paths));
+
+    paths = fc.listStatus(getTestRootPath(fc, "test/hadoop/a"));
     Assert.assertEquals(0, paths.length);
   }
   
   @Test
   public void testListStatusFilterWithNoMatches() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA2),
-                        getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA2),
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX), };
     
    if (fc.exists(testDirs[0]) == false) {
      for (Path path : testDirs) {
@@ -322,18 +294,19 @@
      }
    }
 
-    //listStatus with filters returns empty correctly
-    FileStatus[] filteredPaths = fc.util().listStatus(getTestRootPath("test"), 
-                                                      TEST_X_FILTER);
+    // listStatus with filters returns empty correctly
+    FileStatus[] filteredPaths = fc.util().listStatus(
+        getTestRootPath(fc, "test"), TEST_X_FILTER);
     Assert.assertEquals(0,filteredPaths.length);
     
   }
   
   public void testListStatusFilterWithSomeMatches() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AAA2), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -341,19 +314,23 @@
       }
     }
 
-    //should return 2 paths ("/test/hadoop/axa" and "/test/hadoop/axx")
-    FileStatus[] filteredPaths = fc.util().listStatus(getTestRootPath("test/hadoop"), 
-                                                      TEST_X_FILTER);
+    // should return 2 paths ("/test/hadoop/axa" and "/test/hadoop/axx")
+    FileStatus[] filteredPaths = fc.util()
+        .listStatus(getTestRootPath(fc, "test/hadoop"),
+            TEST_X_FILTER);
     Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
   public void testGlobStatusThrowsExceptionForNonExistentFile() throws Exception {
     try {
-      //This should throw a FileNotFoundException
-      fc.util().globStatus(getTestRootPath("test/hadoopfsdf/?"));
+      // This should throw a FileNotFoundException
+      fc.util().globStatus(
+          getTestRootPath(fc, "test/hadoopfsdf/?"));
       Assert.fail("Should throw FileNotFoundException");
     } catch (FileNotFoundException fnfe) {
       // expected
@@ -362,10 +339,11 @@
   
   @Test
   public void testGlobStatusWithNoMatchesInPath() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AAA2), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -373,17 +351,19 @@
       }
     }
 
-    //should return nothing
-    FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop/?"));
+    // should return nothing
+    FileStatus[] paths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/?"));
     Assert.assertEquals(0, paths.length);
   }
   
   @Test
   public void testGlobStatusSomeMatchesInDirectories() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AAA2), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -391,19 +371,23 @@
       }
     }
     
-    //Should return two items ("/test/hadoop" and "/test/hadoop2")
-    FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop*"));
+    // Should return two items ("/test/hadoop" and "/test/hadoop2")
+    FileStatus[] paths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop*"));
     Assert.assertEquals(2, paths.length);
-    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop"), paths));
-    Assert.assertTrue(containsPath(getTestRootPath("test/hadoop2"), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        "test/hadoop"), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        "test/hadoop2"), paths));
   }
   
   @Test
   public void testGlobStatusWithMultipleWildCardMatches() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AAA2), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -413,20 +397,22 @@
 
     //Should return all 4 items ("/test/hadoop/aaa", "/test/hadoop/axa"
     //"/test/hadoop/axx", and "/test/hadoop2/axx")
-    FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop*/*"));
+    FileStatus[] paths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop*/*"));
     Assert.assertEquals(4, paths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), paths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), paths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), paths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA2), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AAA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXX), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AAA2), paths));
   }
   
   @Test
   public void testGlobStatusWithMultipleMatchesOfSingleChar() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AAA2), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AAA2), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -435,18 +421,22 @@
     }
     
     //Should return only 2 items ("/test/hadoop/axa", "/test/hadoop/axx")
-    FileStatus[] paths = fc.util().globStatus(getTestRootPath("test/hadoop/ax?"));
+    FileStatus[] paths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/ax?"));
     Assert.assertEquals(2, paths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), paths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXA), paths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXX), paths));
   }
   
   @Test
   public void testGlobStatusFilterWithEmptyPathResults() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -455,17 +445,20 @@
     }
     
     //This should return an empty set
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/?"), 
-                                                      DEFAULT_FILTER);
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/?"),
+        DEFAULT_FILTER);
     Assert.assertEquals(0,filteredPaths.length);
   }
   
   @Test
-  public void testGlobStatusFilterWithSomePathMatchesAndTrivialFilter() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+  public void testGlobStatusFilterWithSomePathMatchesAndTrivialFilter()
+      throws Exception {
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -474,20 +467,26 @@
     }
     
     //This should return all three (aaa, axa, axx)
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/*"), 
-                                                      DEFAULT_FILTER);  
-    Assert.assertEquals(3,filteredPaths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/*"),
+        DEFAULT_FILTER);
+    Assert.assertEquals(3, filteredPaths.length);
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AAA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
-  public void testGlobStatusFilterWithMultipleWildCardMatchesAndTrivialFilter() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+  public void testGlobStatusFilterWithMultipleWildCardMatchesAndTrivialFilter()
+      throws Exception {
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -496,20 +495,26 @@
     }
     
     //This should return all three (aaa, axa, axx)
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/a??"), 
-                                                      DEFAULT_FILTER);
-    Assert.assertEquals(3,filteredPaths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AAA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/a??"),
+        DEFAULT_FILTER);
+    Assert.assertEquals(3, filteredPaths.length);
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AAA),
+        filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXA),
+        filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXX),
+        filteredPaths));
   }
   
   @Test
-  public void testGlobStatusFilterWithMultiplePathMatchesAndNonTrivialFilter() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+  public void testGlobStatusFilterWithMultiplePathMatchesAndNonTrivialFilter()
+      throws Exception {
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -518,19 +523,24 @@
     }
     
     //This should return two (axa, axx)
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/*"), 
-                                                      TEST_X_FILTER);  
-    Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/*"),
+        TEST_X_FILTER);
+    Assert.assertEquals(2, filteredPaths.length);
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXA), filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc,
+        TEST_DIR_AXX), filteredPaths));
   }
   
   @Test
-  public void testGlobStatusFilterWithNoMatchingPathsAndNonTrivialFilter() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+  public void testGlobStatusFilterWithNoMatchingPathsAndNonTrivialFilter()
+      throws Exception {
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -539,17 +549,20 @@
     }
     
     //This should return an empty set
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/?"), 
-                                                      TEST_X_FILTER);
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/?"),
+        TEST_X_FILTER);
     Assert.assertEquals(0,filteredPaths.length);
   }
   
   @Test
-  public void testGlobStatusFilterWithMultiplePathWildcardsAndNonTrivialFilter() throws Exception {
-    Path[] testDirs = { getTestRootPath(TEST_DIR_AAA),
-                        getTestRootPath(TEST_DIR_AXA),
-                        getTestRootPath(TEST_DIR_AXX),
-                        getTestRootPath(TEST_DIR_AXX), };
+  public void testGlobStatusFilterWithMultiplePathWildcardsAndNonTrivialFilter()
+      throws Exception {
+    Path[] testDirs = {
+        getTestRootPath(fc, TEST_DIR_AAA),
+        getTestRootPath(fc, TEST_DIR_AXA),
+        getTestRootPath(fc, TEST_DIR_AXX),
+        getTestRootPath(fc, TEST_DIR_AXX), };
 
     if (fc.exists(testDirs[0]) == false) {
       for (Path path : testDirs) {
@@ -558,11 +571,14 @@
     }
     
     //This should return two (axa, axx)
-    FileStatus[] filteredPaths = fc.util().globStatus(getTestRootPath("test/hadoop/a??"), 
-                                                      TEST_X_FILTER);
-    Assert.assertEquals(2,filteredPaths.length);
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXA), filteredPaths));
-    Assert.assertTrue(containsPath(getTestRootPath(TEST_DIR_AXX), filteredPaths));
+    FileStatus[] filteredPaths = fc.util().globStatus(
+        getTestRootPath(fc, "test/hadoop/a??"),
+        TEST_X_FILTER);
+    Assert.assertEquals(2, filteredPaths.length);
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXA),
+        filteredPaths));
+    Assert.assertTrue(containsPath(getTestRootPath(fc, TEST_DIR_AXX),
+        filteredPaths));
   }
   
   @Test
@@ -572,31 +588,33 @@
 
   @Test
   public void testWriteReadAndDeleteHalfABlock() throws Exception {
-    writeReadAndDelete(getBlockSize() / 2);
+    writeReadAndDelete(getDefaultBlockSize() / 2);
   }
 
   @Test
   public void testWriteReadAndDeleteOneBlock() throws Exception {
-    writeReadAndDelete(getBlockSize());
+    writeReadAndDelete(getDefaultBlockSize());
   }
   
   @Test
   public void testWriteReadAndDeleteOneAndAHalfBlocks() throws Exception {
-    writeReadAndDelete(getBlockSize() + (getBlockSize() / 2));
+    int blockSize = getDefaultBlockSize();
+    writeReadAndDelete(blockSize + (blockSize / 2));
   }
   
   @Test
   public void testWriteReadAndDeleteTwoBlocks() throws Exception {
-    writeReadAndDelete(getBlockSize() * 2);
+    writeReadAndDelete(getDefaultBlockSize() * 2);
   }
   
   private void writeReadAndDelete(int len) throws IOException {
-    Path path = getTestRootPath("test/hadoop/file");
+    Path path = getTestRootPath(fc, "test/hadoop/file");
     
     fc.mkdir(path.getParent(), FsPermission.getDefault(), true);
 
-    FSDataOutputStream out = fc.create(path, EnumSet.of(CreateFlag.CREATE), 
-        CreateOpts.repFac((short) 1), CreateOpts.blockSize(getBlockSize()));
+    FSDataOutputStream out = fc.create(path, EnumSet.of(CreateFlag.CREATE),
+        CreateOpts.repFac((short) 1), CreateOpts
+            .blockSize(getDefaultBlockSize()));
     out.write(data, 0, len);
     out.close();
 
@@ -621,7 +639,7 @@
   
   @Test
   public void testOverwrite() throws IOException {
-    Path path = getTestRootPath("test/hadoop/file");
+    Path path = getTestRootPath(fc, "test/hadoop/file");
     
     fc.mkdir(path.getParent(), FsPermission.getDefault(), true);
 
@@ -648,7 +666,7 @@
   
   @Test
   public void testWriteInNonExistentDirectory() throws IOException {
-    Path path = getTestRootPath("test/hadoop/file");
+    Path path = getTestRootPath(fc, "test/hadoop/file");
     Assert.assertFalse("Parent doesn't exist", fc.exists(path.getParent()));
     createFile(path);
     
@@ -659,16 +677,16 @@
 
   @Test
   public void testDeleteNonExistentFile() throws IOException {
-    Path path = getTestRootPath("test/hadoop/file");    
+    Path path = getTestRootPath(fc, "test/hadoop/file");    
     Assert.assertFalse("Doesn't exist", fc.exists(path));
     Assert.assertFalse("No deletion", fc.delete(path, true));
   }
   
   @Test
   public void testDeleteRecursively() throws IOException {
-    Path dir = getTestRootPath("test/hadoop");
-    Path file = getTestRootPath("test/hadoop/file");
-    Path subdir = getTestRootPath("test/hadoop/subdir");
+    Path dir = getTestRootPath(fc, "test/hadoop");
+    Path file = getTestRootPath(fc, "test/hadoop/file");
+    Path subdir = getTestRootPath(fc, "test/hadoop/subdir");
     
     createFile(file);
     fc.mkdir(subdir,FsPermission.getDefault(), true);
@@ -695,7 +713,7 @@
   
   @Test
   public void testDeleteEmptyDirectory() throws IOException {
-    Path dir = getTestRootPath("test/hadoop");
+    Path dir = getTestRootPath(fc, "test/hadoop");
     fc.mkdir(dir, FsPermission.getDefault(), true);
     Assert.assertTrue("Dir exists", fc.exists(dir));
     Assert.assertTrue("Deleted", fc.delete(dir, false));
@@ -705,8 +723,8 @@
   @Test
   public void testRenameNonExistentPath() throws Exception {
     if (!renameSupported()) return;
-    Path src = getTestRootPath("test/hadoop/nonExistent");
-    Path dst = getTestRootPath("test/new/newpath");
+    Path src = getTestRootPath(fc, "test/hadoop/nonExistent");
+    Path dst = getTestRootPath(fc, "test/new/newpath");
     try {
       rename(src, dst, false, false, false, Rename.NONE);
       Assert.fail("Should throw FileNotFoundException");
@@ -726,9 +744,9 @@
   public void testRenameFileToNonExistentDirectory() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
-    Path dst = getTestRootPath("test/nonExistent/newfile");
+    Path dst = getTestRootPath(fc, "test/nonExistent/newfile");
     
     try {
       rename(src, dst, false, true, false, Rename.NONE);
@@ -749,9 +767,9 @@
   public void testRenameFileToDestinationWithParentFile() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
-    Path dst = getTestRootPath("test/parentFile/newfile");
+    Path dst = getTestRootPath(fc, "test/parentFile/newfile");
     createFile(dst.getParent());
     
     try {
@@ -771,9 +789,9 @@
   public void testRenameFileToExistingParent() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
-    Path dst = getTestRootPath("test/new/newfile");
+    Path dst = getTestRootPath(fc, "test/new/newfile");
     fc.mkdir(dst.getParent(), FileContext.DEFAULT_PERM, true);
     rename(src, dst, true, false, true, Rename.OVERWRITE);
   }
@@ -782,9 +800,9 @@
   public void testRenameFileAsExistingFile() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
-    Path dst = getTestRootPath("test/new/existingFile");
+    Path dst = getTestRootPath(fc, "test/new/existingFile");
     createFile(dst);
     
     // Fails without overwrite option
@@ -803,9 +821,9 @@
   public void testRenameFileAsExistingDirectory() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
-    Path dst = getTestRootPath("test/new/existingDir");
+    Path dst = getTestRootPath(fc, "test/new/existingDir");
     fc.mkdir(dst, FileContext.DEFAULT_PERM, true);
     
     // Fails without overwrite option
@@ -827,9 +845,9 @@
   public void testRenameDirectoryToNonExistentParent() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/dir");
+    Path src = getTestRootPath(fc, "test/hadoop/dir");
     fc.mkdir(src, FileContext.DEFAULT_PERM, true);
-    Path dst = getTestRootPath("test/nonExistent/newdir");
+    Path dst = getTestRootPath(fc, "test/nonExistent/newdir");
     
     try {
       rename(src, dst, false, true, false, Rename.NONE);
@@ -856,37 +874,37 @@
   private void testRenameDirectoryAsNonExistentDirectory(Rename... options) throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/dir");
+    Path src = getTestRootPath(fc, "test/hadoop/dir");
     fc.mkdir(src, FileContext.DEFAULT_PERM, true);
-    createFile(getTestRootPath("test/hadoop/dir/file1"));
-    createFile(getTestRootPath("test/hadoop/dir/subdir/file2"));
+    createFile(getTestRootPath(fc, "test/hadoop/dir/file1"));
+    createFile(getTestRootPath(fc, "test/hadoop/dir/subdir/file2"));
     
-    Path dst = getTestRootPath("test/new/newdir");
+    Path dst = getTestRootPath(fc, "test/new/newdir");
     fc.mkdir(dst.getParent(), FileContext.DEFAULT_PERM, true);
     
     rename(src, dst, true, false, true, options);
-    Assert.assertFalse("Nested file1 exists",
-        fc.exists(getTestRootPath("test/hadoop/dir/file1")));
-    Assert.assertFalse("Nested file2 exists",
-        fc.exists(getTestRootPath("test/hadoop/dir/subdir/file2")));
-    Assert.assertTrue("Renamed nested file1 exists",
-        fc.exists(getTestRootPath("test/new/newdir/file1")));
-    Assert.assertTrue("Renamed nested exists",
-        fc.exists(getTestRootPath("test/new/newdir/subdir/file2")));
+    Assert.assertFalse("Nested file1 exists", 
+        fc.exists(getTestRootPath(fc, "test/hadoop/dir/file1")));
+    Assert.assertFalse("Nested file2 exists", 
+        fc.exists(getTestRootPath(fc, "test/hadoop/dir/subdir/file2")));
+    Assert.assertTrue("Renamed nested file1 exists", fc
+        .exists(getTestRootPath(fc, "test/new/newdir/file1")));
+    Assert.assertTrue("Renamed nested exists", 
+        fc.exists(getTestRootPath(fc, "test/new/newdir/subdir/file2")));
   }
 
   @Test
   public void testRenameDirectoryAsNonEmptyDirectory() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/dir");
+    Path src = getTestRootPath(fc, "test/hadoop/dir");
     fc.mkdir(src, FileContext.DEFAULT_PERM, true);
-    createFile(getTestRootPath("test/hadoop/dir/file1"));
-    createFile(getTestRootPath("test/hadoop/dir/subdir/file2"));
+    createFile(getTestRootPath(fc, "test/hadoop/dir/file1"));
+    createFile(getTestRootPath(fc, "test/hadoop/dir/subdir/file2"));
     
-    Path dst = getTestRootPath("test/new/newdir");
+    Path dst = getTestRootPath(fc, "test/new/newdir");
     fc.mkdir(dst, FileContext.DEFAULT_PERM, true);
-    createFile(getTestRootPath("test/new/newdir/file1"));
+    createFile(getTestRootPath(fc, "test/new/newdir/file1"));
     // Fails without overwrite option
     try {
       rename(src, dst, false, true, false, Rename.NONE);
@@ -907,9 +925,9 @@
   public void testRenameDirectoryAsFile() throws Exception {
     if (!renameSupported()) return;
     
-    Path src = getTestRootPath("test/hadoop/dir");
+    Path src = getTestRootPath(fc, "test/hadoop/dir");
     fc.mkdir(src, FileContext.DEFAULT_PERM, true);
-    Path dst = getTestRootPath("test/new/newfile");
+    Path dst = getTestRootPath(fc, "test/new/newfile");
     createFile(dst);
     // Fails without overwrite option
     try {
@@ -929,7 +947,7 @@
   public void testInputStreamClosedTwice() throws IOException {
     //HADOOP-4760 according to Closeable#close() closing already-closed 
     //streams should have no effect. 
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     createFile(src);
     FSDataInputStream in = fc.open(src);
     in.close();
@@ -940,7 +958,7 @@
   public void testOutputStreamClosedTwice() throws IOException {
     //HADOOP-4760 according to Closeable#close() closing already-closed 
     //streams should have no effect. 
-    Path src = getTestRootPath("test/hadoop/file");
+    Path src = getTestRootPath(fc, "test/hadoop/file");
     FSDataOutputStream out = fc.create(src, EnumSet.of(CreateFlag.CREATE),
             Options.CreateOpts.createParent());
     
@@ -955,9 +973,10 @@
     out.write(data, 0, data.length);
     out.close();
   }
-  
+
   private void rename(Path src, Path dst, boolean renameShouldSucceed,
-      boolean srcExists, boolean dstExists, Rename... options) throws IOException {
+      boolean srcExists, boolean dstExists, Rename... options)
+      throws IOException {
     fc.rename(src, dst, options);
     if (!renameShouldSucceed)
       Assert.fail("rename should have thrown exception");
@@ -967,7 +986,8 @@
   private boolean containsPath(Path path, FileStatus[] filteredPaths)
     throws IOException {
     for(int i = 0; i < filteredPaths.length; i ++) { 
-      if(getTestRootPath(path.toString()).equals(filteredPaths[i].getPath())) 
+      if (getTestRootPath(fc, path.toString()).equals(
+          filteredPaths[i].getPath()))
         return true;
       }
     return false;

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java Thu Jan  7 22:04:37 2010
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.EnumSet;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -32,6 +31,8 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+
 /**
  * <p>
  * A collection of permission tests for the {@link FileContext}.
@@ -51,24 +52,8 @@
  *     @AfterClass    public static void ClusterShutdownAtEnd()
  * </p>
  */
-public class FileContextPermissionBase {  
-  static final String TEST_ROOT_DIR = new Path(System.getProperty(
-      "test.build.data", "/tmp")).toString().replace(' ', '_')
-      + "/" + TestLocalFileSystemPermission.class.getSimpleName() + "_";
-  
-  protected Path getTestRootRelativePath(String pathString) {
-    return fc.makeQualified(new Path(TEST_ROOT_DIR, pathString));
-  }
+public abstract class FileContextPermissionBase {  
   
-  private Path rootPath = null;
-  protected Path getTestRootPath() {
-    if (rootPath == null) {
-      rootPath = fc.makeQualified(new Path(TEST_ROOT_DIR));
-    }
-    return rootPath;   
-  }
-
-
   {
     try {
       ((org.apache.commons.logging.impl.Log4JLogger)FileSystem.LOG).getLogger()
@@ -84,23 +69,14 @@
 
   @Before
   public void setUp() throws Exception {
-    fc.mkdir(getTestRootPath(), FileContext.DEFAULT_PERM, true);
+    fc.mkdir(getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
   }
 
   @After
   public void tearDown() throws Exception {
-    fc.delete(getTestRootPath(), true);
+    fc.delete(getTestRootPath(fc), true);
   }
   
-
-  private Path writeFile(FileContext theFc, String name) throws IOException {
-    Path f = getTestRootRelativePath(name);
-    FSDataOutputStream stm = theFc.create(f, EnumSet.of(CreateFlag.CREATE));
-    stm.writeBytes("42\n");
-    stm.close();
-    return f;
-  }
-
   private void cleanupFile(FileContext theFc, Path name) throws IOException {
     Assert.assertTrue(theFc.exists(name));
     theFc.delete(name, true);
@@ -114,7 +90,7 @@
       return;
     }
     String filename = "foo";
-    Path f = writeFile(fc, filename);
+    Path f = createFile(fc, filename);
     doFilePermissionCheck(FileContext.DEFAULT_PERM.applyUMask(fc.getUMask()),
                         fc.getFileStatus(f).getPermission());
   }
@@ -128,7 +104,7 @@
     }
 
     String filename = "foo";
-    Path f = writeFile(fc, filename);
+    Path f = createFile(fc, filename);
 
     try {
       // create files and manipulate them.
@@ -152,7 +128,7 @@
     }
 
     String filename = "bar";
-    Path f = writeFile(fc, filename);
+    Path f = createFile(fc, filename);
     List<String> groups = null;
     try {
       groups = getGroups();

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextURIBase.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextURIBase.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextURIBase.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/FileContextURIBase.java Thu Jan  7 22:04:37 2010
@@ -20,14 +20,16 @@
 
 import java.io.*;
 import java.util.ArrayList;
-import java.util.EnumSet;
 
 import junit.framework.Assert;
 
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+
 /**
  * <p>
  * A collection of tests for the {@link FileContext} to test path names passed
@@ -49,32 +51,18 @@
  */
 public abstract class FileContextURIBase {
   private static final String basePath = System.getProperty("test.build.data",
-      "build/test/data") + "/testContextURI";
+  "build/test/data") + "/testContextURI";
   private static final Path BASE = new Path(basePath);
   protected FileContext fc1;
   protected FileContext fc2;
 
-  private static int BLOCK_SIZE = 1024;
-
-  private static byte[] data = new byte[BLOCK_SIZE * 2]; // two blocks of data
-  {
-    for (int i = 0; i < data.length; i++) {
-      data[i] = (byte) (i % 10);
-    }
-  }
-
   //Helper method to make path qualified
   protected Path qualifiedPath(String path, FileContext fc) {
     return fc.makeQualified(new Path(BASE, path));
   }
 
-  // Helper method to create file and write data to file
-  protected void createFile(Path path, FileContext fc) throws IOException {
-    FSDataOutputStream out = fc.create(path, EnumSet.of(CreateFlag.CREATE),
-        Options.CreateOpts.createParent());
-    out.write(data, 0, data.length);
-    out.close();
-  }
+  @Before
+  public void setUp() throws Exception { }
 
   @After
   public void tearDown() throws Exception {
@@ -100,7 +88,7 @@
       Assert.assertFalse(fc2.exists(testPath));
 
       // Now create file
-      createFile(testPath, fc1);
+      createFile(fc1, testPath);
       // Ensure fc2 has the created file
       Assert.assertTrue(fc2.exists(testPath));
     }
@@ -117,7 +105,7 @@
       Assert.assertFalse(fc2.exists(testPath));
 
       // Create a file on fc2's file system using fc1
-      createFile(testPath, fc1);
+      createFile(fc1, testPath);
       Assert.fail("Create file with null name should throw IllegalArgumentException.");
     } catch (IllegalArgumentException e) {
       // expected
@@ -134,11 +122,11 @@
     Assert.assertFalse(fc2.exists(testPath));
 
     // Create a file on fc2's file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
 
     // Create same file with fc1
     try {
-      createFile(testPath, fc2);
+      createFile(fc2, testPath);
       Assert.fail("Create existing file should throw an IOException.");
     } catch (IOException e) {
       // expected
@@ -158,7 +146,7 @@
     Assert.assertFalse(fc2.exists(testPath));
 
     // Create a file on fc2's file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
 
     // Ensure using fc2 that file is created
     Assert.assertTrue(fc2.isDirectory(testPath.getParent()));
@@ -240,7 +228,7 @@
     Assert.assertTrue(fc2.exists(testDir));
 
     // Create file on fc1 using fc2 context
-    createFile(qualifiedPath("test/hadoop/file", fc2), fc1);
+    createFile(fc1, qualifiedPath("test/hadoop/file", fc2));
 
     Path testSubDir = qualifiedPath("test/hadoop/file/subdir", fc2);
     try {
@@ -292,7 +280,7 @@
     Assert.assertFalse(fc2.exists(testPath));
 
     // First create a file on file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
 
     // Ensure file exist
     Assert.assertTrue(fc2.exists(testPath));
@@ -319,7 +307,7 @@
 
     // TestCase2 : Create , Delete , Delete file
     // Create a file on fc2's file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
     // Ensure file exist
     Assert.assertTrue(fc2.exists(testPath));
 
@@ -346,7 +334,7 @@
 
     // TestCase2 : Create , Delete , Delete file
     // Create a file on fc2's file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
     // Ensure file exist
     Assert.assertTrue(fc2.exists(testPath));
 
@@ -440,7 +428,7 @@
     Path testPath = qualifiedPath(testFile, fc2);
 
     // Create a file on fc2's file system using fc1
-    createFile(testPath, fc1);
+    createFile(fc1, testPath);
     // Get modification time using fc2 and fc1
     fc1ModificationTime = fc1.getFileStatus(testPath).getModificationTime();
     fc2ModificationTime = fc2.getFileStatus(testPath).getModificationTime();
@@ -454,7 +442,7 @@
     Path path2 = fc2.makeQualified(new Path(BASE, fileName));
 
     // Create a file on fc2's file system using fc1
-    createFile(path2, fc1);
+    createFile(fc1, path2);
     FsStatus fc2Status = fc2.getFsStatus(path2);
 
     // FsStatus , used, free and capacity are non-negative longs

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestChecksumFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestChecksumFileSystem.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestChecksumFileSystem.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestChecksumFileSystem.java Thu Jan  7 22:04:37 2010
@@ -26,6 +26,9 @@
 import junit.framework.TestCase;
 
 public class TestChecksumFileSystem extends TestCase {
+  static final String TEST_ROOT_DIR
+    = System.getProperty("test.build.data","build/test/data/work-dir/localfs");
+
   public void testgetChecksumLength() throws Exception {
     assertEquals(8, ChecksumFileSystem.getChecksumLength(0L, 512));
     assertEquals(12, ChecksumFileSystem.getChecksumLength(1L, 512));
@@ -38,10 +41,7 @@
                  ChecksumFileSystem.getChecksumLength(10000000000000L, 10));    
   } 
   
-  public void testVerifyChecksum() throws Exception {
-    String TEST_ROOT_DIR
-    = System.getProperty("test.build.data","build/test/data/work-dir/localfs");
-    
+  public void testVerifyChecksum() throws Exception {    
     Configuration conf = new Configuration();
     LocalFileSystem localFs = FileSystem.getLocal(conf);
     Path testPath = new Path(TEST_ROOT_DIR, "testPath");
@@ -54,9 +54,15 @@
     fout.write("testing you".getBytes());
     fout.close();
 
+    // Exercise some boundary cases - a divisor of the chunk size
+    // the chunk size, 2x chunk size, and +/-1 around these.
     TestLocalFileSystem.readFile(localFs, testPath, 128);
+    TestLocalFileSystem.readFile(localFs, testPath, 511);
     TestLocalFileSystem.readFile(localFs, testPath, 512);
+    TestLocalFileSystem.readFile(localFs, testPath, 513);
+    TestLocalFileSystem.readFile(localFs, testPath, 1023);
     TestLocalFileSystem.readFile(localFs, testPath, 1024);
+    TestLocalFileSystem.readFile(localFs, testPath, 1025);
 
     localFs.delete(localFs.getChecksumFile(testPath), true);
     assertTrue("checksum deleted", !localFs.exists(localFs.getChecksumFile(testPath)));
@@ -75,9 +81,80 @@
     assertTrue("error reading", errorRead);
     
     //now setting verify false, the read should succeed
-    localFs.setVerifyChecksum(false);
-    String str = TestLocalFileSystem.readFile(localFs, testPath, 1024);
-    assertTrue("read", "testing".equals(str));
+    try {
+      localFs.setVerifyChecksum(false);
+      String str = TestLocalFileSystem.readFile(localFs, testPath, 1024);
+      assertTrue("read", "testing".equals(str));
+    } finally {
+      // reset for other tests
+      localFs.setVerifyChecksum(true);
+    }
     
   }
+
+  public void testMultiChunkFile() throws Exception {
+    Configuration conf = new Configuration();
+    LocalFileSystem localFs = FileSystem.getLocal(conf);
+    Path testPath = new Path(TEST_ROOT_DIR, "testMultiChunk");
+    FSDataOutputStream fout = localFs.create(testPath);
+    for (int i = 0; i < 1000; i++) {
+      fout.write(("testing" + i).getBytes());
+    }
+    fout.close();
+
+    // Exercise some boundary cases - a divisor of the chunk size
+    // the chunk size, 2x chunk size, and +/-1 around these.
+    TestLocalFileSystem.readFile(localFs, testPath, 128);
+    TestLocalFileSystem.readFile(localFs, testPath, 511);
+    TestLocalFileSystem.readFile(localFs, testPath, 512);
+    TestLocalFileSystem.readFile(localFs, testPath, 513);
+    TestLocalFileSystem.readFile(localFs, testPath, 1023);
+    TestLocalFileSystem.readFile(localFs, testPath, 1024);
+    TestLocalFileSystem.readFile(localFs, testPath, 1025);
+  }
+
+  /**
+   * Test to ensure that if the checksum file is truncated, a
+   * ChecksumException is thrown
+   */
+  public void testTruncatedChecksum() throws Exception { 
+    Configuration conf = new Configuration();
+    LocalFileSystem localFs = FileSystem.getLocal(conf);
+    Path testPath = new Path(TEST_ROOT_DIR, "testtruncatedcrc");
+    FSDataOutputStream fout = localFs.create(testPath);
+    fout.write("testing truncation".getBytes());
+    fout.close();
+
+    // Read in the checksum
+    Path checksumFile = localFs.getChecksumFile(testPath);
+    FileSystem rawFs = localFs.getRawFileSystem();
+    FSDataInputStream checksumStream = rawFs.open(checksumFile);
+    byte buf[] = new byte[8192];
+    int read = checksumStream.read(buf, 0, buf.length);
+    checksumStream.close();
+
+    // Now rewrite the checksum file with the last byte missing
+    FSDataOutputStream replaceStream = rawFs.create(checksumFile);
+    replaceStream.write(buf, 0, read - 1);
+    replaceStream.close();
+
+    // Now reading the file should fail with a ChecksumException
+    try {
+      TestLocalFileSystem.readFile(localFs, testPath, 1024);
+      fail("Did not throw a ChecksumException when reading truncated " +
+           "crc file");
+    } catch(ChecksumException ie) {
+    }
+
+    // telling it not to verify checksums, should avoid issue.
+    try {
+      localFs.setVerifyChecksum(false);
+      String str = TestLocalFileSystem.readFile(localFs, testPath, 1024);
+      assertTrue("read", "testing truncation".equals(str));
+    } finally {
+      // reset for other tests
+      localFs.setVerifyChecksum(true);
+    }
+
+  }
 }

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestDFVariations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestDFVariations.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestDFVariations.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestDFVariations.java Thu Jan  7 22:04:37 2010
@@ -51,10 +51,6 @@
   public void testOSParsing() throws Exception {
     for (DF.OSType ost : EnumSet.allOf(DF.OSType.class)) {
       XXDF df = new XXDF(ost.getId());
-      assertEquals(ost.getId() + " total", 453115160 * 1024L, df.getCapacity());
-      assertEquals(ost.getId() + " used", 53037920 * 1024L, df.getUsed());
-      assertEquals(ost.getId() + " avail", 400077240 * 1024L, df.getAvailable());
-      assertEquals(ost.getId() + " pcnt used", 11, df.getPercentUsed());
       assertEquals(ost.getId() + " mount", "/foo/bar", df.getMount());
     }
   }

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java Thu Jan  7 22:04:37 2010
@@ -18,29 +18,21 @@
 package org.apache.hadoop.fs;
 
 import java.io.IOException;
-import java.util.EnumSet;
 import java.util.Set;
 
 import junit.framework.Assert;
-
-import org.apache.hadoop.fs.Options.CreateOpts;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.hadoop.fs.FileContextTestHelper.*;
+
 /**
  * Tests {@link FileContext.#deleteOnExit(Path)} functionality.
  */
 public class TestFileContextDeleteOnExit {
-  private static String TEST_ROOT_DIR =
-    System.getProperty("test.build.data", "/tmp") + "/test";
-  
-  private static byte[] data = new byte[1024 * 2]; // two blocks of data
-  {
-    for (int i = 0; i < data.length; i++) {
-      data[i] = (byte) (i % 10);
-    }
-  }
+  private static int blockSize = 1024;
+  private static int numBlocks = 2;
   
   private FileContext fc;
   
@@ -51,23 +43,9 @@
   
   @After
   public void tearDown() throws IOException {
-    fc.delete(getTestRootPath(), true);
+    fc.delete(getTestRootPath(fc), true);
   }
   
-  private Path getTestRootPath() {
-    return fc.makeQualified(new Path(TEST_ROOT_DIR));
-  }
-  
-  private Path getTestPath(String pathString) {
-    return fc.makeQualified(new Path(TEST_ROOT_DIR, pathString));
-  }
-  
-  private void createFile(FileContext fc, Path path) throws IOException {
-    FSDataOutputStream out = fc.create(path, EnumSet.of(CreateFlag.CREATE),
-        CreateOpts.createParent());
-    out.write(data, 0, data.length);
-    out.close();
-  }
   
   private void checkDeleteOnExitData(int size, FileContext fc, Path... paths) {
     Assert.assertEquals(size, FileContext.DELETE_ON_EXIT.size());
@@ -81,21 +59,21 @@
   @Test
   public void testDeleteOnExit() throws Exception {
     // Create deleteOnExit entries
-    Path file1 = getTestPath("file1");
-    createFile(fc, file1);
+    Path file1 = getTestRootPath(fc, "file1");
+    createFile(fc, file1, numBlocks, blockSize);
     fc.deleteOnExit(file1);
     checkDeleteOnExitData(1, fc, file1);
     
     // Ensure shutdown hook is added
     Assert.assertTrue(Runtime.getRuntime().removeShutdownHook(FileContext.FINALIZER));
     
-    Path file2 = getTestPath("dir1/file2");
-    createFile(fc, file2);
+    Path file2 = getTestRootPath(fc, "dir1/file2");
+    createFile(fc, file2, numBlocks, blockSize);
     fc.deleteOnExit(file2);
     checkDeleteOnExitData(1, fc, file1, file2);
     
-    Path dir = getTestPath("dir3/dir4/dir5/dir6");
-    createFile(fc, dir);
+    Path dir = getTestRootPath(fc, "dir3/dir4/dir5/dir6");
+    createFile(fc, dir, numBlocks, blockSize);
     fc.deleteOnExit(dir);
     checkDeleteOnExitData(1, fc, file1, file2, dir);
     

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java Thu Jan  7 22:04:37 2010
@@ -19,12 +19,14 @@
 package org.apache.hadoop.fs.s3native;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystemContractBaseTest;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.s3native.NativeS3FileSystem.NativeS3FsInputStream;
 
 public abstract class NativeS3FileSystemContractBaseTest
   extends FileSystemContractBaseTest {
@@ -148,5 +150,79 @@
     assertEquals("Double default block size", newBlockSize,
     fs.getFileStatus(file).getBlockSize());
   }
+  
+  public void testRetryOnIoException() throws Exception {
+    class TestInputStream extends InputStream {
+      boolean shouldThrow = false;
+      int throwCount = 0;
+      int pos = 0;
+      byte[] bytes;
+      
+      public TestInputStream() {
+        bytes = new byte[256];
+        for (int i = 0; i < 256; i++) {
+          bytes[i] = (byte)i;
+        }
+      }
+      
+      @Override
+      public int read() throws IOException {
+        shouldThrow = !shouldThrow;
+        if (shouldThrow) {
+          throwCount++;
+          throw new IOException();
+        }
+        return pos++;
+      }
+      
+      @Override
+      public int read(byte[] b, int off, int len) throws IOException {
+        shouldThrow = !shouldThrow;
+        if (shouldThrow) {
+          throwCount++;
+          throw new IOException();
+        }
+        
+        int sizeToRead = Math.min(len, 256 - pos);
+        for (int i = 0; i < sizeToRead; i++) {
+          b[i] = bytes[pos + i];
+        }
+        pos += sizeToRead;
+        return sizeToRead;
+      }
+    }
+    
+    final InputStream is = new TestInputStream();
+    
+    class MockNativeFileSystemStore extends Jets3tNativeFileSystemStore {
+      @Override
+      public InputStream retrieve(String key, long byteRangeStart) throws IOException {
+        return is;
+      }
+    }
+    
+    NativeS3FsInputStream stream = new NativeS3FsInputStream(new MockNativeFileSystemStore(), null, is, "");
+    
+    // Test reading methods.
+    byte[] result = new byte[256];
+    for (int i = 0; i < 128; i++) {
+      result[i] = (byte)stream.read();
+    }
+    for (int i = 128; i < 256; i += 8) {
+      byte[] temp = new byte[8];
+      int read = stream.read(temp, 0, 8);
+      assertEquals(8, read);
+      System.arraycopy(temp, 0, result, i, 8);
+    }
+    
+    // Assert correct
+    for (int i = 0; i < 256; i++) {
+      assertEquals((byte)i, result[i]);
+    }
+    
+    // Test to make sure the throw path was exercised.
+    // 144 = 128 + (128 / 8)
+    assertEquals(144, ((TestInputStream)is).throwCount);
+  }
 
 }

Modified: hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/io/TestUTF8.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/io/TestUTF8.java?rev=897029&r1=897028&r2=897029&view=diff
==============================================================================
--- hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/io/TestUTF8.java (original)
+++ hadoop/common/branches/HADOOP-6194/src/test/core/org/apache/hadoop/io/TestUTF8.java Thu Jan  7 22:04:37 2010
@@ -68,16 +68,16 @@
       // test that it reads correctly
       in.reset(out.getData(), out.getLength());
       String after = UTF8.readString(in);
-      assertTrue(before.equals(after));
+      assertEquals(before, after);
 
       // test that it reads correctly with DataInput
       in.reset(out.getData(), out.getLength());
       String after2 = in.readUTF();
-      assertTrue(before.equals(after2));
+      assertEquals(before, after2);
 
       // test that it is compatible with Java's other decoder
       String after3 = new String(out.getData(), 2, out.getLength()-2, "UTF-8");
-      assertTrue(before.equals(after3));
+      assertEquals(before, after3);
 
     }
 



Mime
View raw message