Search in sources :

Example 16 with TestException

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

the class XFlatMapTest method flowableCompletable.

@Test
public void flowableCompletable() throws Exception {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserver<Void> ts = Flowable.just(1).subscribeOn(Schedulers.io()).flatMapCompletable(new Function<Integer, Completable>() {

            @Override
            public Completable apply(Integer v) throws Exception {
                sleep();
                return Completable.error(new TestException());
            }
        }).test();
        cb.await();
        Thread.sleep(50);
        ts.cancel();
        Thread.sleep(SLEEP_AFTER_CANCEL);
        ts.assertEmpty();
        assertTrue(errors.toString(), errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 17 with TestException

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

the class ObserverFullArbiterTest method errorAfterCancel.

@Test
public void errorAfterCancel() {
    ObserverFullArbiter<Integer> fa = new ObserverFullArbiter<Integer>(new TestObserver<Integer>(), null, 128);
    Disposable bs = Disposables.empty();
    fa.dispose();
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        fa.onError(new TestException(), bs);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : ObserverFullArbiter(io.reactivex.internal.disposables.ObserverFullArbiter) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 18 with TestException

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

the class DeferredScalarObserverTest method fusedTerminateMore.

@Test
public void fusedTerminateMore() {
    TestObserver<Integer> to = ObserverFusion.newTest(QueueDisposable.ANY);
    TakeLast source = new TakeLast(to);
    Disposable d = Disposables.empty();
    source.onSubscribe(d);
    source.onNext(1);
    source.onComplete();
    source.onComplete();
    source.onError(new TestException());
    to.assertResult(1);
}
Also used : QueueDisposable(io.reactivex.internal.fuseable.QueueDisposable) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 19 with TestException

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

the class DeferredScalarObserverTest method nonfusedError.

@Test
public void nonfusedError() {
    TestObserver<Integer> to = ObserverFusion.newTest(QueueDisposable.NONE);
    TakeLast source = new TakeLast(to);
    Disposable d = Disposables.empty();
    source.onSubscribe(d);
    source.onNext(1);
    source.onError(new TestException());
    source.onError(new TestException());
    source.onComplete();
    to.assertFailure(TestException.class);
}
Also used : QueueDisposable(io.reactivex.internal.fuseable.QueueDisposable) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 20 with TestException

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

the class DeferredScalarObserverTest method fusedError.

@Test
public void fusedError() {
    TestObserver<Integer> to = ObserverFusion.newTest(QueueDisposable.ANY);
    TakeLast source = new TakeLast(to);
    Disposable d = Disposables.empty();
    source.onSubscribe(d);
    source.onNext(1);
    source.onError(new TestException());
    source.onError(new TestException());
    source.onComplete();
    to.assertFailure(TestException.class);
}
Also used : QueueDisposable(io.reactivex.internal.fuseable.QueueDisposable) 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