use of io.reactivex.rxjava3.exceptions.TestException 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.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableMapOptionalTest method mapperChashConditional.
@Test
public void mapperChashConditional() {
BehaviorSubject<Integer> source = BehaviorSubject.createDefault(1);
source.mapOptional(v -> {
throw new TestException();
}).filter(v -> true).test().assertFailure(TestException.class);
assertFalse(source.hasObservers());
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class BlockingFirstObserverTest method firstValueOnly.
@Test
public void firstValueOnly() {
BlockingFirstObserver<Integer> bf = new BlockingFirstObserver<>();
Disposable d = Disposable.empty();
bf.onSubscribe(d);
bf.onNext(1);
assertTrue(d.isDisposed());
assertEquals(1, bf.value.intValue());
assertEquals(0, bf.getCount());
bf.onNext(2);
assertEquals(1, bf.value.intValue());
assertEquals(0, bf.getCount());
bf.onError(new TestException());
assertEquals(1, bf.value.intValue());
assertNull(bf.error);
assertEquals(0, bf.getCount());
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FutureSingleObserverTest method onErrorCancelRace.
@Test
public void onErrorCancelRace() {
RxJavaPlugins.setErrorHandler(Functions.emptyConsumer());
try {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final PublishSubject<Integer> ps = PublishSubject.create();
final Future<?> f = ps.single(-99).toFuture();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
f.cancel(true);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
ps.onError(ex);
}
};
TestHelper.race(r1, r2);
}
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class CompletableToCompletionStageTest method completableManualCompleteExceptionallyCancels.
@Test
public void completableManualCompleteExceptionallyCancels() throws Exception {
CompletableSubject source = CompletableSubject.create();
CompletableFuture<Object> cf = source.toCompletionStage(null).toCompletableFuture();
assertTrue(source.hasObservers());
cf.completeExceptionally(new TestException());
assertTrue(cf.isDone());
assertTrue(cf.isCompletedExceptionally());
assertFalse(cf.isCancelled());
assertFalse(source.hasObservers());
TestHelper.assertError(cf, TestException.class);
}
Aggregations