JettyConsoleBootstrapMainClass implements Runnable { static List<Option> parseOptions(List<String> lines) { List<Option> options = new ArrayList<>(); Option current = null; for (String line : lines) { line = line.trim(); if(line.startsWith(OPTION_NAME)) { String name = line.substring(OPTION_NAME.length()).trim(); options.add(current = new Option(name)); } else if (line.startsWith(SAMPLE)) { String sample = line.substring(SAMPLE.length()).trim(); current.setSample(sample); } else if (line.startsWith(DESCRIPTION)) { String description = line.substring(DESCRIPTION.length()).trim(); current.setDescription(description); } else if (line.startsWith(SECTION)) { String section = line.substring(SECTION.length()).trim(); current.setSection(section); } } return options; }  static void start(String[] arguments); static void stop(String[] args); static void main(String[] arguments); static Map<String, Option> getOptionsByName(); void run(); static void usage(); static void usage(String args); static String OPTION_NAME; static String SAMPLE; static String DESCRIPTION; static String SECTION; }
@Test public void shouldParseOptions() { List<JettyConsoleBootstrapMainClass.Option> opts = JettyConsoleBootstrapMainClass.parseOptions(lines); assertEquals(2, opts.size()); JettyConsoleBootstrapMainClass.Option one = opts.get(0); assertEquals("ajpPort", one.getName()); assertEquals("n", one.getSample()); assertEquals("Create an AJP listener on port n (default: don't listen on AJP)", one.getDescription()); assertEquals("AJP", one.getSection()); }