MainCommandLine { public static void execute(final String... args) { int port = DEFAULT_PORT; String command = null; boolean debug = false; int index = 0; while (index < args.length) { switch (args[index]) { case CMD_SILENT: rootLogger.setLevel(Level.WARN); consoleAppender.setThreshold(Level.WARN); break; case CMD_DEBUG: debug = true; break; case CMD_PORT: if (index >= (args.length - 1)) { System.out.println("Missing port number"); printUsage(); return; } port = Integer.parseInt(args[index + 1]); ++index; break; default: if (args[index].startsWith("-")) { System.out.println("Unknown option: " + args[index]); printUsage(); return; } if (command != null) { System.out.println("Unknown argument: " + args[index]); printUsage(); return; } command = args[index]; break; } ++index; } if (debug) { consoleAppender.setThreshold(Level.DEBUG); } if ((command != null) && command.equals(CMD_HELP)) { printUsage(); } else { server.startServer(port); } } private  MainCommandLine(); static void execute(final String... args); static void stop();  }
@SuppressWarnings("JUnitTestMethodWithNoAssertions") @Test public void testHelp() { LOG.info("testHelp"); MockitoAnnotations.initMocks(this); MainCommandLine.execute("--help"); }
@SuppressWarnings("JUnitTestMethodWithNoAssertions") @Test public void testUnknownArgument() { LOG.info("testUnknownArgument"); MockitoAnnotations.initMocks(this); MainCommandLine.execute("--help", "unknown"); MainCommandLine.execute("--unknown"); MainCommandLine.execute("--port"); }