Search in sources :

Example 71 with BooleanSubscription

use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class ParallelMapTest method conditionalCancelIgnored.

@Test
public void conditionalCancelIgnored() {
    Flowable<Integer> f = new Flowable<Integer>() {

        @Override
        protected void subscribeActual(@NonNull Subscriber<@NonNull ? super @NonNull Integer> s) {
            @SuppressWarnings("unchecked") ConditionalSubscriber<Integer> subscriber = (ConditionalSubscriber<Integer>) s;
            subscriber.onSubscribe(new BooleanSubscription());
            subscriber.tryOnNext(1);
            subscriber.tryOnNext(2);
        }
    };
    ParallelFlowable.fromArray(f).map(v -> {
        throw new TestException();
    }).filter(v -> true).sequential().test().assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) io.reactivex.rxjava3.functions(io.reactivex.rxjava3.functions) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Test(org.junit.Test) NonNull(io.reactivex.rxjava3.annotations.NonNull) TimeUnit(java.util.concurrent.TimeUnit) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) List(java.util.List) TestHelper(io.reactivex.rxjava3.testsupport.TestHelper) Functions(io.reactivex.rxjava3.internal.functions.Functions) io.reactivex.rxjava3.core(io.reactivex.rxjava3.core) Assert(org.junit.Assert) Subscriber(org.reactivestreams.Subscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) RxJavaPlugins(io.reactivex.rxjava3.plugins.RxJavaPlugins) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Subscriber(org.reactivestreams.Subscriber) NonNull(io.reactivex.rxjava3.annotations.NonNull) ConditionalSubscriber(io.reactivex.rxjava3.operators.ConditionalSubscriber) Test(org.junit.Test)

Example 72 with BooleanSubscription

use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class FlowableConcatMapSingleTest method cancelNoConcurrentClean.

@Test
public void cancelNoConcurrentClean() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ConcatMapSingleSubscriber<Integer, Integer> operator = new ConcatMapSingleSubscriber<>(ts, Functions.justFunction(Single.<Integer>never()), 16, ErrorMode.IMMEDIATE);
    operator.onSubscribe(new BooleanSubscription());
    operator.queue.offer(1);
    operator.getAndIncrement();
    ts.cancel();
    assertFalse(operator.queue.isEmpty());
    operator.addAndGet(-2);
    operator.cancel();
    assertTrue(operator.queue.isEmpty());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) ConcatMapSingleSubscriber(io.reactivex.rxjava3.internal.operators.mixed.FlowableConcatMapSingle.ConcatMapSingleSubscriber) Test(org.junit.Test)

Example 73 with BooleanSubscription

use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class FlowableConcatMapMaybeTest method cancelNoConcurrentClean.

@Test
public void cancelNoConcurrentClean() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ConcatMapMaybeSubscriber<Integer, Integer> operator = new ConcatMapMaybeSubscriber<>(ts, Functions.justFunction(Maybe.<Integer>never()), 16, ErrorMode.IMMEDIATE);
    operator.onSubscribe(new BooleanSubscription());
    operator.queue.offer(1);
    operator.getAndIncrement();
    ts.cancel();
    assertFalse(operator.queue.isEmpty());
    operator.addAndGet(-2);
    operator.cancel();
    assertTrue(operator.queue.isEmpty());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) ConcatMapMaybeSubscriber(io.reactivex.rxjava3.internal.operators.mixed.FlowableConcatMapMaybe.ConcatMapMaybeSubscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 74 with BooleanSubscription

use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class HalfSerializerSubscriberTest method reentrantOnNextOnComplete.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnComplete() {
    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.onComplete(a[0], 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.assertResult(1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) 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)

Example 75 with BooleanSubscription

use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class HalfSerializerSubscriberTest method reentrantErrorOnError.

@Test
@SuppressUndeliverable
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantErrorOnError() {
    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) {
            ts.onNext(t);
        }

        @Override
        public void onError(Throwable t) {
            ts.onError(t);
            HalfSerializer.onError(a[0], new IOException(), wip, error);
        }

        @Override
        public void onComplete() {
            ts.onComplete();
        }
    };
    a[0] = s;
    s.onSubscribe(new BooleanSubscription());
    HalfSerializer.onError(s, new TestException(), wip, error);
    ts.assertFailure(TestException.class);
}
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) IOException(java.io.IOException) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Aggregations

BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)227 Test (org.junit.Test)152 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)81 TestException (io.reactivex.rxjava3.exceptions.TestException)40 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)32 IOException (java.io.IOException)26 InOrder (org.mockito.InOrder)19 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)12 Subscriber (org.reactivestreams.Subscriber)11 io.reactivex.rxjava3.testsupport (io.reactivex.rxjava3.testsupport)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 Assert (org.junit.Assert)10 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 io.reactivex.rxjava3.functions (io.reactivex.rxjava3.functions)8 Functions (io.reactivex.rxjava3.internal.functions.Functions)8 ConditionalSubscriber (io.reactivex.rxjava3.operators.ConditionalSubscriber)8 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)8 io.reactivex.rxjava3.processors (io.reactivex.rxjava3.processors)8 java.util (java.util)8