Search in sources :

Example 16 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class FlowableIntervalRange method subscribeActual.

@Override
public void subscribeActual(Subscriber<? super Long> s) {
    IntervalRangeSubscriber is = new IntervalRangeSubscriber(s, start, end);
    s.onSubscribe(is);
    Scheduler sch = scheduler;
    if (sch instanceof TrampolineScheduler) {
        Worker worker = sch.createWorker();
        is.setResource(worker);
        worker.schedulePeriodically(is, initialDelay, period, unit);
    } else {
        Disposable d = sch.schedulePeriodicallyDirect(is, initialDelay, period, unit);
        is.setResource(d);
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)

Example 17 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class BlockingFirstObserverTest method firstValueOnly.

@Test
public void firstValueOnly() {
    BlockingFirstObserver<Integer> bf = new BlockingFirstObserver<>();
    Disposable d = Disposable.empty();
    bf.onSubscribe(d);
    bf.onNext(1);
    assertTrue(d.isDisposed());
    assertEquals(1, bf.value.intValue());
    assertEquals(0, bf.getCount());
    bf.onNext(2);
    assertEquals(1, bf.value.intValue());
    assertEquals(0, bf.getCount());
    bf.onError(new TestException());
    assertEquals(1, bf.value.intValue());
    assertNull(bf.error);
    assertEquals(0, bf.getCount());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 18 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class FutureMultiObserverTest method cancelBeforeOnSubscribe.

@Test
public void cancelBeforeOnSubscribe() {
    FutureMultiObserver<Integer> f = new FutureMultiObserver<>();
    assertTrue(f.cancel(true));
    Disposable d = Disposable.empty();
    f.onSubscribe(d);
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 19 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class DeferredScalarObserverTest method fusedError.

@Test
public void fusedError() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
        TakeLast source = new TakeLast(to);
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        source.onNext(1);
        source.onError(new TestException());
        source.onError(new TestException("second"));
        source.onComplete();
        to.assertFailure(TestException.class);
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 20 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class DeferredScalarObserverTest method normal.

@Test
public void normal() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Integer> to = new TestObserver<>();
        TakeFirst source = new TakeFirst(to);
        source.onSubscribe(Disposable.empty());
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        assertTrue(d.isDisposed());
        source.onNext(1);
        to.assertResult(1);
        TestHelper.assertError(errors, 0, ProtocolViolationException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)251 Disposable (io.reactivex.rxjava3.disposables.Disposable)236 TestException (io.reactivex.rxjava3.exceptions.TestException)74 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)56 IOException (java.io.IOException)38 Scheduler (io.reactivex.rxjava3.core.Scheduler)36 EmptyDisposable (io.reactivex.rxjava3.internal.disposables.EmptyDisposable)35 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)34 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)32 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)22 TestObserver (io.reactivex.rxjava3.observers.TestObserver)18 SequentialDisposable (io.reactivex.rxjava3.internal.disposables.SequentialDisposable)15 QueueDisposable (io.reactivex.rxjava3.operators.QueueDisposable)13 CountingRunnable (io.reactivex.rxjava3.android.testutil.CountingRunnable)10 TrampolineScheduler (io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)9 LifecycleDisposable (org.thoughtcrime.securesms.util.LifecycleDisposable)8 Observable (io.reactivex.rxjava3.core.Observable)6 Observer (io.reactivex.rxjava3.core.Observer)6 ScalarDisposable (io.reactivex.rxjava3.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)6