use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableTimeoutTests method shouldSwitchToOtherIfOnNextNotWithinTimeout.
@Test
public void shouldSwitchToOtherIfOnNextNotWithinTimeout() {
Flowable<String> other = Flowable.just("a", "b", "c");
Flowable<String> source = underlyingSubject.timeout(TIMEOUT, TIME_UNIT, testScheduler, other);
Subscriber<String> subscriber = TestHelper.mockSubscriber();
TestSubscriber<String> ts = new TestSubscriber<>(subscriber);
source.subscribe(ts);
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
underlyingSubject.onNext("One");
testScheduler.advanceTimeBy(4, TimeUnit.SECONDS);
underlyingSubject.onNext("Two");
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber, times(1)).onNext("One");
inOrder.verify(subscriber, times(1)).onNext("a");
inOrder.verify(subscriber, times(1)).onNext("b");
inOrder.verify(subscriber, times(1)).onNext("c");
inOrder.verify(subscriber, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
ts.cancel();
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableTakeTimedTest method takeTimed.
@Test
public void takeTimed() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.take(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
result.subscribe(subscriber);
source.onNext(1);
source.onNext(2);
source.onNext(3);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber).onNext(1);
inOrder.verify(subscriber).onNext(2);
inOrder.verify(subscriber).onNext(3);
inOrder.verify(subscriber).onComplete();
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(4);
verify(subscriber, never()).onError(any(Throwable.class));
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableThrottleFirstTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
innerScheduler = scheduler.createWorker();
subscriber = TestHelper.mockSubscriber();
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableSkipLastTimedTest method skipLastTimedErrorBeforeTime.
@Test
public void skipLastTimedErrorBeforeTime() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.skipLast(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
result.subscribe(subscriber);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
scheduler.advanceTimeBy(1050, TimeUnit.MILLISECONDS);
verify(subscriber).onError(any(TestException.class));
verify(subscriber, never()).onComplete();
verify(subscriber, never()).onNext(any());
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableSkipTimedTest method skipTimedErrorBeforeTime.
@Test
public void skipTimedErrorBeforeTime() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.skip(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
result.subscribe(subscriber);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(any());
verify(subscriber, never()).onComplete();
}
Aggregations