StopInstanceCommand extends AbstractCommand { public static StopInstanceCommand parse(String commandString, ExecutionContext sessionContext) throws ODPSConsoleException { if (commandString.toUpperCase().startsWith("KILL")) { String temp[] = commandString.trim().replaceAll("\\s+", " ").split(" "); CommandLine cl = getCommandLine(temp); if (2 == cl.getArgs().length) { return new StopInstanceCommand(commandString, sessionContext, temp[1], false); } if (1 != cl.getArgs().length) { throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "[invalid parameters]"); } if (cl.hasOption("sync")) { return new StopInstanceCommand(commandString, sessionContext, cl.getOptionValue("sync"), true); } } return null; } StopInstanceCommand(String commandText, ExecutionContext context, String instanceId,
                             boolean synchronizeFlag); static void printUsage(PrintStream stream); String getInstanceId(); void run(); static StopInstanceCommand parse(String commandString, ExecutionContext sessionContext); static final String[] HELP_TAGS; }
@Test public void testSyncNagtive() throws ODPSConsoleException, OdpsException { ExecutionContext ctx = ExecutionContext.init(); for (String str : nagtive) { StopInstanceCommand test = StopInstanceCommand.parse(str, ctx); assertNull(test); } }
@Test(expected = ODPSConsoleException.class) public void testSyncBadParas() throws ODPSConsoleException, OdpsException { ExecutionContext ctx = ExecutionContext.init(); for (String str : badPara) { String cmd = str + getID(ctx); StopInstanceCommand.parse(cmd, ctx); } }