@Test
public void testAppendOption() {

  Configuration conf = new Configuration();
  Assert.assertFalse(conf.getBoolean(
      DistCpOptionSwitch.APPEND.getConfigLabel(), false));
  Assert.assertFalse(conf.getBoolean(
      DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
  DistCpOptions options = OptionsParser.parse(new String[] { "-update",
      "-append", "hdfs://localhost:8020/source/first",
      "hdfs://localhost:8020/target/" });
  options.appendToConf(conf);
  Assert.assertTrue(conf.getBoolean(
      DistCpOptionSwitch.APPEND.getConfigLabel(), false));
  Assert.assertTrue(conf.getBoolean(
      DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
  // make sure -append is only valid when -update is specified
  try {
    OptionsParser.parse(new String[] { "-append",
            "hdfs://localhost:8020/source/first",
            "hdfs://localhost:8020/target/" });
    fail("Append should fail if update option is not specified");
  } catch (IllegalArgumentException e) {
    GenericTestUtils.assertExceptionContains(
        "Append is valid only with update options", e);
  }
  // make sure -append is invalid when skipCrc is specified
  try {
    OptionsParser.parse(new String[] {
        "-append", "-update", "-skipcrccheck",
        "hdfs://localhost:8020/source/first",
        "hdfs://localhost:8020/target/" });
    fail("Append should fail if skipCrc option is specified");
  } catch (IllegalArgumentException e) {
    GenericTestUtils.assertExceptionContains(
        "Append is disallowed when skipping CRC", e);
  }
}