Search in sources :

Example 91 with TestException

use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.

the class ReplayProcessorTest method sizeAndTimeBoundReplayError.

@Test
public void sizeAndTimeBoundReplayError() {
    ReplayProcessor<Integer> rp = ReplayProcessor.createWithTimeAndSize(1, TimeUnit.DAYS, Schedulers.single(), 2);
    rp.onNext(1);
    rp.onNext(2);
    rp.onNext(3);
    rp.onNext(4);
    rp.onError(new TestException());
    rp.test().assertFailure(TestException.class, 3, 4);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Example 92 with TestException

use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.

the class ReplayProcessorTest method sizeboundReplayError.

@Test
public void sizeboundReplayError() {
    ReplayProcessor<Integer> rp = ReplayProcessor.createWithSize(2);
    rp.onNext(1);
    rp.onNext(2);
    rp.onNext(3);
    rp.onNext(4);
    rp.onError(new TestException());
    rp.test().assertFailure(TestException.class, 3, 4);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Example 93 with TestException

use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.

the class SchedulerTest method scheduleDirectThrows.

@Test
public void scheduleDirectThrows() throws Exception {
    List<Throwable> list = TestHelper.trackPluginErrors();
    try {
        Schedulers.io().scheduleDirect(new Runnable() {

            @Override
            public void run() {
                throw new TestException();
            }
        });
        Thread.sleep(250);
        assertTrue(list.size() >= 1);
        TestHelper.assertUndeliverable(list, 0, TestException.class, null);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 94 with TestException

use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.

the class SingleCacheTest method crossCancelOnError.

@Test
public void crossCancelOnError() {
    PublishSubject<Integer> ps = PublishSubject.create();
    Single<Integer> cache = ps.single(-99).cache();
    final TestSubscriber<Integer> ts1 = new TestSubscriber<>();
    TestSubscriber<Integer> ts2 = new TestSubscriber<Integer>() {

        @Override
        public void onError(Throwable t) {
            super.onError(t);
            ts1.cancel();
        }
    };
    cache.toFlowable().subscribe(ts2);
    cache.toFlowable().subscribe(ts1);
    ps.onError(new TestException());
    ts1.assertNoValues().assertNoErrors().assertNotComplete();
    ts2.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 95 with TestException

use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.

the class SingleRetryTest method untilFalseError.

@Test
public void untilFalseError() {
    AtomicInteger counter = new AtomicInteger();
    Single.defer(() -> {
        if (counter.getAndIncrement() == 0) {
            return Single.error(new TestException());
        }
        return Single.just(1);
    }).retryUntil(() -> false).test().assertResult(1);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)656 Test (org.junit.Test)555 IOException (java.io.IOException)95 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)90 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)81 Disposable (io.reactivex.rxjava3.disposables.Disposable)56 InOrder (org.mockito.InOrder)54 TestObserver (io.reactivex.rxjava3.observers.TestObserver)47 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)47 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)40 Observable (io.reactivex.rxjava3.core.Observable)38 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)20 Action (io.reactivex.rxjava3.functions.Action)20 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)20 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)18 Observer (io.reactivex.rxjava3.core.Observer)15 TestHelper (io.reactivex.rxjava3.testsupport.TestHelper)15 Assert (org.junit.Assert)15 java.util (java.util)13 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)12