Java Code Examples for rx.observers.AssertableSubscriber#assertFailure()
The following examples show how to use
rx.observers.AssertableSubscriber#assertFailure() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublishSubjectRaceTest.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Test public void racy() throws Exception { Worker worker = Schedulers.computation().createWorker(); try { for (int i = 0; i < 1000; i++) { AtomicInteger wip = new AtomicInteger(2); PublishSubject<Integer> ps = PublishSubject.create(); AssertableSubscriber<Integer> as = ps.test(1); CountDownLatch cdl = new CountDownLatch(1); worker.schedule(() -> { if (wip.decrementAndGet() != 0) { while (wip.get() != 0) ; } ps.onNext(1); cdl.countDown(); }); if (wip.decrementAndGet() != 0) { while (wip.get() != 0) ; } ps.onNext(1); cdl.await(); as.assertFailure(MissingBackpressureException.class, 1); } } finally { worker.unsubscribe(); } }
Example 2
Source File: PublishSubjectRaceTest.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Test public void nonRacy() throws Exception { Worker worker = Schedulers.computation().createWorker(); try { for (int i = 0; i < 1000; i++) { AtomicInteger wip = new AtomicInteger(2); Subject<Integer, Integer> ps = PublishSubject.<Integer>create().toSerialized(); AssertableSubscriber<Integer> as = ps.test(1); CountDownLatch cdl = new CountDownLatch(1); worker.schedule(() -> { if (wip.decrementAndGet() != 0) { while (wip.get() != 0) ; } ps.onNext(1); cdl.countDown(); }); if (wip.decrementAndGet() != 0) { while (wip.get() != 0) ; } ps.onNext(1); cdl.await(); as.assertFailure(MissingBackpressureException.class, 1); } } finally { worker.unsubscribe(); } }