use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class MaybeDoOnEventTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Disposable bs = Disposable.empty();
new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
observer.onSuccess(1);
}
}.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable d) throws Exception {
throw new TestException("First");
}
}).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowableReplayEagerTruncateTest 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 FlowableMergeTest method mergeErrors.
@Test
public void mergeErrors() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable<Integer> source1 = Flowable.error(new TestException("First"));
Flowable<Integer> source2 = Flowable.error(new TestException("Second"));
Flowable.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 ObservableJoinTest method badEndSource.
@Test
public void badEndSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
@SuppressWarnings("rawtypes") final Observer[] o = { null };
TestObserverEx<Integer> to = Observable.just(1).join(Observable.just(2), Functions.justFunction(Observable.never()), Functions.justFunction(new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
o[0] = observer;
observer.onSubscribe(Disposable.empty());
observer.onError(new TestException("First"));
}
}), new BiFunction<Integer, Integer, Integer>() {
@Override
public Integer apply(Integer a, Integer b) throws Exception {
return a + b;
}
}).to(TestHelper.<Integer>testConsumer());
o[0].onError(new TestException("Second"));
to.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 ObservableMergeTest method mergeErrors.
@Test
public void mergeErrors() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Observable<Integer> source1 = Observable.error(new TestException("First"));
Observable<Integer> source2 = Observable.error(new TestException("Second"));
Observable.merge(source1, source2).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations