Search in sources :

Example 6 with TestException

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

the class FutureSingleObserverTest method onErrorCancelRace.

@Test
public void onErrorCancelRace() {
    for (int i = 0; i < 500; i++) {
        final PublishSubject<Integer> ps = PublishSubject.create();
        final Future<?> f = ps.single(-99).toFuture();
        final TestException ex = new TestException();
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                f.cancel(true);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                ps.onError(ex);
            }
        };
        TestHelper.race(r1, r2, Schedulers.single());
    }
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 7 with TestException

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

the class CompletableAwaitTest method blockingGetErrorTimeout.

@Test
public void blockingGetErrorTimeout() {
    TestException ex = new TestException();
    assertSame(ex, Completable.error(ex).blockingGet(1, TimeUnit.SECONDS));
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 8 with TestException

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

the class CompletableAwaitTest method blockingGetError.

@Test
public void blockingGetError() {
    TestException ex = new TestException();
    assertSame(ex, Completable.error(ex).blockingGet());
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 9 with TestException

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

the class TransformerTest method completableTransformerThrows.

@Test
public void completableTransformerThrows() {
    try {
        Completable.complete().compose(new CompletableTransformer() {

            @Override
            public Completable apply(Completable v) {
                throw new TestException("Forced failure");
            }
        });
        fail("Should have thrown!");
    } catch (TestException ex) {
        assertEquals("Forced failure", ex.getMessage());
    }
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 10 with TestException

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

the class TransformerTest method observableTransformerThrows.

@Test
public void observableTransformerThrows() {
    try {
        Observable.just(1).compose(new ObservableTransformer<Integer, Integer>() {

            @Override
            public Observable<Integer> apply(Observable<Integer> v) {
                throw new TestException("Forced failure");
            }
        });
        fail("Should have thrown!");
    } catch (TestException ex) {
        assertEquals("Forced failure", ex.getMessage());
    }
}
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