### Question:
RxCmdShell { public synchronized Completable cancel() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("cancel()"); if (session == null) return Completable.complete(); else return session.flatMapCompletable(Session::cancel); } @SuppressWarnings("unused") private  RxCmdShell();   RxCmdShell(Builder builder, RxShell rxShell); synchronized Single<Session> open(); Single<Boolean> isAlive(); synchronized Completable cancel(); synchronized Single<Integer> close(); static Builder builder();  }### Answer:
@Test public void testCancel() { RxCmdShell shell = new RxCmdShell(builder, rxShell); RxCmdShell.Session session1 = shell.open().test().awaitDone(1, TimeUnit.SECONDS).assertNoErrors().values().get(0); session1.isAlive().test().awaitDone(1, TimeUnit.SECONDS).assertNoErrors().assertValue(true); session1.cancel().test().awaitDone(1, TimeUnit.SECONDS).assertNoErrors().assertComplete(); verify(rxShellSession).cancel(); session1.isAlive().test().awaitDone(1, TimeUnit.SECONDS).assertNoErrors().assertValue(false); RxCmdShell.Session session2 = shell.open().test().awaitDone(1, TimeUnit.SECONDS).assertNoErrors().values().get(0); assertThat(session2, is(not(session1))); }