Search in sources :

Example 16 with AtomicThrowable

use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.

the class AtomicThrowableTest method tryTerminateAndReportHasError.

@Test
public void tryTerminateAndReportHasError() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        AtomicThrowable ex = new AtomicThrowable();
        ex.set(new TestException());
        ex.tryTerminateAndReport();
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
        assertEquals(1, errors.size());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 17 with AtomicThrowable

use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.

the class AtomicThrowableTest method tryAddThrowableOrReportNull.

@Test
public void tryAddThrowableOrReportNull() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        AtomicThrowable ex = new AtomicThrowable();
        ex.tryAddThrowableOrReport(new TestException());
        assertTrue("" + errors, errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 18 with AtomicThrowable

use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.

the class AtomicThrowableTest method tryTerminateConsumerSubscriberTerminated.

@Test
public void tryTerminateConsumerSubscriberTerminated() {
    TestSubscriber<Object> ts = new TestSubscriber<>();
    ts.onSubscribe(new BooleanSubscription());
    AtomicThrowable ex = new AtomicThrowable();
    ex.terminate();
    ex.tryTerminateConsumer(ts);
    ts.assertEmpty();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 19 with AtomicThrowable

use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.

the class AtomicThrowableTest method tryTerminateConsumerSubscriberNoError.

@Test
public void tryTerminateConsumerSubscriberNoError() {
    TestSubscriber<Object> ts = new TestSubscriber<>();
    ts.onSubscribe(new BooleanSubscription());
    AtomicThrowable ex = new AtomicThrowable();
    ex.tryTerminateConsumer(ts);
    ts.assertResult();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 20 with AtomicThrowable

use of io.reactivex.rxjava3.internal.util.AtomicThrowable in project RxJava by ReactiveX.

the class HalfSerializerSubscriberTest method reentrantOnNextOnError.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnError() {
    final AtomicInteger wip = new AtomicInteger();
    final AtomicThrowable error = new AtomicThrowable();
    final Subscriber[] a = { null };
    final TestSubscriber ts = new TestSubscriber();
    FlowableSubscriber s = new FlowableSubscriber() {

        @Override
        public void onSubscribe(Subscription s) {
            ts.onSubscribe(s);
        }

        @Override
        public void onNext(Object t) {
            if (t.equals(1)) {
                HalfSerializer.onError(a[0], new TestException(), wip, error);
            }
            ts.onNext(t);
        }

        @Override
        public void onError(Throwable t) {
            ts.onError(t);
        }

        @Override
        public void onComplete() {
            ts.onComplete();
        }
    };
    a[0] = s;
    s.onSubscribe(new BooleanSubscription());
    HalfSerializer.onNext(s, 1, wip, error);
    ts.assertFailure(TestException.class, 1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 TestException (io.reactivex.rxjava3.exceptions.TestException)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 TestObserver (io.reactivex.rxjava3.observers.TestObserver)10 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)9 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)8 AtomicThrowable (io.reactivex.rxjava3.internal.util.AtomicThrowable)2 IOException (java.io.IOException)2 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)1