Search in sources :

Example 21 with TestException

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

the class DeferredScalarObserverTest method fusedError.

@Test
public void fusedError() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
        TakeLast source = new TakeLast(to);
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        source.onNext(1);
        source.onError(new TestException());
        source.onError(new TestException("second"));
        source.onComplete();
        to.assertFailure(TestException.class);
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 22 with TestException

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

the class DeferredScalarObserverTest method fused.

@Test
public void fused() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
        TakeFirst source = new TakeFirst(to);
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        to.assertFuseable();
        to.assertFusionMode(QueueFuseable.ASYNC);
        source.onNext(1);
        source.onNext(1);
        source.onError(new TestException());
        source.onComplete();
        assertTrue(d.isDisposed());
        to.assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 23 with TestException

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

the class DeferredScalarObserverTest method fusedReject.

@Test
public void fusedReject() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.SYNC);
        TakeFirst source = new TakeFirst(to);
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        to.assertFuseable();
        to.assertFusionMode(QueueFuseable.NONE);
        source.onNext(1);
        source.onNext(1);
        source.onError(new TestException());
        source.onComplete();
        assertTrue(d.isDisposed());
        to.assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 24 with TestException

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

the class MaybeFlattenStreamAsObservableTest method nextThrowsInDrain.

@Test
public void nextThrowsInDrain() {
    @SuppressWarnings("unchecked") Stream<Integer> stream = mock(Stream.class);
    when(stream.iterator()).thenReturn(new Iterator<Integer>() {

        @Override
        public boolean hasNext() {
            return true;
        }

        @Override
        public Integer next() {
            throw new TestException();
        }
    });
    Maybe.just(1).flattenStreamAsObservable(v -> stream).test().assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 25 with TestException

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

the class MaybeFlattenStreamAsObservableTest method streamCloseCrash.

@Test
public void streamCloseCrash() throws Throwable {
    TestHelper.withErrorTracking(errors -> {
        Maybe.just(1).flattenStreamAsObservable(v -> Stream.of(v).onClose(() -> {
            throw new TestException();
        })).test().assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    });
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)656 Test (org.junit.Test)555 IOException (java.io.IOException)95 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)90 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)81 Disposable (io.reactivex.rxjava3.disposables.Disposable)56 InOrder (org.mockito.InOrder)54 TestObserver (io.reactivex.rxjava3.observers.TestObserver)47 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)47 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)40 Observable (io.reactivex.rxjava3.core.Observable)38 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)20 Action (io.reactivex.rxjava3.functions.Action)20 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)20 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)18 Observer (io.reactivex.rxjava3.core.Observer)15 TestHelper (io.reactivex.rxjava3.testsupport.TestHelper)15 Assert (org.junit.Assert)15 java.util (java.util)13 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)12