MemoryCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; String subCommand = safeReadLine(reader); if (subCommand.equals(MEMORY_DEL_SUB_COMMAND_NAME)) { returnCommand = deleteObject(reader); } else { returnCommand = Protocol.getOutputErrorCommand("Unknown Memory SubCommand Name: " + subCommand); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } MemoryCommand(); @Override void execute(String commandName, BufferedReader reader, BufferedWriter writer); final static String MEMORY_COMMAND_NAME; final static String MEMORY_DEL_SUB_COMMAND_NAME; }
@Test public void testDelete() { String inputCommand = "d\n" + target + "\ne\n"; try { assertTrue(gateway.getBindings().containsKey(target)); command.execute("m", new BufferedReader(new StringReader(inputCommand)), writer); assertEquals("!yv\n", sWriter.toString()); assertFalse(gateway.getBindings().containsKey(target)); command.execute("m", new BufferedReader(new StringReader(inputCommand)), writer); assertEquals("!yv\n!yv\n", sWriter.toString()); } catch (Exception e) { e.printStackTrace(); fail(); } }