use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeAmbTest method innerErrorRace.
@Test
public void innerErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp0 = PublishProcessor.create();
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final TestObserver<Integer> to = Maybe.amb(Arrays.asList(pp0.singleElement(), pp1.singleElement())).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
pp0.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
pp1.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCacheTest method crossCancelOnError.
@Test
public void crossCancelOnError() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
PublishProcessor<Integer> pp = PublishProcessor.create();
Maybe<Integer> source = pp.singleElement().cache();
source.subscribe(Functions.emptyConsumer(), new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
ts.cancel();
}
});
source.toFlowable().subscribe(ts);
pp.onError(new TestException());
ts.assertEmpty();
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableWindowWithStartEndFlowableTest method closeError.
@Test
public void closeError() throws Throwable {
TestHelper.withErrorTracking(errors -> {
AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
AtomicReference<Subscriber<? super Integer>> ref2 = new AtomicReference<>();
Flowable<Integer> f1 = Flowable.<Integer>unsafeCreate(ref1::set);
Flowable<Integer> f2 = Flowable.<Integer>unsafeCreate(ref2::set);
TestSubscriber<Integer> ts = BehaviorProcessor.createDefault(1).window(f1, v -> f2).flatMap(v -> v).test();
ref1.get().onSubscribe(new BooleanSubscription());
ref1.get().onNext(1);
ref2.get().onSubscribe(new BooleanSubscription());
ref2.get().onError(new TestException());
ref2.get().onError(new TestException());
ts.assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableWindowWithStartEndFlowableTest method windowOpenMainError.
@Test
public void windowOpenMainError() {
AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
PublishProcessor<Object> pp = PublishProcessor.create();
Flowable<Integer> f1 = Flowable.<Integer>unsafeCreate(ref1::set);
AtomicInteger counter = new AtomicInteger();
TestSubscriber<Flowable<Object>> ts = pp.window(f1, v -> Flowable.never()).doOnNext(w -> {
if (counter.getAndIncrement() == 0) {
ref1.get().onNext(2);
pp.onNext(1);
pp.onError(new TestException());
}
w.test();
}).test();
ref1.get().onSubscribe(new BooleanSubscription());
ref1.get().onNext(1);
ts.assertError(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableWithLatestFromTest method withError.
@Test
public void withError() {
TestSubscriber<String> ts = new TestSubscriber<>(0);
Flowable.range(1, 3).withLatestFrom(new Flowable<?>[] { Flowable.just(1), Flowable.error(new TestException()) }, toArray).subscribe(ts);
ts.assertNoValues();
ts.assertError(TestException.class);
ts.assertNotComplete();
}
Aggregations