CommandLineParser { public void parse(String[] programArgs) { List<GlobalOptionConfiguration> globalOptions; globalOptions = new ArrayList<GlobalOptionConfiguration>(); for (int i = 0; i < programArgs.length;) { String arg; arg = programArgs[i]; if (arg.indexOf(TASK_ARGUMENT_PREFIX) == 0) { i = parseTask(programArgs, i); } else if (arg.indexOf(GLOBAL_ARGUMENT_PREFIX) == 0) { i = parseGlobalOption(globalOptions, programArgs, i); } else { throw new OsmosisRuntimeException("Expected argument " + (i + 1) + " to be an option or task name."); } } for (GlobalOptionConfiguration globalOption : globalOptions) { if (isArgumentForOption(OPTION_QUIET_SHORT, OPTION_QUIET_LONG, globalOption.name)) { quietValue = parseOptionIntegerWithDefault(globalOption, 0) + 1; } else if (isArgumentForOption(OPTION_VERBOSE_SHORT, OPTION_VERBOSE_LONG, globalOption.name)) { verboseValue = parseOptionIntegerWithDefault(globalOption, 0) + 1; } else if (isArgumentForOption(OPTION_PLUGIN_SHORT, OPTION_PLUGIN_LONG, globalOption.name)) { plugins.add(parseOptionString(globalOption)); } else { throw new OsmosisRuntimeException("Argument " + (globalOption.offset + 1) + " specifies an unrecognised option \"" + GLOBAL_ARGUMENT_PREFIX + globalOption.name + "\"."); } } } CommandLineParser(); void parse(String[] programArgs); List<TaskConfiguration> getTaskInfoList(); int getLogLevelIndex(); List<String> getPlugins();  }
@Test (expected = OsmosisRuntimeException.class) public void testUnknownOption() { CommandLineParser commandLineParser; commandLineParser = new CommandLineParser(); commandLineParser.parse(new String[] {"-a"}); }