Search in sources :

Example 91 with TestException

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

the class MaybeDoAfterSuccessTest method errorConditional.

@Test
public void errorConditional() {
    Maybe.<Integer>error(new TestException()).doAfterSuccess(afterSuccess).filter(Functions.alwaysTrue()).subscribeWith(ts).assertFailure(TestException.class);
    assertTrue(values.isEmpty());
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 92 with TestException

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

the class MaybeDoFinallyTest method actionThrowsConditional.

@Test
public void actionThrowsConditional() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Maybe.just(1).doFinally(new Action() {

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

Example 93 with TestException

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

the class MaybeMergeArrayTest method errorRace.

@SuppressWarnings("unchecked")
@Test
public void errorRace() {
    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();
            TestSubscriber<Integer> ts = Maybe.mergeArray(ps1.singleElement(), ps2.singleElement()).test();
            final TestException ex = new TestException();
            Runnable r1 = new Runnable() {

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

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

Example 94 with TestException

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

the class MaybeMergeArrayTest method errorFused.

@SuppressWarnings("unchecked")
@Test
public void errorFused() {
    TestSubscriber<Integer> ts = SubscriberFusion.newTest(QueueSubscription.ANY);
    Maybe.mergeArray(Maybe.<Integer>error(new TestException()), Maybe.just(2)).subscribe(ts);
    ts.assertOf(SubscriberFusion.<Integer>assertFuseable()).assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueSubscription.ASYNC)).assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 95 with TestException

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

the class MaybeOfTypeTest method errorNotInstance.

@Test
public void errorNotInstance() {
    TestObserver<String> ts = Maybe.<Integer>error(new TestException()).ofType(String.class).test();
    // don't make this fluent, target type required!
    ts.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

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