public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
void waitForThreadDone() throws InterruptedException { threadHasStarted.await(); t.join(); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
void waitForThreadDone() throws InterruptedException { threadHasStarted.await(); t.join(); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
synchronized void shutdown() throws InterruptedException { for (Thread hook : hooks) { hook.start(); } for (Thread hook : hooks) { hook.join(); } } }
@Test public void testMergeArrayWithThreading() { final TestASynchronousObservable o1 = new TestASynchronousObservable(); final TestASynchronousObservable o2 = new TestASynchronousObservable(); Observable<String> m = Observable.mergeDelayError(Observable.unsafeCreate(o1), Observable.unsafeCreate(o2)); m.subscribe(stringObserver); try { o1.t.join(); o2.t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } verify(stringObserver, never()).onError(any(Throwable.class)); verify(stringObserver, times(2)).onNext("hello"); verify(stringObserver, times(1)).onComplete(); }
@Test public void testMergeArrayWithThreading() { final TestASynchronousFlowable f1 = new TestASynchronousFlowable(); final TestASynchronousFlowable f2 = new TestASynchronousFlowable(); Flowable<String> m = Flowable.mergeDelayError(Flowable.unsafeCreate(f1), Flowable.unsafeCreate(f2)); m.subscribe(stringSubscriber); try { f1.t.join(); f2.t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } verify(stringSubscriber, never()).onError(any(Throwable.class)); verify(stringSubscriber, times(2)).onNext("hello"); verify(stringSubscriber, times(1)).onComplete(); }
public void testJoinWithNoWait() throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); Thread thread = new Thread(new JoinTarget(15)); thread.start(); thread.join(); assertFalse(thread.isAlive()); joinUninterruptibly(thread); joinUninterruptibly(thread, 0, MILLISECONDS); joinUninterruptibly(thread, -42, MILLISECONDS); joinUninterruptibly(thread, LONG_DELAY_MS, MILLISECONDS); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
public void testServiceThrowOnShutDown() throws Exception { ThrowOnShutDown service = new ThrowOnShutDown(); service.startAsync().awaitRunning(); assertEquals(Service.State.RUNNING, service.state()); service.stopAsync(); enterRun.countDown(); executionThread.join(); assertEquals(Service.State.FAILED, service.state()); assertThat(service.failureCause()).hasMessageThat().isEqualTo("kaboom!"); }
public void testServiceThrowOnRun() throws Exception { ThrowOnRunService service = new ThrowOnRunService(); service.startAsync(); try { service.awaitTerminated(); fail(); } catch (IllegalStateException expected) { executionThread.join(); assertThat(expected).hasCauseThat().isEqualTo(service.failureCause()); assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!"); } assertTrue(service.shutDownCalled); assertEquals(Service.State.FAILED, service.state()); }
public void testServiceStartStop() throws Exception { WaitOnRunService service = new WaitOnRunService(); assertFalse(service.startUpCalled); service.startAsync().awaitRunning(); assertTrue(service.startUpCalled); assertEquals(Service.State.RUNNING, service.state()); enterRun.await(); // to avoid stopping the service until run() is invoked service.stopAsync().awaitTerminated(); assertTrue(service.shutDownCalled); assertEquals(Service.State.TERMINATED, service.state()); executionThread.join(); }
public void testServiceStopIdempotence() throws Exception { WaitOnRunService service = new WaitOnRunService(); service.startAsync().awaitRunning(); enterRun.await(); // to avoid stopping the service until run() is invoked service.stopAsync(); service.stopAsync(); service.stopAsync().awaitTerminated(); assertEquals(Service.State.TERMINATED, service.state()); service.stopAsync().awaitTerminated(); assertEquals(Service.State.TERMINATED, service.state()); executionThread.join(); }
public void testServiceExitingOnItsOwn() throws Exception { WaitOnRunService service = new WaitOnRunService(); service.expectedShutdownState = Service.State.RUNNING; service.startAsync().awaitRunning(); assertTrue(service.startUpCalled); assertEquals(Service.State.RUNNING, service.state()); exitRun.countDown(); // the service will exit voluntarily executionThread.join(); assertTrue(service.shutDownCalled); assertEquals(Service.State.TERMINATED, service.state()); service.stopAsync().awaitTerminated(); // no-op assertEquals(Service.State.TERMINATED, service.state()); assertTrue(service.shutDownCalled); }
public void testThreadedServiceStopIdempotenceAfterWait() throws Throwable { ThreadedService service = new ThreadedService(); service.startAsync().awaitRunning(); assertEquals(State.RUNNING, service.state()); service.awaitRunChecks(); service.stopAsync().awaitTerminated(); service.stopAsync(); assertEquals(State.TERMINATED, service.state()); executionThread.join(); throwIfSet(thrownByExecutionThread); }