Search in sources :

Example 1 with ScheduledWorker

use of io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker in project RxJava by ReactiveX.

the class SingleSchedulerTest method shutdownRejects.

@Test
@SuppressUndeliverable
public void shutdownRejects() {
    final int[] calls = { 0 };
    Runnable r = new Runnable() {

        @Override
        public void run() {
            calls[0]++;
        }
    };
    Scheduler s = new SingleScheduler();
    s.shutdown();
    assertEquals(Disposable.disposed(), s.scheduleDirect(r));
    assertEquals(Disposable.disposed(), s.scheduleDirect(r, 1, TimeUnit.SECONDS));
    assertEquals(Disposable.disposed(), s.schedulePeriodicallyDirect(r, 1, 1, TimeUnit.SECONDS));
    Worker w = s.createWorker();
    ((ScheduledWorker) w).executor.shutdownNow();
    assertEquals(Disposable.disposed(), w.schedule(r));
    assertEquals(Disposable.disposed(), w.schedule(r, 1, TimeUnit.SECONDS));
    assertEquals(Disposable.disposed(), w.schedulePeriodically(r, 1, 1, TimeUnit.SECONDS));
    assertEquals(0, calls[0]);
    w.dispose();
    assertTrue(w.isDisposed());
}
Also used : Scheduler(io.reactivex.rxjava3.core.Scheduler) ScheduledWorker(io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) Test(org.junit.Test)

Aggregations

Scheduler (io.reactivex.rxjava3.core.Scheduler)1 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)1 ScheduledWorker (io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker)1 Test (org.junit.Test)1