use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableFlattenIterableTest method onErrorLate.
@Test
public void onErrorLate() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
FlattenIterableSubscriber<Integer, Integer> f = new FlattenIterableSubscriber<>(ts, Functions.justFunction(Collections.<Integer>emptyList()), 128);
f.onSubscribe(new BooleanSubscription());
f.onError(new TestException("first"));
ts.assertFailureAndMessage(TestException.class, "first");
assertTrue(errors.isEmpty());
f.done = false;
f.onError(new TestException("second"));
TestHelper.assertUndeliverable(errors, 0, TestException.class, "second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableCombineLatestTest method onErrorDisposeDelayErrorRace.
@Test
public void onErrorDisposeDelayErrorRace() throws Throwable {
TestHelper.withErrorTracking(errors -> {
TestException ex = new TestException();
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
TestSubscriberEx<Object[]> ts = new TestSubscriberEx<>();
AtomicReference<Subscriber<? super Object>> ref = new AtomicReference<>();
Flowable<Object> f = new Flowable<Object>() {
@Override
public void subscribeActual(Subscriber<? super Object> s) {
ref.set(s);
}
};
Flowable.combineLatestDelayError(Arrays.asList(f, Flowable.never()), (a) -> a).subscribe(ts);
ref.get().onSubscribe(new BooleanSubscription());
TestHelper.race(() -> ref.get().onError(ex), () -> ts.cancel());
if (ts.errors().isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
}
});
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableSwitchMapMaybeTest method innerErrorAfterTermination.
@Test
public void innerErrorAfterTermination() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<MaybeObserver<? super Integer>> moRef = new AtomicReference<>();
TestSubscriberEx<Integer> ts = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onError(new TestException("outer"));
}
}.switchMapMaybe(new Function<Integer, MaybeSource<Integer>>() {
@Override
public MaybeSource<Integer> apply(Integer v) throws Exception {
return new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
moRef.set(observer);
}
};
}
}).to(TestHelper.<Integer>testConsumer());
ts.assertFailureAndMessage(TestException.class, "outer");
moRef.get().onError(new TestException("inner"));
moRef.get().onComplete();
TestHelper.assertUndeliverable(errors, 0, TestException.class, "inner");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableSwitchMapSingleTest method innerErrorAfterTermination.
@Test
public void innerErrorAfterTermination() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<SingleObserver<? super Integer>> moRef = new AtomicReference<>();
TestSubscriberEx<Integer> ts = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onError(new TestException("outer"));
}
}.switchMapSingle(new Function<Integer, SingleSource<Integer>>() {
@Override
public SingleSource<Integer> apply(Integer v) throws Exception {
return new Single<Integer>() {
@Override
protected void subscribeActual(SingleObserver<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
moRef.set(observer);
}
};
}
}).to(TestHelper.<Integer>testConsumer());
ts.assertFailureAndMessage(TestException.class, "outer");
moRef.get().onError(new TestException("inner"));
TestHelper.assertUndeliverable(errors, 0, TestException.class, "inner");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class MaybeMergeArrayTest method errorFused.
@Test
public void errorFused() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>().setInitialFusionMode(QueueFuseable.ANY);
Maybe.mergeArray(Maybe.<Integer>error(new TestException()), Maybe.just(2)).subscribe(ts);
ts.assertFuseable().assertFusionMode(QueueFuseable.ASYNC).assertFailure(TestException.class);
}
Aggregations