/** * Remove some data from the session * @param key the key of the data * @return the data that was there or null if none there */ public <T> T remove(String key) { T ret = (T) delegate.remove(key); return ret; }
/** * Remove some data from the session * @param key the key of the data * @return the data that was there or null if none there */ public <T> T remove(String key) { T ret = (T) delegate.remove(key); return ret; }
public static <T>java.lang.Object remove(io.vertx.ext.shell.session.Session j_receiver, java.lang.String key) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.remove(key)); } }
@Override public void process(CommandProcess process) { if (process.args().size() > 0) { String cwd = process.session().get("cwd"); new FsHelper().cd(process.vertx().fileSystem(), cwd, dir, ar -> { if (ar.succeeded()) { process.session().put("cwd", ar.result()); process.end(); } else { process.write("cd: No such file or directory\n"); process.end(); } }); } else { process.session().remove("cwd"); process.end(); } }
@Test public void testSessionRemove(TestContext context) throws Exception { Async async = context.async(); commands.add(CommandBuilder.command("foo").processHandler(process -> { Session session = process.session(); context.assertNotNull(session); context.assertEquals("the_value", session.remove("the_key")); process.end(); })); Shell shell = server.createShell(); Job job = shell.createJob("foo"); Pty pty = Pty.create(); Session session = new SessionImpl(); session.put("the_key", "the_value"); job.setSession(session).setTty(pty.slave()).statusUpdateHandler(CommandProcessTest.terminateHandler(status -> { context.assertEquals(0, job.process().exitCode()); context.assertNull(session.get("the_key")); async.complete(); })).run(); }