Search in sources :

Example 6 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class FlowableTakeUntilTest method untilPublisherOtherError.

@Test
public void untilPublisherOtherError() {
    PublishProcessor<Integer> main = PublishProcessor.create();
    PublishProcessor<Integer> other = PublishProcessor.create();
    TestSubscriber<Integer> ts = main.takeUntil(other).test();
    assertTrue("Main no subscribers?", main.hasSubscribers());
    assertTrue("Other no subscribers?", other.hasSubscribers());
    other.onError(new TestException());
    assertFalse("Main has subscribers?", main.hasSubscribers());
    assertFalse("Other has subscribers?", other.hasSubscribers());
    ts.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 7 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowSlowpathDelayError.

@Test
public void overflowSlowpathDelayError() {
    @SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {

        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            if (t == 1) {
                subs[0].onNext(2);
                subs[0].onNext(3);
            }
        }
    };
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subs[0] = subscribers[0];
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequentialDelayError(1).subscribe(ts);
    ts.request(1);
    ts.assertFailure(MissingBackpressureException.class, 1, 2);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Subscriber(org.reactivestreams.Subscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 8 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowSlowpath.

@Test
public void overflowSlowpath() {
    @SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {

        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            subs[0].onNext(2);
            subs[0].onNext(3);
        }
    };
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subs[0] = subscribers[0];
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequential(1).subscribe(ts);
    ts.assertFailure(MissingBackpressureException.class, 1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Subscriber(org.reactivestreams.Subscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 9 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowFastpathDelayError.

@Test
public void overflowFastpathDelayError() {
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
            subscribers[0].onNext(2);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequentialDelayError(1).test(0).requestMore(1).assertFailure(MissingBackpressureException.class, 1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 10 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class ConnectableFlowable method connect.

/**
 * Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying
 * {@link Flowable} to its {@link Subscriber}s.
 * <p>
 * To disconnect from a synchronous source, use the {@link #connect(io.reactivex.rxjava3.functions.Consumer)} method.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>The behavior is determined by the implementor of this abstract class.</dd>
 * </dl>
 *
 * @return the subscription representing the connection
 * @see <a href="http://reactivex.io/documentation/operators/connect.html">ReactiveX documentation: Connect</a>
 */
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable connect() {
    ConnectConsumer cc = new ConnectConsumer();
    connect(cc);
    return cc.disposable;
}
Also used : ConnectConsumer(io.reactivex.rxjava3.internal.util.ConnectConsumer)

Aggregations

Test (org.junit.Test)19 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 TestException (io.reactivex.rxjava3.exceptions.TestException)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)4 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)3 TestObserver (io.reactivex.rxjava3.observers.TestObserver)3 Disposable (io.reactivex.rxjava3.disposables.Disposable)2 Pattern (java.util.regex.Pattern)2 Subscriber (org.reactivestreams.Subscriber)2 SchedulerMultiWorkerSupport (io.reactivex.rxjava3.internal.schedulers.SchedulerMultiWorkerSupport)1 ConnectConsumer (io.reactivex.rxjava3.internal.util.ConnectConsumer)1 ConditionalSubscriber (io.reactivex.rxjava3.operators.ConditionalSubscriber)1 InOrder (org.mockito.InOrder)1