UnSetCommand extends AbstractCommand { public static UnSetCommand parse(String commandString, ExecutionContext sessionContext) throws ODPSConsoleException { if (StringUtils.isNullOrEmpty(commandString)) { return null; } String[] tokens = new AntlrObject(commandString).getTokenStringArray(); if (tokens.length != 2) { return null; } UnSetCommand command = null; if ("UNSET".equalsIgnoreCase(tokens[0])) { String key = tokens[1]; command = new UnSetCommand(true, key.trim(), commandString, sessionContext); } else if ("UNALIAS".equalsIgnoreCase(tokens[0])) { String key = tokens[1]; command = new UnSetCommand(false, key.trim(), commandString, sessionContext); } return command; } UnSetCommand(boolean isSet, String key, String commandText,
                      ExecutionContext context); static void printUsage(PrintStream stream); static UnSetCommand parse(String commandString, ExecutionContext sessionContext); void run(); static final String[] HELP_TAGS; }
@Test public void negativeTest() throws ODPSConsoleException, OdpsException { UnSetCommand cmd = UnSetCommand.parse("unse testkey", null); assertNull(cmd); cmd = UnSetCommand.parse("unset ", null); assertNull(cmd); cmd = UnSetCommand.parse("unalia testkey\n", null); assertNull(cmd); cmd = UnSetCommand.parse("unalias \r\n", null); assertNull(cmd); }