/** * Create a new empty session. * @return the created session */ public static io.vertx.rxjava.ext.shell.session.Session create() { io.vertx.rxjava.ext.shell.session.Session ret = io.vertx.rxjava.ext.shell.session.Session.newInstance(io.vertx.ext.shell.session.Session.create()); return ret; }
/** * Create a new empty session. * @return the created session */ public static io.vertx.rxjava.ext.shell.session.Session create() { io.vertx.rxjava.ext.shell.session.Session ret = io.vertx.rxjava.ext.shell.session.Session.newInstance(io.vertx.ext.shell.session.Session.create()); return ret; }
private Process createProcessInContext(Context context, Command command) throws Exception { CompletableFuture<Process> fut = new CompletableFuture<>(); context.runOnContext(v -> { Process process = command.createProcess().setSession(Session.create()).setTty(Pty.create().slave()); fut.complete(process); }); return fut.get(2000, TimeUnit.MILLISECONDS); }
@Test public void testSuspendReadyProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); builder.processHandler(process -> context.fail()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); try { process.suspend(); context.fail(); } catch (Exception ignore) { } }
@Test public void testResumeReadyProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); builder.processHandler(process -> context.fail()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); try { process.resume(); context.fail(); } catch (Exception ignore) { } }
@Test public void testInterruptReadyProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); builder.processHandler(process -> context.fail()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); try { process.interrupt(); context.fail(); } catch (Exception ignore) { } }
@Test public void testRunRunningProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async runningLatch = context.async(); builder.processHandler(process -> runningLatch.complete()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.run(); runningLatch.awaitSuccess(10000); try { process.run(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testResumeRunningProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async runningLatch = context.async(); builder.processHandler(process -> runningLatch.complete()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.run(); runningLatch.awaitSuccess(10000); try { process.resume(); context.fail(); } catch (Exception ignore) { } }
@Test public void testRunTerminatedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async terminatedLatch = context.async(); builder.processHandler(CommandProcess::end); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.terminatedHandler(exitCode -> terminatedLatch.complete()); process.run(); terminatedLatch.awaitSuccess(10000); try { process.run(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testResumeTerminatedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async terminatedLatch = context.async(); builder.processHandler(CommandProcess::end); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.terminatedHandler(exitCode -> terminatedLatch.complete()); process.run(); terminatedLatch.awaitSuccess(10000); try { process.resume(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testSuspendTerminatedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async terminatedLatch = context.async(); builder.processHandler(CommandProcess::end); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.terminatedHandler(exitCode -> terminatedLatch.complete()); process.run(); terminatedLatch.awaitSuccess(10000); try { process.suspend(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testInterruptTerminatedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async terminatedLatch = context.async(); builder.processHandler(process -> process.end()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.terminatedHandler(exitCode -> terminatedLatch.complete()); process.run(); terminatedLatch.awaitSuccess(10000); try { process.interrupt(); context.fail(); } catch (Exception ignore) { } }
@Test public void testSuspendSuspendedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async suspendedLatch = context.async(); Async runningLatch = context.async(); builder.processHandler(process -> { process.suspendHandler(v -> suspendedLatch.complete()); runningLatch.complete(); }); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.run(); runningLatch.awaitSuccess(10000); process.suspend(); suspendedLatch.awaitSuccess(10000); try { process.suspend(); context.fail(); } catch (Exception ignore) { } }
@Test public void testTerminateTerminatedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async runningLatch = context.async(); Async terminatedLatch = context.async(); builder.processHandler(process -> runningLatch.complete()); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.terminatedHandler(exitCode -> terminatedLatch.complete()); process.run(); runningLatch.awaitSuccess(10000); process.terminate(); terminatedLatch.awaitSuccess(10000); try { process.terminate(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testRunSuspendedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async suspendedLatch = context.async(); Async runningLatch = context.async(); builder.processHandler(process -> { process.suspendHandler(v -> suspendedLatch.complete()); runningLatch.complete(); }); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.run(); runningLatch.awaitSuccess(10000); process.suspend(); suspendedLatch.awaitSuccess(10000); try { process.run(); context.fail(); } catch (IllegalStateException ignore) { } }
@Test public void testInterruptSuspendedProcess(TestContext context) { CommandBuilder builder = CommandBuilder.command("hello"); Async runningLatch = context.async(); Async suspendedLatch = context.async(); Async interruptedLatch = context.async(3); builder.processHandler(process -> { process.interruptHandler(v -> interruptedLatch.countDown()); process.suspendHandler(v -> suspendedLatch.complete()); runningLatch.complete(); }); Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave()); process.run(); runningLatch.awaitSuccess(10000); process.suspend(); suspendedLatch.awaitSuccess(10000); process.interrupt(); process.interrupt(); process.interrupt(); }