@Test
public void testPreserveAclsforDefaultACL() throws IOException {

  FileSystem fs = FileSystem.get(config);
  EnumSet<FileAttribute> attributes = EnumSet.of(FileAttribute.ACL,
      FileAttribute.PERMISSION, FileAttribute.XATTR, FileAttribute.GROUP,
      FileAttribute.USER, FileAttribute.REPLICATION, FileAttribute.XATTR,
      FileAttribute.TIMES);
  Path dest = new Path("/tmpdest");
  Path src = new Path("/testsrc");
  fs.mkdirs(src);
  fs.mkdirs(dest);
  List<AclEntry> acls = Lists.newArrayList(
      aclEntry(DEFAULT, USER, "foo", READ_EXECUTE),
      aclEntry(ACCESS, USER, READ_WRITE), aclEntry(ACCESS, GROUP, READ),
      aclEntry(ACCESS, OTHER, READ), aclEntry(ACCESS, USER, "bar", ALL));
  final List<AclEntry> acls1 = Lists.newArrayList(aclEntry(ACCESS, USER, ALL),
      aclEntry(ACCESS, USER, "user1", ALL),
      aclEntry(ACCESS, GROUP, READ_EXECUTE),
      aclEntry(ACCESS, OTHER, EXECUTE));
  fs.setPermission(src, fullPerm);
  fs.setOwner(src, "somebody", "somebody-group");
  fs.setTimes(src, 0, 0);
  fs.setReplication(src, (short) 1);
  fs.setAcl(src, acls);
  fs.setPermission(dest, noPerm);
  fs.setOwner(dest, "nobody", "nobody-group");
  fs.setTimes(dest, 100, 100);
  fs.setReplication(dest, (short) 2);
  fs.setAcl(dest, acls1);
  List<AclEntry> en1 = fs.getAclStatus(src).getEntries();
  List<AclEntry> dd2 = fs.getAclStatus(dest).getEntries();
  Assert.assertNotEquals(en1, dd2);
  CopyListingFileStatus srcStatus = new CopyListingFileStatus(
      fs.getFileStatus(src));
  en1 = srcStatus.getAclEntries();
  DistCpUtils.preserve(fs, dest, srcStatus, attributes, false);
  CopyListingFileStatus dstStatus = new CopyListingFileStatus(
      fs.getFileStatus(dest));
  dd2 = dstStatus.getAclEntries();
  en1 = srcStatus.getAclEntries();
  // FileStatus.equals only compares path field, must explicitly compare all
  // fields
  assertStatusEqual(fs, dest, srcStatus);
  Assert.assertArrayEquals(en1.toArray(), dd2.toArray());
}