OptionsParser { private static void parseBandwidth(CommandLine command, DistCpOptions option) { if (command.hasOption(DistCpOptionSwitch.BANDWIDTH.getSwitch())) { try { Float mapBandwidth = Float.parseFloat( getVal(command, DistCpOptionSwitch.BANDWIDTH.getSwitch()).trim()); if (mapBandwidth <= 0) { throw new IllegalArgumentException("Bandwidth specified is not " + "positive: " + mapBandwidth); } option.setMapBandwidth(mapBandwidth); } catch (NumberFormatException e) { throw new IllegalArgumentException("Bandwidth specified is invalid: " + getVal(command, DistCpOptionSwitch.BANDWIDTH.getSwitch()), e); } } }  static DistCpOptions parse(String args[]); static void usage();  }
@Test public void testParsebandwidth() { DistCpOptions options = OptionsParser.parse(new String[] { "hdfs: "hdfs: Assert.assertEquals(options.getMapBandwidth(), DistCpConstants.DEFAULT_BANDWIDTH_MB, DELTA); options = OptionsParser.parse(new String[] { "-bandwidth", "11.2", "hdfs: "hdfs: Assert.assertEquals(options.getMapBandwidth(), 11.2, DELTA); }