use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFromCompletionStageTest method syncFailure.
@Test
public void syncFailure() {
CompletableFuture<Integer> cf = new CompletableFuture<>();
cf.completeExceptionally(new TestException());
Flowable.fromCompletionStage(cf).test().assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFromStreamTest method closeCalledOnItemCrashConditional.
@Test
public void closeCalledOnItemCrashConditional() {
AtomicInteger calls = new AtomicInteger();
AtomicInteger counter = new AtomicInteger();
Flowable.fromStream(Stream.<Integer>generate(() -> {
int value = counter.getAndIncrement();
if (value == 1) {
throw new TestException();
}
return value;
}).onClose(() -> calls.getAndIncrement())).filter(v -> true).test().assertFailure(TestException.class, 0);
assertEquals(1, calls.get());
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFromStreamTest method hasNextCrash.
@Test
public void hasNextCrash() {
AtomicInteger v = new AtomicInteger();
Flowable.fromStream(Stream.<Integer>generate(() -> {
int value = v.getAndIncrement();
if (value == 1) {
throw new TestException();
}
return value;
})).test().assertFailure(TestException.class, 0);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableCollectWithCollectorTest method collectorAccumulatorDropSignalsToObservable.
@Test
public void collectorAccumulatorDropSignalsToObservable() throws Throwable {
TestHelper.withErrorTracking(errors -> {
Observable<Integer> source = new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new IOException());
observer.onComplete();
}
};
source.collect(new Collector<Integer, Integer, Integer>() {
@Override
public Supplier<Integer> supplier() {
return () -> 1;
}
@Override
public BiConsumer<Integer, Integer> accumulator() {
return (a, b) -> {
throw new TestException();
};
}
@Override
public BinaryOperator<Integer> combiner() {
return (a, b) -> a + b;
}
@Override
public Function<Integer, Integer> finisher() {
return a -> a;
}
@Override
public Set<Characteristics> characteristics() {
return Collections.emptySet();
}
}).toObservable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableFromCompletionStageTest method syncFailure.
@Test
public void syncFailure() {
CompletableFuture<Integer> cf = new CompletableFuture<>();
cf.completeExceptionally(new TestException());
Observable.fromCompletionStage(cf).test().assertFailure(TestException.class);
}
Aggregations