use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFlatMapStreamTest method mapperThrowsWhenUpstreamErrors.
@Test
public void mapperThrowsWhenUpstreamErrors() throws Throwable {
TestHelper.withErrorTracking(errors -> {
PublishProcessor<Integer> pp = PublishProcessor.create();
AtomicInteger counter = new AtomicInteger();
TestSubscriber<Integer> ts = pp.hide().concatMapStream(v -> {
if (counter.getAndIncrement() == 0) {
return Stream.of(1, 2);
}
pp.onError(new IOException());
throw new TestException();
}).test();
pp.onNext(1);
pp.onNext(2);
ts.assertFailure(IOException.class, 1, 2);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class ParallelCollectorTest method doubleError.
@Test
public void doubleError() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new ParallelInvalid().collect(Collectors.toList()).test().assertFailure(TestException.class);
assertFalse(errors.isEmpty());
for (Throwable ex : errors) {
assertTrue(ex.toString(), ex.getCause() instanceof TestException);
}
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleFlattenStreamAsObservableTest method streamCloseCrash.
@Test
public void streamCloseCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
Single.just(1).flattenStreamAsObservable(v -> Stream.of(v).onClose(() -> {
throw new TestException();
})).test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleFlattenStreamAsObservableTest method hasNextThrowsInDrain.
@Test
public void hasNextThrowsInDrain() {
@SuppressWarnings("unchecked") Stream<Integer> stream = mock(Stream.class);
when(stream.iterator()).thenReturn(new Iterator<Integer>() {
int count;
@Override
public boolean hasNext() {
if (count++ > 0) {
throw new TestException();
}
return true;
}
@Override
public Integer next() {
return 1;
}
});
Single.just(1).flattenStreamAsObservable(v -> stream).test().assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableFlatMapStreamTest method hasNextThrowsLater.
@Test
public void hasNextThrowsLater() {
AtomicInteger counter = new AtomicInteger();
Observable.just(1).hide().concatMapStream(v -> Stream.generate(() -> {
if (counter.getAndIncrement() == 0) {
return 1;
}
throw new TestException();
})).test().assertFailure(TestException.class, 1);
}
Aggregations