OptionsParser { private static void parseNumListStatusThreads(CommandLine command, DistCpOptions option) { if (command.hasOption( DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch())) { try { Integer numThreads = Integer.parseInt(getVal(command, DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch()).trim()); option.setNumListstatusThreads(numThreads); } catch (NumberFormatException e) { throw new IllegalArgumentException( "Number of liststatus threads is invalid: " + getVal(command, DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch()), e); } } }  static DistCpOptions parse(String args[]); static void usage();  }
@Test public void testParseNumListstatusThreads() { DistCpOptions options = OptionsParser.parse(new String[] { "hdfs: "hdfs: Assert.assertEquals(0, options.getNumListstatusThreads()); options = OptionsParser.parse(new String[] { "--numListstatusThreads", "12", "hdfs: "hdfs: Assert.assertEquals(12, options.getNumListstatusThreads()); options = OptionsParser.parse(new String[] { "--numListstatusThreads", "0", "hdfs: "hdfs: Assert.assertEquals(0, options.getNumListstatusThreads()); try { OptionsParser.parse(new String[] { "--numListstatusThreads", "hello", "hdfs: "hdfs: Assert.fail("Non numberic numListstatusThreads parsed"); } catch (IllegalArgumentException ignore) { } options = OptionsParser.parse(new String[] { "--numListstatusThreads", "100", "hdfs: "hdfs: Assert.assertEquals(DistCpOptions.maxNumListstatusThreads, options.getNumListstatusThreads()); }