Search in sources :

Example 71 with TestException

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

the class ObservableConcatMapTest method onErrorRace.

@Test
public void onErrorRace() {
    for (int i = 0; i < 500; i++) {
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            final PublishSubject<Integer> ps1 = PublishSubject.create();
            final PublishSubject<Integer> ps2 = PublishSubject.create();
            TestObserver<Integer> to = ps1.concatMap(new Function<Integer, ObservableSource<Integer>>() {

                @Override
                public ObservableSource<Integer> apply(Integer v) throws Exception {
                    return ps2;
                }
            }).test();
            final TestException ex1 = new TestException();
            final TestException ex2 = new TestException();
            Runnable r1 = new Runnable() {

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

                @Override
                public void run() {
                    ps2.onError(ex2);
                }
            };
            TestHelper.race(r1, r2, Schedulers.single());
            to.assertFailure(TestException.class);
            if (!errors.isEmpty()) {
                TestHelper.assertError(errors, 0, TestException.class);
            }
        } finally {
            RxJavaPlugins.reset();
        }
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 72 with TestException

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

the class NotificationLiteTest method errorNotification.

@Test
public void errorNotification() {
    Object o = NotificationLite.error(new TestException());
    assertEquals("NotificationLite.Error[io.reactivex.exceptions.TestException]", o.toString());
    assertTrue(NotificationLite.isError(o));
    assertFalse(NotificationLite.isComplete(o));
    assertFalse(NotificationLite.isDisposable(o));
    assertFalse(NotificationLite.isSubscription(o));
    assertTrue(NotificationLite.getError(o) instanceof TestException);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 73 with TestException

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

the class BlockingObservableLatestTest method onError.

@SuppressWarnings("unchecked")
@Test
public void onError() {
    Iterator<Object> it = Observable.never().blockingLatest().iterator();
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        ((Observer<Object>) it).onError(new TestException());
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.exceptions.TestException) Observer(io.reactivex.Observer)

Example 74 with TestException

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

the class BlockingObservableNextTest method nextObserverError.

@Test
public void nextObserverError() {
    NextObserver<Integer> no = new NextObserver<Integer>();
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        no.onError(new TestException());
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : NextObserver(io.reactivex.internal.operators.observable.BlockingObservableNext.NextObserver) TestException(io.reactivex.exceptions.TestException)

Example 75 with TestException

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

the class BlockingObservableNextTest method testOnError.

@Test
public void testOnError() throws Throwable {
    Subject<String> obs = PublishSubject.create();
    Iterator<String> it = next(obs).iterator();
    obs.onError(new TestException());
    try {
        it.hasNext();
        fail("Expected an TestException");
    } catch (TestException e) {
    // successful
    }
    assertErrorAfterObservableFail(it);
}
Also used : TestException(io.reactivex.exceptions.TestException)

Aggregations

TestException (io.reactivex.exceptions.TestException)417 Test (org.junit.Test)255 InOrder (org.mockito.InOrder)35 IOException (java.io.IOException)28 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)26 TestObserver (io.reactivex.observers.TestObserver)26 Observable (io.reactivex.Observable)24 Function (io.reactivex.functions.Function)24 TestSubscriber (io.reactivex.subscribers.TestSubscriber)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)23 TestScheduler (io.reactivex.schedulers.TestScheduler)11 Observer (io.reactivex.Observer)8 QueueDisposable (io.reactivex.internal.fuseable.QueueDisposable)8 Disposable (io.reactivex.disposables.Disposable)7 CrashingIterable (io.reactivex.internal.util.CrashingIterable)6 Action (io.reactivex.functions.Action)5 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 ObserveOnObserver (io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver)2 ScalarDisposable (io.reactivex.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)2 FutureSubscriber (io.reactivex.internal.subscribers.FutureSubscriber)2