Search in sources :

Example 11 with CompositeException

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

the class FlowableConcatMapCompletableTest method immediateOuterInnerErrorRace.

@Test
public void immediateOuterInnerErrorRace() {
    final TestException ex = new TestException();
    for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            final PublishProcessor<Integer> pp = PublishProcessor.create();
            final CompletableSubject cs = CompletableSubject.create();
            TestObserver<Void> to = pp.concatMapCompletable(Functions.justFunction(cs)).test();
            pp.onNext(1);
            Runnable r1 = new Runnable() {

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

                @Override
                public void run() {
                    cs.onError(ex);
                }
            };
            TestHelper.race(r1, r2);
            to.assertError(new Predicate<Throwable>() {

                @Override
                public boolean test(Throwable e) throws Exception {
                    return e instanceof TestException || e instanceof CompositeException;
                }
            }).assertNotComplete();
            if (!errors.isEmpty()) {
                TestHelper.assertUndeliverable(errors, 0, TestException.class);
            }
        } finally {
            RxJavaPlugins.reset();
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 CompositeException (io.reactivex.rxjava3.exceptions.CompositeException)4 Disposable (io.reactivex.rxjava3.disposables.Disposable)3 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)3 IOException (java.io.IOException)3 InOrder (org.mockito.InOrder)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)1 AtomicThrowable (io.reactivex.rxjava3.internal.util.AtomicThrowable)1