use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class CompletableDisposeOnTest method error.
@Test
public void error() {
TestScheduler scheduler = new TestScheduler();
final int[] call = { 0 };
Completable.error(new TestException()).doOnDispose(new Action() {
@Override
public void run() throws Exception {
call[0]++;
}
}).unsubscribeOn(scheduler).test().assertFailure(TestException.class);
scheduler.triggerActions();
assertEquals(0, call[0]);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDoAfterNextTest method errorConditional.
@Test
public void errorConditional() {
Flowable.<Integer>error(new TestException()).doAfterNext(afterNext).filter(Functions.alwaysTrue()).subscribeWith(ts).assertFailure(TestException.class);
assertTrue(values.isEmpty());
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDelayTest method testErrorRunsBeforeOnNext.
@Test
public void testErrorRunsBeforeOnNext() {
TestScheduler test = new TestScheduler();
PublishProcessor<Integer> ps = PublishProcessor.create();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ps.delay(1, TimeUnit.SECONDS, test).subscribe(ts);
ps.onNext(1);
test.advanceTimeBy(500, TimeUnit.MILLISECONDS);
ps.onError(new TestException());
test.advanceTimeBy(1, TimeUnit.SECONDS);
ts.assertNoValues();
ts.assertError(TestException.class);
ts.assertNotComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableDelayFunctionThrows.
@Test
public void testDelayWithFlowableDelayFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
throw new TestException();
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDelayTest method onErrorFinal.
@Test
public void onErrorFinal() {
TestScheduler scheduler = new TestScheduler();
Flowable.error(new TestException()).delay(1, TimeUnit.MILLISECONDS, scheduler).subscribe(new DisposableSubscriber<Object>() {
@Override
public void onNext(Object value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
}
});
try {
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
}
Aggregations