use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowablePublishTest method doubleErrorRefCount.
@Test
public void doubleErrorRefCount() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onError(new TestException("one"));
s.onError(new TestException("two"));
}
}.publish(1).refCount().to(TestHelper.<Integer>testSubscriber(0L)).assertFailureAndMessage(TestException.class, "one");
TestHelper.assertUndeliverable(errors, 0, TestException.class, "two");
assertEquals(1, errors.size());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowableReplayTest method badSource.
@Test
public void badSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
subscriber.onError(new TestException("First"));
subscriber.onNext(1);
subscriber.onError(new TestException("Second"));
subscriber.onComplete();
}
}.replay().autoConnect().to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class SingleMergeTest method mergeErrors.
@Test
public void mergeErrors() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Single<Integer> source1 = Single.error(new TestException("First"));
Single<Integer> source2 = Single.error(new TestException("Second"));
Single.merge(source1, source2).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class SingleDoOnLifecycleTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
Action onDispose = mock(Action.class);
doThrow(new TestException("First")).when(onSubscribe).accept(any());
Disposable bs = Disposable.empty();
new Single<Integer>() {
@Override
protected void subscribeActual(SingleObserver<? super Integer> observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onSuccess(1);
}
}.doOnLifecycle(onSubscribe, onDispose).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
verify(onSubscribe).accept(any());
verify(onDispose, never()).run();
});
}
use of io.reactivex.rxjava3.testsupport.TestHelper 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();
}
Aggregations