Search in sources :

Example 11 with SerializedObserver

use of io.reactivex.rxjava3.observers.SerializedObserver in project RxJava by ReactiveX.

the class SerializedObserverTest method dispose.

@Test
public void dispose() {
    TestObserver<Integer> to = new TestObserver<>();
    SerializedObserver<Integer> so = new SerializedObserver<>(to);
    Disposable d = Disposable.empty();
    so.onSubscribe(d);
    assertFalse(so.isDisposed());
    to.dispose();
    assertTrue(so.isDisposed());
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable)

Example 12 with SerializedObserver

use of io.reactivex.rxjava3.observers.SerializedObserver in project RxJava by ReactiveX.

the class SerializedObserverTest method onCompleteRace.

@Test
public void onCompleteRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        TestObserver<Integer> to = new TestObserver<>();
        final SerializedObserver<Integer> so = new SerializedObserver<>(to);
        Disposable d = Disposable.empty();
        so.onSubscribe(d);
        Runnable r = new Runnable() {

            @Override
            public void run() {
                so.onComplete();
            }
        };
        TestHelper.race(r, r);
        to.awaitDone(5, TimeUnit.SECONDS).assertResult();
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable)

Aggregations

Disposable (io.reactivex.rxjava3.disposables.Disposable)9 TestException (io.reactivex.rxjava3.exceptions.TestException)5 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)2 SerializedObserver (io.reactivex.rxjava3.observers.SerializedObserver)1