use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableUnsubscribeOnTest method signalAfterDispose.
@Test
public void signalAfterDispose() {
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();
}
}.unsubscribeOn(Schedulers.single()).take(1).test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableWindowWithStartEndFlowableTest method endError.
@Test
public void endError() {
PublishProcessor<Integer> source = PublishProcessor.create();
PublishProcessor<Integer> start = PublishProcessor.create();
final PublishProcessor<Integer> end = PublishProcessor.create();
TestSubscriber<Integer> to = source.window(start, new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer v) throws Exception {
return end;
}
}).flatMap(Functions.<Flowable<Integer>>identity()).test();
start.onNext(1);
end.onError(new TestException());
to.assertFailure(TestException.class);
assertFalse("Source has observers!", source.hasSubscribers());
assertFalse("Start has observers!", start.hasSubscribers());
assertFalse("End has observers!", end.hasSubscribers());
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableSkipTimedTest method testSkipTimedErrorBeforeTime.
@Test
public void testSkipTimedErrorBeforeTime() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.skip(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> o = TestHelper.mockSubscriber();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
InOrder inOrder = inOrder(o);
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 FlowableTakeLastTimedTest method takeLastTimedThrowingSource.
@Test
public void takeLastTimedThrowingSource() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Object> source = PublishProcessor.create();
Flowable<Object> result = source.takeLast(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
result.subscribe(o);
// T: 0ms
source.onNext(1);
scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
// T: 250ms
source.onNext(2);
scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
// T: 500ms
source.onNext(3);
scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
// T: 750ms
source.onNext(4);
scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
// T: 1000ms
source.onNext(5);
scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
// T: 1250ms
source.onError(new TestException());
inOrder.verify(o, times(1)).onError(any(TestException.class));
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableTakeTimedTest method testTakeTimedErrorAfterTime.
@Test
public void testTakeTimedErrorAfterTime() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.take(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> o = TestHelper.mockSubscriber();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
source.onError(new TestException());
InOrder inOrder = inOrder(o);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onComplete();
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(4);
verify(o, never()).onError(any(TestException.class));
}
Aggregations