use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeFlattenStreamAsObservableTest 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;
}
});
Maybe.just(1).flattenStreamAsObservable(v -> stream).test().assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableCollectWithCollectorTest method collectorAccumulatorDropSignals.
@Test
public void collectorAccumulatorDropSignals() throws Throwable {
TestHelper.withErrorTracking(errors -> {
Flowable<Integer> source = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onNext(2);
s.onError(new IOException());
s.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();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableZipIterableTest method zipIterableNextThrows.
@Test
public void zipIterableNextThrows() {
PublishProcessor<String> r1 = PublishProcessor.create();
/* define a Subscriber to receive aggregated events */
Subscriber<String> subscriber = TestHelper.mockSubscriber();
InOrder io = inOrder(subscriber);
Iterable<String> r2 = new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
@Override
public boolean hasNext() {
return true;
}
@Override
public String next() {
throw new TestException();
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
};
r1.zipWith(r2, zipr2).subscribe(subscriber);
r1.onError(new TestException());
io.verify(subscriber).onError(any(TestException.class));
verify(subscriber, never()).onNext(any(String.class));
verify(subscriber, never()).onComplete();
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class NotificationLiteTest method errorNotification.
@Test
public void errorNotification() {
Object o = NotificationLite.error(new TestException());
assertEquals("NotificationLite.Error[io.reactivex.rxjava3.exceptions.TestException]", o.toString());
assertTrue(NotificationLite.isError(o));
assertFalse(NotificationLite.isComplete(o));
assertFalse(NotificationLite.isDisposable(o));
assertFalse(NotificationLite.isSubscription(o));
assertTrue(NotificationLite.getError(o) instanceof TestException);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeAmbTest method noWinnerErrorDispose.
@Test
public void noWinnerErrorDispose() throws Exception {
final TestException ex = new TestException();
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
final AtomicBoolean interrupted = new AtomicBoolean();
final CountDownLatch cdl = new CountDownLatch(1);
Maybe.ambArray(Maybe.error(ex).subscribeOn(Schedulers.single()).observeOn(Schedulers.computation()), Maybe.never()).subscribe(Functions.emptyConsumer(), new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
assertTrue(cdl.await(500, TimeUnit.SECONDS));
assertFalse("Interrupted!", interrupted.get());
}
}
Aggregations