Search in sources :

Example 11 with Scheduler

use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.

the class FlowableWindowWithStartEndFlowableTest method before.

@Before
public void before() {
    scheduler = new TestScheduler();
    innerScheduler = scheduler.createWorker();
}
Also used : TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler)

Example 12 with Scheduler

use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.

the class MaybeDelaySubscriptionTest method timedTestScheduler.

@Test
public void timedTestScheduler() {
    TestScheduler scheduler = new TestScheduler();
    TestObserver<Integer> to = Maybe.just(1).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler).test();
    to.assertEmpty();
    scheduler.advanceTimeBy(99, TimeUnit.MILLISECONDS);
    to.assertEmpty();
    scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
    to.assertResult(1);
}
Also used : TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) Test(org.junit.Test)

Example 13 with Scheduler

use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.

the class MaybeDelayTest method delayedErrorOnError.

@Test
public void delayedErrorOnError() {
    final TestScheduler scheduler = new TestScheduler();
    final TestObserver<?> observer = Maybe.error(new TestException()).delay(5, TimeUnit.SECONDS, scheduler, true).test();
    scheduler.advanceTimeTo(2, TimeUnit.SECONDS);
    observer.assertNoErrors();
    scheduler.advanceTimeTo(5, TimeUnit.SECONDS);
    observer.assertError(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) Test(org.junit.Test)

Example 14 with Scheduler

use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.

the class MaybeDelayTest method disposeDuringDelay.

@Test
public void disposeDuringDelay() {
    TestScheduler scheduler = new TestScheduler();
    TestObserver<Integer> to = Maybe.just(1).delay(100, TimeUnit.MILLISECONDS, scheduler).test();
    to.dispose();
    scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
    to.assertEmpty();
}
Also used : TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) Test(org.junit.Test)

Example 15 with Scheduler

use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.

the class SingleDelayTest method delayedErrorOnError.

@Test
public void delayedErrorOnError() {
    final TestScheduler scheduler = new TestScheduler();
    final TestObserver<?> observer = Single.error(new TestException()).delay(5, TimeUnit.SECONDS, scheduler, true).test();
    scheduler.advanceTimeTo(2, TimeUnit.SECONDS);
    observer.assertNoErrors();
    scheduler.advanceTimeTo(5, TimeUnit.SECONDS);
    observer.assertError(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)169 Disposable (io.reactivex.rxjava3.disposables.Disposable)69 Scheduler (io.reactivex.rxjava3.core.Scheduler)61 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)54 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)50 TestException (io.reactivex.rxjava3.exceptions.TestException)34 EmptyDisposable (io.reactivex.rxjava3.internal.disposables.EmptyDisposable)32 InOrder (org.mockito.InOrder)32 TrampolineScheduler (io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)20 ImmediateThinScheduler (io.reactivex.rxjava3.internal.schedulers.ImmediateThinScheduler)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)9 EmptyScheduler (io.reactivex.rxjava3.android.testutil.EmptyScheduler)8 Observable (io.reactivex.rxjava3.core.Observable)7 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)6 SequentialDisposable (io.reactivex.rxjava3.internal.disposables.SequentialDisposable)6 Action (io.reactivex.rxjava3.functions.Action)5 SuppressUndeliverable (io.reactivex.rxjava3.testsupport.SuppressUndeliverable)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5