Search in sources :

Example 16 with BooleanSubscription

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

the class MulticastProcessorTest method refCounted2.

@Test
public void refCounted2() {
    MulticastProcessor<Integer> mp = MulticastProcessor.create(16, true);
    BooleanSubscription bs = new BooleanSubscription();
    mp.onSubscribe(bs);
    assertFalse(bs.isCancelled());
    mp.test(1, true);
    assertTrue(bs.isCancelled());
    assertFalse(mp.hasSubscribers());
    assertTrue(mp.hasComplete());
    assertFalse(mp.hasThrowable());
    assertNull(mp.getThrowable());
    mp.test().assertResult();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 17 with BooleanSubscription

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

the class MulticastProcessorTest method refCounted.

@Test
public void refCounted() {
    MulticastProcessor<Integer> mp = MulticastProcessor.create(true);
    BooleanSubscription bs = new BooleanSubscription();
    mp.onSubscribe(bs);
    assertFalse(bs.isCancelled());
    mp.test().cancel();
    assertTrue(bs.isCancelled());
    assertFalse(mp.hasSubscribers());
    assertTrue(mp.hasComplete());
    assertFalse(mp.hasThrowable());
    assertNull(mp.getThrowable());
    mp.test().assertResult();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 18 with BooleanSubscription

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

the class FlowableObserveOnTest method asycFusedPollThrows.

@Test
public void asycFusedPollThrows() {
    new Flowable<Integer>() {

        @Override
        protected void subscribeActual(Subscriber<? super Integer> subscriber) {
            subscriber.onSubscribe(new BooleanSubscription());
            @SuppressWarnings("unchecked") BaseObserveOnSubscriber<Integer> oo = (BaseObserveOnSubscriber<Integer>) subscriber;
            oo.sourceMode = QueueFuseable.ASYNC;
            oo.requested.lazySet(1);
            oo.queue = new SimpleQueue<Integer>() {

                @Override
                public boolean offer(Integer value) {
                    return false;
                }

                @Override
                public boolean offer(Integer v1, Integer v2) {
                    return false;
                }

                @Nullable
                @Override
                public Integer poll() throws Exception {
                    throw new TestException();
                }

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

                @Override
                public void clear() {
                }
            };
            oo.clear();
            oo.trySchedule();
        }
    }.observeOn(Schedulers.single()).test(0L).awaitDone(5, TimeUnit.SECONDS).assertFailure(TestException.class);
}
Also used : BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) Nullable(io.reactivex.rxjava3.annotations.Nullable) Test(org.junit.Test)

Example 19 with BooleanSubscription

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

the class FlowableObserveOnTest method badSource.

@Test
public void badSource() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestScheduler scheduler = new TestScheduler();
        TestSubscriber<Integer> ts = new Flowable<Integer>() {

            @Override
            protected void subscribeActual(Subscriber<? super Integer> subscriber) {
                subscriber.onSubscribe(new BooleanSubscription());
                subscriber.onComplete();
                subscriber.onNext(1);
                subscriber.onError(new TestException());
                subscriber.onComplete();
            }
        }.observeOn(scheduler).test();
        scheduler.triggerActions();
        ts.assertResult();
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) BaseObserveOnSubscriber(io.reactivex.rxjava3.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber) Test(org.junit.Test)

Example 20 with BooleanSubscription

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

the class FlowableReplayEagerTruncateTest method badSource.

@Test
public void badSource() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        new Flowable<Integer>() {

            @Override
            protected void subscribeActual(Subscriber<? super Integer> subscriber) {
                subscriber.onSubscribe(new BooleanSubscription());
                subscriber.onError(new TestException("First"));
                subscriber.onNext(1);
                subscriber.onError(new TestException("Second"));
                subscriber.onComplete();
            }
        }.replay().autoConnect().to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
        TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) ConnectableFlowable(io.reactivex.rxjava3.flowables.ConnectableFlowable)

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