Search in sources :

Example 81 with TestException

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

the class SingleMaterializeTest method error.

@Test
public void error() {
    TestException ex = new TestException();
    Maybe.error(ex).materialize().test().assertResult(Notification.createOnError(ex));
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 82 with TestException

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

the class SingleTakeUntilTest method untilPublisherOtherError.

@Test
public void untilPublisherOtherError() {
    SingleSubject<Integer> main = SingleSubject.create();
    PublishProcessor<Integer> other = PublishProcessor.create();
    TestObserver<Integer> to = main.takeUntil(other).test();
    assertTrue("Main no observers?", main.hasObservers());
    assertTrue("Other no observers?", other.hasSubscribers());
    other.onError(new TestException());
    assertFalse("Main has observers?", main.hasObservers());
    assertFalse("Other has observers?", other.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 83 with TestException

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

the class SingleZipIterableTest method innerErrorRace.

@Test
public void innerErrorRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            final PublishProcessor<Integer> pp0 = PublishProcessor.create();
            final PublishProcessor<Integer> pp1 = PublishProcessor.create();
            final TestObserver<Object> to = Single.zip(Arrays.asList(pp0.single(0), pp1.single(0)), addString).test();
            final TestException ex = new TestException();
            Runnable r1 = new Runnable() {

                @Override
                public void run() {
                    pp0.onError(ex);
                }
            };
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    pp1.onError(ex);
                }
            };
            TestHelper.race(r1, r2);
            to.assertFailure(TestException.class);
            if (!errors.isEmpty()) {
                TestHelper.assertUndeliverable(errors, 0, TestException.class);
            }
        } finally {
            RxJavaPlugins.reset();
        }
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 84 with TestException

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

the class SingleDoAfterSuccessTest method consumerThrows.

@Test
public void consumerThrows() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Single.just(1).doAfterSuccess(new Consumer<Integer>() {

            @Override
            public void accept(Integer e) throws Exception {
                throw new TestException();
            }
        }).test().assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 85 with TestException

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

the class SingleDoOnTerminateTest method doOnTerminateErrorCrash.

@Test
public void doOnTerminateErrorCrash() {
    TestObserverEx<Object> to = Single.error(new TestException("Outer")).doOnTerminate(new Action() {

        @Override
        public void run() {
            throw new TestException("Inner");
        }
    }).to(TestHelper.testConsumer()).assertFailure(CompositeException.class);
    List<Throwable> errors = TestHelper.compositeList(to.errors().get(0));
    TestHelper.assertError(errors, 0, TestException.class, "Outer");
    TestHelper.assertError(errors, 1, TestException.class, "Inner");
}
Also used : Action(io.reactivex.rxjava3.functions.Action) 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