Search in sources :

Example 31 with TestException

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

the class FlowableBufferTest method bufferTimedExactBoundedError.

@SuppressWarnings("unchecked")
@Test
public void bufferTimedExactBoundedError() {
    TestScheduler scheduler = new TestScheduler();
    PublishProcessor<Integer> ps = PublishProcessor.create();
    TestSubscriber<List<Integer>> to = ps.buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, Functions.<Integer>createArrayList(16), true).test();
    ps.onError(new TestException());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 32 with TestException

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

the class FlowableBufferTest method bufferWithBOSourceThrows.

@Test
public void bufferWithBOSourceThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    PublishProcessor<Integer> boundary = PublishProcessor.create();
    Subscriber<Object> o = TestHelper.mockSubscriber();
    source.buffer(boundary).subscribe(o);
    source.onNext(1);
    source.onError(new TestException());
    verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
    verify(o, never()).onNext(any());
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 33 with TestException

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

the class FlowableBufferTest method bufferWithStartEndEndThrows.

@Test
public void bufferWithStartEndEndThrows() {
    PublishProcessor<Integer> start = PublishProcessor.create();
    Function<Integer, Flowable<Integer>> end = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return Flowable.error(new TestException());
        }
    };
    PublishProcessor<Integer> source = PublishProcessor.create();
    Flowable<List<Integer>> result = source.buffer(start, end);
    Subscriber<Object> o = TestHelper.mockSubscriber();
    result.subscribe(o);
    start.onNext(1);
    source.onNext(1);
    source.onNext(2);
    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
    verify(o).onError(any(TestException.class));
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 34 with TestException

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

the class FlowableBufferTest method bufferWithBOBoundaryThrows.

@Test
public void bufferWithBOBoundaryThrows() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    PublishProcessor<Integer> boundary = PublishProcessor.create();
    Subscriber<Object> o = TestHelper.mockSubscriber();
    source.buffer(boundary).subscribe(o);
    source.onNext(1);
    boundary.onError(new TestException());
    verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();
    verify(o, never()).onNext(any());
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 35 with TestException

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

the class CompletableCreateTest method onErrorThrows2.

@Test
public void onErrorThrows2() {
    Completable.create(new CompletableOnSubscribe() {

        @Override
        public void subscribe(CompletableEmitter e) throws Exception {
            try {
                e.onError(new IOException());
                fail("Should have thrown");
            } catch (TestException ex) {
            // expected
            }
            assertTrue(e.isDisposed());
        }
    }).subscribe(new CompletableObserver() {

        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onError(Throwable e) {
            throw new TestException();
        }

        @Override
        public void onComplete() {
        }
    });
}
Also used : TestException(io.reactivex.exceptions.TestException) IOException(java.io.IOException) 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