use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class SchedulerWhenTest method syncMaxConcurrent.
@Test
public void syncMaxConcurrent() {
TestScheduler tSched = new TestScheduler();
SchedulerWhen sched = maxConcurrentScheduler(tSched);
TestSubscriber<Long> tSub = TestSubscriber.create();
syncWork(sched).subscribe(tSub);
tSub.assertValueCount(0);
tSched.advanceTimeBy(0, SECONDS);
// since all the work is synchronous nothing is blocked and its all done
tSub.assertValueCount(5);
tSub.assertComplete();
sched.dispose();
}
use of io.reactivex.rxjava3.schedulers.TestScheduler 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
}
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableBufferTest method timedSizeBufferAlreadyCleared.
@Test
public void timedSizeBufferAlreadyCleared() {
TestScheduler sch = new TestScheduler();
TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
BufferExactBoundedSubscriber<Integer, List<Integer>> sub = new BufferExactBoundedSubscriber<>(ts, Functions.justSupplier((List<Integer>) new ArrayList<Integer>()), 1, TimeUnit.SECONDS, 1, false, sch.createWorker());
BooleanSubscription bs = new BooleanSubscription();
sub.onSubscribe(bs);
sub.producerIndex++;
sub.run();
assertFalse(sub.isDisposed());
sub.enter();
sub.onComplete();
assertTrue(sub.isDisposed());
sub.run();
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableBufferTest method timedSkipCancelWhenSecondBuffer.
@Test
public void timedSkipCancelWhenSecondBuffer() {
TestScheduler sch = new TestScheduler();
final TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
BufferSkipBoundedSubscriber<Integer, List<Integer>> sub = new BufferSkipBoundedSubscriber<>(ts, new Supplier<List<Integer>>() {
int calls;
@Override
public List<Integer> get() throws Exception {
if (++calls == 2) {
ts.cancel();
}
return new ArrayList<>();
}
}, 1, 1, TimeUnit.SECONDS, sch.createWorker());
sub.onSubscribe(new BooleanSubscription());
sub.run();
assertTrue(ts.isCancelled());
}
use of io.reactivex.rxjava3.schedulers.TestScheduler in project RxJava by ReactiveX.
the class FlowableDebounceTest method timedLateEmit.
@Test
public void timedLateEmit() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
DebounceTimedSubscriber<Integer> sub = new DebounceTimedSubscriber<>(ts, 1, TimeUnit.SECONDS, new TestScheduler().createWorker());
sub.onSubscribe(new BooleanSubscription());
DebounceEmitter<Integer> de = new DebounceEmitter<>(1, 50, sub);
de.emit();
de.emit();
ts.assertEmpty();
}
Aggregations