GenericOptionsParser { public CommandLine getCommandLine() { return commandLine; } GenericOptionsParser(Options opts, String[] args);  GenericOptionsParser(String[] args);  GenericOptionsParser(Configuration conf, String[] args);  GenericOptionsParser(Configuration conf,
      Options options, String[] args); String[] getRemainingArgs(); Configuration getConfiguration(); CommandLine getCommandLine(); boolean isParseSuccessful(); static URL[] getLibJars(Configuration conf); static void printGenericCommandUsage(PrintStream out);  }
@SuppressWarnings("static-access") @Test public void testCreateWithOptions() throws Exception { Option opt = OptionBuilder.withArgName("int") .hasArg() .withDescription("A new option") .create("newOpt"); Options opts = new Options(); opts.addOption(opt); String[] args = new String[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); assertEquals("New option was ignored", "7", g.getCommandLine().getOptionValues("newOpt")[0]); }
@Test public void testConfWithMultipleOpts() throws Exception { String[] args = new String[2]; args[0] = "--conf=foo"; args[1] = "--conf=bar"; GenericOptionsParser g = new GenericOptionsParser(args); assertEquals("1st conf param is incorrect", "foo", g.getCommandLine().getOptionValues("conf")[0]); assertEquals("2st conf param is incorrect", "bar", g.getCommandLine().getOptionValues("conf")[1]); }