@Test
  public void testSetPermissionsOnExistingDir() throws IOException {
    File tmpDir = Files.createTempDir();
    Path path = new Path(tmpDir.getPath());
    HiveConf conf = new HiveConf(this.getClass());
    FileSystem fs = path.getFileSystem(conf);
    fs.setPermission(path, new FsPermission((short) 00700));
    Utilities.ensurePathIsWritable(path, conf);
    Assert.assertEquals((short) 0733, fs.getFileStatus(path).getPermission().toShort());

    // Test with more open permissions than required, but still not writable,
    // it should just make the directory writable without restricting the existing permissions
    fs.setPermission(path, new FsPermission((short) 00755));
    Utilities.ensurePathIsWritable(path, conf);
    Assert.assertEquals((short) 0777, fs.getFileStatus(path).getPermission().toShort());
  }
This test tests that Utilities.get*Tasks do not repeat themselves in the process
of extracting tasks from a given set of root tasks when given DAGs that can have
multiple paths, such as the case with Diamond-shaped DAGs common to replication.
ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java