use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class TestSubscriberTest method interruptTerminalEventAwaitTimed.
@Test
public void interruptTerminalEventAwaitTimed() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
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 {
// clear interrupted flag
Thread.interrupted();
w.dispose();
}
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableObserveOnTest method badSource.
@Test
public void badSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestScheduler scheduler = new TestScheduler();
TestSubscriber<Integer> ts = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
subscriber.onComplete();
subscriber.onNext(1);
subscriber.onError(new TestException());
subscriber.onComplete();
}
}.observeOn(scheduler).test();
scheduler.triggerActions();
ts.assertResult();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableReplayEagerTruncateTest method disposeNoNeedForResetSizeBound.
@Test
public void disposeNoNeedForResetSizeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, true);
TestSubscriber<Integer> ts = cf.test();
Disposable d = cf.connect();
pp.onNext(1);
d.dispose();
ts = cf.test();
ts.assertEmpty();
cf.connect();
ts.assertEmpty();
pp.onNext(2);
ts.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableReplayEagerTruncateTest method disposeNoNeedForResetTimeAndSIzeBound.
@Test
public void disposeNoNeedForResetTimeAndSIzeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, 10, TimeUnit.MINUTES, Schedulers.single(), true);
TestSubscriber<Integer> ts = cf.test();
Disposable d = cf.connect();
pp.onNext(1);
d.dispose();
ts = cf.test();
ts.assertEmpty();
cf.connect();
ts.assertEmpty();
pp.onNext(2);
ts.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableReplayEagerTruncateTest method disposeNoNeedForResetTimeBound.
@Test
public void disposeNoNeedForResetTimeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, TimeUnit.MINUTES, Schedulers.single(), true);
TestSubscriber<Integer> ts = cf.test();
Disposable d = cf.connect();
pp.onNext(1);
d.dispose();
ts = cf.test();
ts.assertEmpty();
cf.connect();
ts.assertEmpty();
pp.onNext(2);
ts.assertValuesOnly(2);
}
Aggregations