CommonCLIBuilder { public static CommandLine parseOptions(Class<?> clazz, String[] args, Options options) { CommandLineParser parser = new DefaultParser(); try { return parser.parse(options, args); } catch (ParseException e) { printUsageAndExit(clazz, options, e.getMessage()); throw new IllegalArgumentException(e.getMessage()); } }  static CommandLine parseOptions(Class<?> clazz, String[] args, Options options); static Options getCommonOptions(); static String getConfigOption(CommandLine cli); static final String CONFIG_OPT; }
@Test public void testParseOptions() { String[] args = new String[] { "argument" }; CommandLine cli = CommonCLIBuilder.parseOptions(this.getClass(), args, new Options()); assertNotNull(cli); }
@Test(expected = IllegalArgumentException.class) public void testParseOptions_withMissingOptions() { String[] args = new String[] { "fail-on-random-option" }; Options options = new Options(); options.addOption(Option.builder("o").required().build()); CommonCLIBuilder.parseOptions(this.getClass(), args, options); }