Search in sources :

Example 41 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class SafeSubscriberTest method onNextAfterComplete.

@Test
@SuppressUndeliverable
public void onNextAfterComplete() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    SafeSubscriber<Integer> so = new SafeSubscriber<>(ts);
    BooleanSubscription bs = new BooleanSubscription();
    so.onSubscribe(bs);
    so.onComplete();
    so.onNext(1);
    so.onError(new TestException());
    so.onComplete();
    ts.assertResult();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 42 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class NewThreadSchedulerTest method shutdownRejects.

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

        @Override
        public void run() {
            calls[0]++;
        }
    };
    Scheduler s = getScheduler();
    Worker w = s.createWorker();
    w.dispose();
    assertTrue(w.isDisposed());
    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));
    NewThreadWorker actual = (NewThreadWorker) w;
    CompositeDisposable cd = new CompositeDisposable();
    actual.scheduleActual(r, 1, TimeUnit.SECONDS, cd);
    assertEquals(0, cd.size());
    assertEquals(0, calls[0]);
}
Also used : Scheduler(io.reactivex.rxjava3.core.Scheduler) NewThreadWorker(io.reactivex.rxjava3.internal.schedulers.NewThreadWorker) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) NewThreadWorker(io.reactivex.rxjava3.internal.schedulers.NewThreadWorker) Test(org.junit.Test) SuppressUndeliverable(io.reactivex.rxjava3.testsupport.SuppressUndeliverable)

Example 43 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class AsyncSubjectTest method onErrorCancelRace.

@Test
@SuppressUndeliverable
public void onErrorCancelRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        final AsyncSubject<Object> p = AsyncSubject.create();
        final TestObserverEx<Object> to1 = p.to(TestHelper.testConsumer());
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                to1.dispose();
            }
        };
        final TestException ex = new TestException();
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                p.onError(ex);
            }
        };
        TestHelper.race(r1, r2);
        if (to1.errors().size() != 0) {
            to1.assertFailure(TestException.class);
        } else {
            to1.assertEmpty();
        }
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 44 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class PublishSubjectTest method crossCancelOnError.

@Test
@SuppressUndeliverable
public void crossCancelOnError() {
    final TestObserver<Integer> to1 = new TestObserver<>();
    TestObserver<Integer> to2 = new TestObserver<Integer>() {

        @Override
        public void onError(Throwable t) {
            super.onError(t);
            to1.dispose();
        }
    };
    PublishSubject<Integer> ps = PublishSubject.create();
    ps.subscribe(to2);
    ps.subscribe(to1);
    ps.onError(new TestException());
    to2.assertError(TestException.class);
    to1.assertNoErrors();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)31 Test (org.junit.Test)30 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 Observable (io.reactivex.rxjava3.core.Observable)8 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)8 IOException (java.io.IOException)8 SuppressUndeliverable (io.reactivex.rxjava3.testsupport.SuppressUndeliverable)7 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)6 Disposable (io.reactivex.rxjava3.disposables.Disposable)6 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)5 Scheduler (io.reactivex.rxjava3.core.Scheduler)3 TestObserver (io.reactivex.rxjava3.observers.TestObserver)3 NewThreadWorker (io.reactivex.rxjava3.internal.schedulers.NewThreadWorker)2 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)2 Observer (io.reactivex.rxjava3.core.Observer)1 Cancellable (io.reactivex.rxjava3.functions.Cancellable)1 ComputationScheduler (io.reactivex.rxjava3.internal.schedulers.ComputationScheduler)1 DelayedRunnable (io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler.DelayedRunnable)1 IoScheduler (io.reactivex.rxjava3.internal.schedulers.IoScheduler)1 ScheduledWorker (io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker)1