### Question:
ManagementConsole { boolean parserArguments(String[] args) { portName = ""; serviceName = ""; operationName = ""; boolean result = false; try { for (int i = 0; i < args.length; i++) { String arg = args[i]; if ("--port".equals(arg) || "-p".equals(arg)) { portName = args[++i]; } else if ("--service".equals(arg) || "-s".equals(arg)) { serviceName = args[++i]; } else if ("--jmx".equals(arg) || "-j".equals(arg)) { jmxServerURL = args[++i]; } else if ("--operation".equals(arg) || "-o".equals(arg)) { operationName = args[++i]; result = true; } } } catch (Exception ex) { return false; } return result; } ManagementConsole(); void getManagedObjectAttributes(ObjectName name); void doManagement(); static void main(String[] args);  }### Answer:
@Test public void paraserCommandTest() { String[] listArgs = new String[] {"--operation", "list"}; mc.parserArguments(listArgs); assertEquals("It is not right operation name", "list", mc.operationName); assertEquals("The portName should be cleared", "", mc.portName); String[] startArgs = new String[] {"-o", "start", "--jmx", "service:jmx:rmi: "--service", "\"{http: "--port", "\"{http: mc.parserArguments(startArgs); assertEquals("It is not right operation name", "start", mc.operationName); assertEquals("It is not right port name", "\"{http: assertEquals("It is not right service name", "\"{http: assertEquals("It is not a jmx url", "service:jmx:rmi: mc.jmxServerURL); String[] errorArgs = new String[] {"--op", "listAll"}; assertFalse("the arguments are wrong", mc.parserArguments(errorArgs)); }