/** * Put some data in a session * @param key the key for the data * @param obj the data * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.session.Session put(String key, Object obj) { delegate.put(key, obj); return this; }
/** * Put some data in a session * @param key the key for the data * @param obj the data * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.session.Session put(String key, Object obj) { delegate.put(key, obj); return this; }
public static io.vertx.ext.shell.session.Session put(io.vertx.ext.shell.session.Session j_receiver, java.lang.String key, java.lang.Object obj) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.put(key, io.vertx.core.impl.ConversionHelper.toObject(obj))); return j_receiver; } public static <T>java.lang.Object get(io.vertx.ext.shell.session.Session j_receiver, java.lang.String key) {
public ShellImpl(Term term, InternalCommandManager commandManager) { session.put("vert.x-command-manager", commandManager); this.id = UUID.randomUUID().toString(); this.jobController = new JobControllerImpl(); this.commandManager = commandManager; this.closedFuture = Future.future(); this.term = term; if (term != null) { term.setSession(session); jobController.foregroundUpdatedHandler(job -> { if (job == null) { readline(); } }); } }
@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 testSessionGet(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.get("the_key")); process.end(); })); Shell shell = server.createShell(); Job job = shell.createJob("foo"); Session session = new SessionImpl(); session.put("the_key", "the_value"); Pty pty = Pty.create(); job.setSession(session).setTty(pty.slave()).statusUpdateHandler(CommandProcessTest.terminateHandler(status -> { context.assertEquals(0, job.process().exitCode()); async.complete(); })).run(); }
@Test public void testSessionPut(TestContext context) throws Exception { Async async = context.async(); commands.add(CommandBuilder.command("foo").processHandler(process -> { Session session = process.session(); context.assertNotNull(session); context.assertNull(session.get("the_key")); session.put("the_key", "the_value"); process.end(); })); Shell shell = server.createShell(); Job job = shell.createJob("foo"); Pty pty = Pty.create(); Session session = new SessionImpl(); job.setSession(session).setTty(pty.slave()).statusUpdateHandler(CommandProcessTest.terminateHandler(status -> { context.assertEquals(0, job.process().exitCode()); context.assertEquals("the_value", session.get("the_key")); async.complete(); })).run(); }
@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(); }