Search in sources :

Example 46 with TestException

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

the class BlockingFlowableLatestTest method onError.

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

Example 47 with TestException

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

the class FlowableDematerializeTest method eventsAfterDematerializedTerminal.

@Test
public void eventsAfterDematerializedTerminal() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        new Flowable<Object>() {

            @Override
            protected void subscribeActual(Subscriber<? super Object> observer) {
                observer.onSubscribe(new BooleanSubscription());
                observer.onNext(Notification.createOnComplete());
                observer.onNext(Notification.createOnNext(1));
                observer.onNext(Notification.createOnError(new TestException("First")));
                observer.onError(new TestException("Second"));
            }
        }.dematerialize().test().assertResult();
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
        TestHelper.assertUndeliverable(errors, 1, TestException.class, "Second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 48 with TestException

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

the class FlowableOnErrorResumeNextViaFlowableTest method normalBackpressure.

@Test
public void normalBackpressure() {
    TestSubscriber<Integer> ts = TestSubscriber.create(0);
    PublishProcessor<Integer> ps = PublishProcessor.create();
    ps.onErrorResumeNext(Flowable.range(3, 2)).subscribe(ts);
    ts.request(2);
    ps.onNext(1);
    ps.onNext(2);
    ps.onError(new TestException("Forced failure"));
    ts.assertValues(1, 2);
    ts.assertNoErrors();
    ts.assertNotComplete();
    ts.request(2);
    ts.assertValues(1, 2, 3, 4);
    ts.assertNoErrors();
    ts.assertComplete();
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 49 with TestException

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

the class FlowableOnErrorResumeNextViaFunctionTest method normalBackpressure.

@Test
public void normalBackpressure() {
    TestSubscriber<Integer> ts = TestSubscriber.create(0);
    PublishProcessor<Integer> ps = PublishProcessor.create();
    ps.onErrorResumeNext(new Function<Throwable, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Throwable v) {
            return Flowable.range(3, 2);
        }
    }).subscribe(ts);
    ts.request(2);
    ps.onNext(1);
    ps.onNext(2);
    ps.onError(new TestException("Forced failure"));
    ts.assertValues(1, 2);
    ts.assertNoErrors();
    ts.assertNotComplete();
    ts.request(2);
    ts.assertValues(1, 2, 3, 4);
    ts.assertNoErrors();
    ts.assertComplete();
}
Also used : Function(io.reactivex.functions.Function) TestException(io.reactivex.exceptions.TestException)

Example 50 with TestException

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

the class FlowableOnErrorReturnTest method normalBackpressure.

@Test
public void normalBackpressure() {
    TestSubscriber<Integer> ts = TestSubscriber.create(0);
    PublishProcessor<Integer> ps = PublishProcessor.create();
    ps.onErrorReturn(new Function<Throwable, Integer>() {

        @Override
        public Integer apply(Throwable e) {
            return 3;
        }
    }).subscribe(ts);
    ts.request(2);
    ps.onNext(1);
    ps.onNext(2);
    ps.onError(new TestException("Forced failure"));
    ts.assertValues(1, 2);
    ts.assertNoErrors();
    ts.assertNotComplete();
    ts.request(2);
    ts.assertValues(1, 2, 3);
    ts.assertNoErrors();
    ts.assertComplete();
}
Also used : Function(io.reactivex.functions.Function) 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