use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class SerializedSubscriberTest method onErrorQueuedUp.
@Test
@SuppressUndeliverable
public void onErrorQueuedUp() {
AtomicReference<SerializedSubscriber<Integer>> ssRef = new AtomicReference<>();
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>() {
@Override
public void onNext(Integer t) {
super.onNext(t);
ssRef.get().onNext(2);
ssRef.get().onError(new TestException());
}
};
final SerializedSubscriber<Integer> so = new SerializedSubscriber<>(ts, true);
ssRef.set(so);
BooleanSubscription bs = new BooleanSubscription();
so.onSubscribe(bs);
so.onNext(1);
ts.assertFailure(TestException.class, 1, 2);
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class TestSubscriberExTest method interruptTerminalEventAwait.
@Test
public void interruptTerminalEventAwait() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
final Thread t0 = Thread.currentThread();
Worker w = Schedulers.computation().createWorker();
try {
w.schedule(new Runnable() {
@Override
public void run() {
t0.interrupt();
}
}, 200, TimeUnit.MILLISECONDS);
try {
if (ts.await(5, TimeUnit.SECONDS)) {
fail("Did not interrupt wait!");
}
} catch (InterruptedException expected) {
// expected
}
} finally {
w.dispose();
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableWithLatestFromTest method otherThrows.
@Test
public void otherThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
PublishProcessor<Integer> other = PublishProcessor.create();
Flowable<Integer> result = source.withLatestFrom(other, COMBINER);
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
result.subscribe(ts);
assertTrue(source.hasSubscribers());
assertTrue(other.hasSubscribers());
other.onNext(1);
source.onNext(1);
other.onError(new TestException());
ts.assertTerminated();
ts.assertValue((1 << 8) + 1);
ts.assertNotComplete();
ts.assertError(TestException.class);
assertFalse(source.hasSubscribers());
assertFalse(other.hasSubscribers());
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableWithLatestFromTest method sourceThrows.
@Test
public void sourceThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
PublishProcessor<Integer> other = PublishProcessor.create();
Flowable<Integer> result = source.withLatestFrom(other, COMBINER);
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
result.subscribe(ts);
assertTrue(source.hasSubscribers());
assertTrue(other.hasSubscribers());
other.onNext(1);
source.onNext(1);
source.onError(new TestException());
ts.assertTerminated();
ts.assertValue((1 << 8) + 1);
ts.assertError(TestException.class);
ts.assertNotComplete();
assertFalse(source.hasSubscribers());
assertFalse(other.hasSubscribers());
}
Aggregations