use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableBufferTest method boundaryBoundaryError.
@SuppressWarnings("unchecked")
@Test
public void boundaryBoundaryError() {
PublishProcessor<Object> pp = PublishProcessor.create();
TestSubscriber<Collection<Object>> ts = pp.buffer(Functions.justCallable(Flowable.error(new TestException())), new Callable<Collection<Object>>() {
@Override
public Collection<Object> call() throws Exception {
return new ArrayList<Object>();
}
}).test();
pp.onError(new TestException());
ts.assertFailure(TestException.class);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableBufferTest method bufferWithSizeThrows.
@Test
public void bufferWithSizeThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<List<Integer>> result = source.buffer(2);
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
inOrder.verify(o).onNext(Arrays.asList(1, 2));
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(Arrays.asList(3));
verify(o, never()).onComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableCacheTest method unsafeChildThrows.
@Test
@Ignore("RS subscribers should not throw")
public void unsafeChildThrows() {
final AtomicInteger count = new AtomicInteger();
Flowable<Integer> source = Flowable.range(1, 100).doOnNext(new Consumer<Integer>() {
@Override
public void accept(Integer t) {
count.getAndIncrement();
}
}).cache();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
@Override
public void onNext(Integer t) {
throw new TestException();
}
};
source.subscribe(ts);
Assert.assertEquals(100, count.get());
ts.assertNoValues();
ts.assertNotComplete();
ts.assertError(TestException.class);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class BlockingFlowableNextTest method testOnError.
@Test
public void testOnError() throws Throwable {
FlowableProcessor<String> obs = PublishProcessor.create();
Iterator<String> it = obs.blockingNext().iterator();
obs.onError(new TestException());
try {
it.hasNext();
fail("Expected an TestException");
} catch (TestException e) {
// successful
}
assertErrorAfterObservableFail(it);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableAllTest method predicateThrowsObservable.
@Test
public void predicateThrowsObservable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> observer) {
observer.onSubscribe(new BooleanSubscription());
observer.onNext(1);
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.all(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).toFlowable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations