use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableTakeTimedTest method testTakeTimedErrorBeforeTime.
@Test
public void testTakeTimedErrorBeforeTime() {
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);
source.onError(new TestException());
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
InOrder inOrder = inOrder(o);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onComplete();
verify(o, never()).onNext(4);
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableWindowWithStartEndFlowableTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
innerScheduler = scheduler.createWorker();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class ObservableDebounceTest method debounceWithTimeBackpressure.
@Test
public void debounceWithTimeBackpressure() throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
TestObserver<Integer> observer = new TestObserver<Integer>();
Observable.merge(Observable.just(1), Observable.just(2).delay(10, TimeUnit.MILLISECONDS, scheduler)).debounce(20, TimeUnit.MILLISECONDS, scheduler).take(1).subscribe(observer);
scheduler.advanceTimeBy(30, TimeUnit.MILLISECONDS);
observer.assertValue(2);
observer.assertTerminated();
observer.assertNoErrors();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class ObservableDebounceTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
observer = TestHelper.mockObserver();
innerScheduler = scheduler.createWorker();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class ObservableDebounceTest method badSource.
@Test
public void badSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposables.empty());
observer.onComplete();
observer.onNext(1);
observer.onError(new TestException());
observer.onComplete();
}
}.debounce(1, TimeUnit.SECONDS, new TestScheduler()).test().assertResult();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations