use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class CompletableCacheTest method crossDisposeOnError.
@Test
public void crossDisposeOnError() {
PublishSubject<Integer> ps = PublishSubject.create();
final TestObserver<Void> to1 = new TestObserver<>();
final TestObserver<Void> to2 = new TestObserver<Void>() {
@Override
public void onError(Throwable ex) {
super.onError(ex);
to1.dispose();
}
};
Completable c = ps.ignoreElements().cache();
c.subscribe(to2);
c.subscribe(to1);
ps.onError(new TestException());
to1.assertEmpty();
to2.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableFlatMapStreamTest method mapperThrowsWhenUpstreamErrors.
@Test
public void mapperThrowsWhenUpstreamErrors() throws Throwable {
TestHelper.withErrorTracking(errors -> {
PublishSubject<Integer> ps = PublishSubject.create();
AtomicInteger counter = new AtomicInteger();
TestObserver<Integer> to = ps.hide().concatMapStream(v -> {
if (counter.getAndIncrement() == 0) {
return Stream.of(1, 2);
}
ps.onError(new IOException());
throw new TestException();
}).test();
ps.onNext(1);
ps.onNext(2);
to.assertFailure(IOException.class, 1, 2);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableFlatMapStreamTest method fusedPollCrash.
@Test
public void fusedPollCrash() {
UnicastSubject<Integer> us = UnicastSubject.create();
TestObserver<Integer> to = us.map(v -> {
throw new TestException();
}).compose(TestHelper.observableStripBoundary()).flatMapStream(v -> Stream.of(1, 2)).test();
assertTrue(us.hasObservers());
us.onNext(1);
assertFalse(us.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableFlatMapStreamTest method upstreamCancelledCloseCrash.
@Test
public void upstreamCancelledCloseCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = ps.flatMapStream(v -> Stream.of(v + 1, v + 2).onClose(() -> {
throw new TestException();
})).take(1).test();
assertTrue(ps.hasObservers());
ps.onNext(1);
to.assertResult(2);
assertFalse(ps.hasObservers());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method normal.
@Test
public void normal() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = new TestObserver<>();
TakeFirst source = new TakeFirst(to);
source.onSubscribe(Disposable.empty());
Disposable d = Disposable.empty();
source.onSubscribe(d);
assertTrue(d.isDisposed());
source.onNext(1);
to.assertResult(1);
TestHelper.assertError(errors, 0, ProtocolViolationException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations