@Test
public void testOptionsAppendToConfDoesntOverwriteBandwidth() {

  Configuration conf = new Configuration();
  Assert.assertEquals(
      conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), null);
  DistCpOptions options = OptionsParser.parse(new String[] {
      "hdfs://localhost:8020/source/first",
      "hdfs://localhost:8020/target/"});
  options.appendToConf(conf);
  assertThat(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1))
          .isCloseTo(-1.0f,within(DELTA));
  conf = new Configuration();
  Assert.assertEquals(
      conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), null);
  options = OptionsParser.parse(new String[] {
      "-update",
      "-delete",
      "-pu",
      "-bandwidth",
      "77",
      "hdfs://localhost:8020/source/first",
      "hdfs://localhost:8020/target/"});
  options.appendToConf(conf);
  Assert.assertEquals(
      conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 77.0,
      DELTA);
  conf = new Configuration();
  conf.set(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), "88");
  Assert.assertEquals(
      conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), "88");
  options = OptionsParser.parse(new String[] {
      "hdfs://localhost:8020/source/first",
      "hdfs://localhost:8020/target/"});
  options.appendToConf(conf);
  Assert.assertEquals(
      conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 88.0,
      DELTA);
  conf = new Configuration();
  conf.set(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), "88.0");
  Assert.assertEquals(
      conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), "88.0");
  options = OptionsParser.parse(new String[] {
      "-bandwidth",
      "99",
      "hdfs://localhost:8020/source/first",
      "hdfs://localhost:8020/target/"});
  options.appendToConf(conf);
  Assert.assertEquals(
      conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 99.0,
      DELTA);
}