use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherCancelDuringSingle.
@Test
public void flatMapPublisherCancelDuringSingle() {
final AtomicBoolean disposed = new AtomicBoolean();
TestSubscriberEx<Integer> ts = Single.<Integer>never().doOnDispose(new Action() {
@Override
public void run() throws Exception {
disposed.set(true);
}
}).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
return Flowable.range(v, 5);
}
}).to(TestHelper.<Integer>testConsumer()).assertNoValues().assertNotTerminated();
assertFalse(disposed.get());
ts.cancel();
assertTrue(disposed.get());
ts.assertNotTerminated();
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherCancelDuringFlowable.
@Test
public void flatMapPublisherCancelDuringFlowable() {
final AtomicBoolean disposed = new AtomicBoolean();
TestSubscriberEx<Integer> ts = Single.just(1).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
return Flowable.<Integer>never().doOnCancel(new Action() {
@Override
public void run() throws Exception {
disposed.set(true);
}
});
}
}).to(TestHelper.<Integer>testConsumer()).assertNoValues().assertNotTerminated();
assertFalse(disposed.get());
ts.cancel();
assertTrue(disposed.get());
ts.assertNotTerminated();
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class StrictSubscriberTest method doubleOnSubscribe.
@Test
public void doubleOnSubscribe() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
SubscriberWrapper<Integer> wrapper = new SubscriberWrapper<>(ts);
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
BooleanSubscription b1 = new BooleanSubscription();
s.onSubscribe(b1);
BooleanSubscription b2 = new BooleanSubscription();
s.onSubscribe(b2);
assertTrue(b1.isCancelled());
assertTrue(b2.isCancelled());
}
}.subscribe(wrapper);
ts.assertFailure(IllegalStateException.class);
assertTrue(ts.errors().toString(), ts.errors().get(0).getMessage().contains("2.12"));
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableOnBackpressureReduceTest method createDelayedSubscriber.
private <T> TestSubscriberEx<T> createDelayedSubscriber() {
return new TestSubscriberEx<T>(1L) {
final Random rnd = new Random();
@Override
public void onNext(T t) {
super.onNext(t);
if (rnd.nextDouble() < 0.001) {
try {
Thread.sleep(1);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
request(1);
}
};
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableIgnoreElementsTest method errorReceivedFlowable.
@Test
public void errorReceivedFlowable() {
TestSubscriberEx<Object> ts = new TestSubscriberEx<>();
TestException ex = new TestException("boo");
Flowable.error(ex).ignoreElements().toFlowable().subscribe(ts);
ts.assertNoValues();
ts.assertTerminated();
ts.assertError(TestException.class);
ts.assertErrorMessage("boo");
}
Aggregations