Search in sources :

Example 91 with BooleanSubscription

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

the class SubscriberResourceWrapperTest method error.

@Test
public void error() {
    BooleanSubscription bs = new BooleanSubscription();
    Disposable d = Disposable.empty();
    s.setResource(d);
    s.onSubscribe(bs);
    s.onError(new TestException());
    assertTrue(d.isDisposed());
    assertFalse(bs.isCancelled());
    ts.assertFailure(TestException.class);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 92 with BooleanSubscription

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

the class SubscriberResourceWrapperTest method complete.

@Test
public void complete() {
    BooleanSubscription bs = new BooleanSubscription();
    Disposable d = Disposable.empty();
    s.setResource(d);
    s.onSubscribe(bs);
    s.onComplete();
    assertTrue(d.isDisposed());
    assertFalse(bs.isCancelled());
    ts.assertResult();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 93 with BooleanSubscription

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

the class QueueDrainHelperTest method postCompleteWithRequest.

@Test
public void postCompleteWithRequest() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ArrayDeque<Integer> queue = new ArrayDeque<>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {

        @Override
        public boolean getAsBoolean() throws Exception {
            return false;
        }
    };
    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();
    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
    ts.assertResult(1);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) BooleanSupplier(io.reactivex.rxjava3.functions.BooleanSupplier) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 94 with BooleanSubscription

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

the class QueueDrainHelperTest method completeRequestRace.

@Test
public void completeRequestRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        final TestSubscriber<Integer> ts = new TestSubscriber<>();
        final ArrayDeque<Integer> queue = new ArrayDeque<>();
        final AtomicLong state = new AtomicLong();
        final BooleanSupplier isCancelled = new BooleanSupplier() {

            @Override
            public boolean getAsBoolean() throws Exception {
                return false;
            }
        };
        ts.onSubscribe(new BooleanSubscription());
        queue.offer(1);
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                QueueDrainHelper.postCompleteRequest(1, ts, queue, state, isCancelled);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
            }
        };
        TestHelper.race(r1, r2);
        ts.assertResult(1);
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) BooleanSupplier(io.reactivex.rxjava3.functions.BooleanSupplier) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 95 with BooleanSubscription

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

the class QueueDrainHelperTest method checkTerminatedNonDelayErrorError.

@Test
public void checkTerminatedNonDelayErrorError() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ts.onSubscribe(new BooleanSubscription());
    QueueDrain<Integer, Integer> qd = new QueueDrain<Integer, Integer>() {

        @Override
        public boolean cancelled() {
            return false;
        }

        @Override
        public boolean done() {
            return false;
        }

        @Override
        public Throwable error() {
            return new TestException();
        }

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

        @Override
        public long requested() {
            return 0;
        }

        @Override
        public long produced(long n) {
            return 0;
        }

        @Override
        public int leave(int m) {
            return 0;
        }

        @Override
        public boolean accept(Subscriber<? super Integer> a, Integer v) {
            return false;
        }
    };
    SpscArrayQueue<Integer> q = new SpscArrayQueue<>(32);
    QueueDrainHelper.checkTerminated(true, false, ts, false, q, qd);
    ts.assertFailure(TestException.class);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) SpscArrayQueue(io.reactivex.rxjava3.operators.SpscArrayQueue) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) 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