@Test
public void testParseDFSURI() throws Exception {

  // warehouse hdfs, path /
  assertEquals("hdfs://namenode:8020/tmp/hive-user", PathUtils.
    parseDFSURI("hdfs://namenode:8020/user/hive/warehouse", "/tmp/hive-user"));
  // warehouse hdfs, path hdfs
  assertEquals("hdfs://namenode:8020/tmp/hive-user", PathUtils.
    parseDFSURI("hdfs://namenode:8020/user/hive/warehouse", "hdfs://namenode:8020/tmp/hive-user"));
  try {
    PathUtils.parseDFSURI("hdfs://namenode:8020/user/hive/warehouse", "tmp/hive-user");
    fail("IllegalArgumentException should be thrown");
  } catch (IllegalArgumentException ue) {
  }
  // warehouse swift, path /
  assertEquals("swift://namenode:8020/tmp/hive-user",
      PathUtils.parseDFSURI("swift://namenode:8020/user/hive/warehouse", "/tmp/hive-user"));
  // warehouse swift, path swift
  assertEquals("swift://namenode:8020/tmp/hive-user", PathUtils.parseDFSURI(
      "swift://namenode:8020/user/hive/warehouse", "swift://namenode:8020/tmp/hive-user"));
  try {
    PathUtils.parseDFSURI("swift://namenode:8020/user/hive/warehouse", "tmp/hive-user");
    fail("IllegalArgumentException should be thrown");
  } catch (IllegalArgumentException ue) {
  }
  // warehouse file:///, path /
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:///tmp/hive-warehouse", "/tmp/hive-user"));
  // warehouse file:///, path file:/
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:///tmp/hive-warehouse", "file:/tmp/hive-user"));
  // warehouse file:///, path file:///
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:///tmp/hive-warehouse", "file:///tmp/hive-user"));
  try {
    PathUtils.parseDFSURI("file:///hive-warehouse", "tmp/hive-user");
    fail("IllegalArgumentException should be thrown");
  } catch (IllegalArgumentException ue) {
  }
  // warehouse file:/, path /
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:/tmp/hive-warehouse", "/tmp/hive-user"));
  // warehouse file:/, path file:/
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:/tmp/hive-warehouse", "file:/tmp/hive-user"));
  // warehouse file:/, path file:///
  assertEquals("file:///tmp/hive-user", PathUtils.
    parseDFSURI("file:/tmp/hive-warehouse", "file:///tmp/hive-user"));
  // for local test case
  assertEquals("file:///tmp/hive-user",
      PathUtils.parseURI("testLocal:///tmp/hive-warehouse", "/tmp/hive-user", true));
  try {
    PathUtils.parseURI("testLocal:///tmp/hive-warehouse", "tmp/hive-user", true);
    fail("IllegalStateException should be thrown");
  } catch (IllegalArgumentException ue) {
  }
  // warehouse /, path /
  assertEquals("file:///tmp/hive-user",
      PathUtils.parseDFSURI("/tmp/hive-warehouse", "/tmp/hive-user"));
}