@Test
public void testPreserve() {

  DistCpOptions options = new DistCpOptions.Builder(
      new Path("hdfs://localhost:8020/source/first"),
      new Path("hdfs://localhost:8020/target/"))
      .build();
  Assert.assertFalse(options.shouldPreserve(FileAttribute.BLOCKSIZE));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.REPLICATION));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.PERMISSION));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.USER));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.GROUP));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.CHECKSUMTYPE));
  options = new DistCpOptions.Builder(
      new Path("hdfs://localhost:8020/source/first"),
      new Path("hdfs://localhost:8020/target/"))
      .preserve(FileAttribute.ACL)
      .build();
  Assert.assertFalse(options.shouldPreserve(FileAttribute.BLOCKSIZE));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.REPLICATION));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.PERMISSION));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.USER));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.GROUP));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.CHECKSUMTYPE));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.ACL));
  options = new DistCpOptions.Builder(
      new Path("hdfs://localhost:8020/source/first"),
      new Path("hdfs://localhost:8020/target/"))
      .preserve(FileAttribute.BLOCKSIZE)
      .preserve(FileAttribute.REPLICATION)
      .preserve(FileAttribute.PERMISSION)
      .preserve(FileAttribute.USER)
      .preserve(FileAttribute.GROUP)
      .preserve(FileAttribute.CHECKSUMTYPE)
      .build();
  Assert.assertTrue(options.shouldPreserve(FileAttribute.BLOCKSIZE));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.REPLICATION));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.PERMISSION));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.USER));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.GROUP));
  Assert.assertTrue(options.shouldPreserve(FileAttribute.CHECKSUMTYPE));
  Assert.assertFalse(options.shouldPreserve(FileAttribute.XATTR));
}