@Test public final void testReadArguments3() { final String[] argsUndefined = {"", "-test=wrong", "blah", AbstractReader.STUN_FIRST_IP + "=wrong"}; CmdReader cmdReaderUndefinedArgs = new CmdReader(argsUndefined); try { cmdReaderUndefinedArgs.readArguments(stunArgs, relayArgs, mediatorArgs); } catch (Exception e) { fail("Should not be here!"); } }
@Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { for (String arg : args) { try { String[] splitted = arg.split("="); String result = ""; if (splitted.length > 1) { result = splitted[1]; } if (arg.startsWith(STUN_FIRST_IP) || arg.startsWith("-" + STUN_FIRST_IP)) { processStunFirstIP(stunArgs, result); } else if (arg.startsWith(STUN_SECOND_IP) || arg.startsWith("-" + STUN_SECOND_IP)) { processStunSecondIP(stunArgs, result); } else if (arg.startsWith(RELAY_PORT) || arg.startsWith("-" + RELAY_PORT)) { processRelayPort(relayArgs, result); } else if (arg.startsWith(MEDIATOR_PORT) || arg.startsWith("-" + MEDIATOR_PORT)) { processMediatorPort(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_ITERATION) || arg.startsWith("-" + MEDIATOR_ITERATION)) { processMediatorIteration(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_LIFETIME) || arg.startsWith("-" + MEDIATOR_LIFETIME)) { processMediatorLifeTime(mediatorArgs, result); } else { logInfo("Argument \"" + arg + "\" not recognized"); } } catch (IllegalArgumentException e) { logError("CmdReader: Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } }
CmdReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { for (String arg : args) { try { String[] splitted = arg.split("="); String result = ""; if (splitted.length > 1) { result = splitted[1]; } if (arg.startsWith(STUN_FIRST_IP) || arg.startsWith("-" + STUN_FIRST_IP)) { processStunFirstIP(stunArgs, result); } else if (arg.startsWith(STUN_SECOND_IP) || arg.startsWith("-" + STUN_SECOND_IP)) { processStunSecondIP(stunArgs, result); } else if (arg.startsWith(RELAY_PORT) || arg.startsWith("-" + RELAY_PORT)) { processRelayPort(relayArgs, result); } else if (arg.startsWith(MEDIATOR_PORT) || arg.startsWith("-" + MEDIATOR_PORT)) { processMediatorPort(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_ITERATION) || arg.startsWith("-" + MEDIATOR_ITERATION)) { processMediatorIteration(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_LIFETIME) || arg.startsWith("-" + MEDIATOR_LIFETIME)) { processMediatorLifeTime(mediatorArgs, result); } else { logInfo("Argument \"" + arg + "\" not recognized"); } } catch (IllegalArgumentException e) { logError("CmdReader: Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } }
CmdReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { for (String arg : args) { try { String[] splitted = arg.split("="); String result = ""; if (splitted.length > 1) { result = splitted[1]; } if (arg.startsWith(STUN_FIRST_IP) || arg.startsWith("-" + STUN_FIRST_IP)) { processStunFirstIP(stunArgs, result); } else if (arg.startsWith(STUN_SECOND_IP) || arg.startsWith("-" + STUN_SECOND_IP)) { processStunSecondIP(stunArgs, result); } else if (arg.startsWith(RELAY_PORT) || arg.startsWith("-" + RELAY_PORT)) { processRelayPort(relayArgs, result); } else if (arg.startsWith(MEDIATOR_PORT) || arg.startsWith("-" + MEDIATOR_PORT)) { processMediatorPort(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_ITERATION) || arg.startsWith("-" + MEDIATOR_ITERATION)) { processMediatorIteration(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_LIFETIME) || arg.startsWith("-" + MEDIATOR_LIFETIME)) { processMediatorLifeTime(mediatorArgs, result); } else { logInfo("Argument \"" + arg + "\" not recognized"); } } catch (IllegalArgumentException e) { logError("CmdReader: Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } CmdReader(final String[] args); }
CmdReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { for (String arg : args) { try { String[] splitted = arg.split("="); String result = ""; if (splitted.length > 1) { result = splitted[1]; } if (arg.startsWith(STUN_FIRST_IP) || arg.startsWith("-" + STUN_FIRST_IP)) { processStunFirstIP(stunArgs, result); } else if (arg.startsWith(STUN_SECOND_IP) || arg.startsWith("-" + STUN_SECOND_IP)) { processStunSecondIP(stunArgs, result); } else if (arg.startsWith(RELAY_PORT) || arg.startsWith("-" + RELAY_PORT)) { processRelayPort(relayArgs, result); } else if (arg.startsWith(MEDIATOR_PORT) || arg.startsWith("-" + MEDIATOR_PORT)) { processMediatorPort(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_ITERATION) || arg.startsWith("-" + MEDIATOR_ITERATION)) { processMediatorIteration(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_LIFETIME) || arg.startsWith("-" + MEDIATOR_LIFETIME)) { processMediatorLifeTime(mediatorArgs, result); } else { logInfo("Argument \"" + arg + "\" not recognized"); } } catch (IllegalArgumentException e) { logError("CmdReader: Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } CmdReader(final String[] args); @Override void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs); }
CmdReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { for (String arg : args) { try { String[] splitted = arg.split("="); String result = ""; if (splitted.length > 1) { result = splitted[1]; } if (arg.startsWith(STUN_FIRST_IP) || arg.startsWith("-" + STUN_FIRST_IP)) { processStunFirstIP(stunArgs, result); } else if (arg.startsWith(STUN_SECOND_IP) || arg.startsWith("-" + STUN_SECOND_IP)) { processStunSecondIP(stunArgs, result); } else if (arg.startsWith(RELAY_PORT) || arg.startsWith("-" + RELAY_PORT)) { processRelayPort(relayArgs, result); } else if (arg.startsWith(MEDIATOR_PORT) || arg.startsWith("-" + MEDIATOR_PORT)) { processMediatorPort(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_ITERATION) || arg.startsWith("-" + MEDIATOR_ITERATION)) { processMediatorIteration(mediatorArgs, result); } else if (arg.startsWith(MEDIATOR_LIFETIME) || arg.startsWith("-" + MEDIATOR_LIFETIME)) { processMediatorLifeTime(mediatorArgs, result); } else { logInfo("Argument \"" + arg + "\" not recognized"); } } catch (IllegalArgumentException e) { logError("CmdReader: Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } CmdReader(final String[] args); @Override void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs);  }