try {
Configuration conf = new Configuration();
conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, true);
cluster = new MiniDFSCluster.Builder(conf).build();
cluster.waitActive();
DistributedFileSystem hdfs = cluster.getFileSystem();
// Create a reasonable namespace with ACLs
Path dir = new Path("/dirWithNoAcl");
hdfs.mkdirs(dir);
writtenAcls.put(dir.toString(), hdfs.getAclStatus(dir));
dir = new Path("/dirWithDefaultAcl");
hdfs.mkdirs(dir);
hdfs.setAcl(dir, Lists.newArrayList(
aclEntry(DEFAULT, USER, ALL),
aclEntry(DEFAULT, USER, "foo", ALL),
aclEntry(DEFAULT, GROUP, READ_EXECUTE),
aclEntry(DEFAULT, OTHER, NONE)));
writtenAcls.put(dir.toString(), hdfs.getAclStatus(dir));
Path file = new Path("/noAcl");
FSDataOutputStream o = hdfs.create(file);
o.write(23);
o.close();
writtenAcls.put(file.toString(), hdfs.getAclStatus(file));
file = new Path("/withAcl");
o = hdfs.create(file);
o.write(23);
o.close();
hdfs.setAcl(file, Lists.newArrayList(
aclEntry(ACCESS, USER, READ_WRITE),
aclEntry(ACCESS, USER, "foo", READ),
aclEntry(ACCESS, GROUP, READ),
aclEntry(ACCESS, OTHER, NONE)));
writtenAcls.put(file.toString(), hdfs.getAclStatus(file));
file = new Path("/withSeveralAcls");
o = hdfs.create(file);
o.write(23);
o.close();
hdfs.setAcl(file, Lists.newArrayList(
aclEntry(ACCESS, USER, READ_WRITE),
aclEntry(ACCESS, USER, "foo", READ_WRITE),
aclEntry(ACCESS, USER, "bar", READ),
aclEntry(ACCESS, GROUP, READ),
aclEntry(ACCESS, GROUP, "group", READ),
aclEntry(ACCESS, OTHER, NONE)));
writtenAcls.put(file.toString(), hdfs.getAclStatus(file));
// Write results to the fsimage file
hdfs.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_ENTER, false);
hdfs.saveNamespace();
// Determine the location of the fsimage file
originalFsimage = FSImageTestUtil.findLatestImageFile(FSImageTestUtil
.getFSImage(cluster.getNameNode()).getStorage().getStorageDir(0));
if (originalFsimage == null) {