Search in sources :

Example 66 with TestException

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

the class FlowableTimeoutWithSelectorTest method testTimeoutSelectorSubsequentFlowableThrows.

@Test
public void testTimeoutSelectorSubsequentFlowableThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final PublishProcessor<Integer> timeout = PublishProcessor.create();
    Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return Flowable.<Integer>error(new TestException());
        }
    };
    Flowable<Integer> other = Flowable.fromIterable(Arrays.asList(100));
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.timeout(timeout, timeoutFunc, other).subscribe(o);
    source.onNext(1);
    inOrder.verify(o).onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
}
Also used : Function(io.reactivex.functions.Function) InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 67 with TestException

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

the class FlowableTimeoutWithSelectorTest method testTimeoutSelectorSubsequentThrows.

@Test
public void testTimeoutSelectorSubsequentThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final PublishProcessor<Integer> timeout = PublishProcessor.create();
    Function<Integer, Flowable<Integer>> timeoutFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            throw new TestException();
        }
    };
    Flowable<Integer> other = Flowable.fromIterable(Arrays.asList(100));
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);
    source.timeout(timeout, timeoutFunc, other).subscribe(o);
    source.onNext(1);
    inOrder.verify(o).onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
}
Also used : Function(io.reactivex.functions.Function) InOrder(org.mockito.InOrder) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 68 with TestException

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

the class FlowableSkipLastTimedTest method testSkipLastTimedErrorBeforeTime.

@Test
public void testSkipLastTimedErrorBeforeTime() {
    TestScheduler scheduler = new TestScheduler();
    PublishProcessor<Integer> source = PublishProcessor.create();
    Flowable<Integer> result = source.skipLast(1, TimeUnit.SECONDS, scheduler);
    Subscriber<Object> o = TestHelper.mockSubscriber();
    result.subscribe(o);
    source.onNext(1);
    source.onNext(2);
    source.onNext(3);
    source.onError(new TestException());
    scheduler.advanceTimeBy(1050, TimeUnit.MILLISECONDS);
    verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
    verify(o, never()).onNext(any());
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 69 with TestException

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

the class FlowableWithLatestFromTest method withMainError.

@Test
public void withMainError() {
    TestSubscriber<String> ts = new TestSubscriber<String>(0);
    Flowable.error(new TestException()).withLatestFrom(new Flowable<?>[] { Flowable.just(1), Flowable.just(1) }, toArray).subscribe(ts);
    ts.assertNoValues();
    ts.assertError(TestException.class);
    ts.assertNotComplete();
}
Also used : TestException(io.reactivex.exceptions.TestException) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Example 70 with TestException

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

the class FlowableZipIterableTest method testZipIterableIteratorThrows.

@Test
public void testZipIterableIteratorThrows() {
    PublishProcessor<String> r1 = PublishProcessor.create();
    /* define a Subscriber to receive aggregated events */
    Subscriber<String> o = TestHelper.mockSubscriber();
    InOrder io = inOrder(o);
    Iterable<String> r2 = new Iterable<String>() {

        @Override
        public Iterator<String> iterator() {
            throw new TestException();
        }
    };
    r1.zipWith(r2, zipr2).subscribe(o);
    r1.onNext("one-");
    r1.onNext("two-");
    r1.onError(new TestException());
    io.verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
    verify(o, never()).onNext(any(String.class));
}
Also used : InOrder(org.mockito.InOrder) CrashingIterable(io.reactivex.internal.util.CrashingIterable) 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