Search in sources :

Example 1 with ScalarSubscription

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

the class RxJavaPluginsTest method overrideConnectableFlowable.

@SuppressWarnings("rawtypes")
@Test
public void overrideConnectableFlowable() {
    try {
        RxJavaPlugins.setOnConnectableFlowableAssembly(new Function<ConnectableFlowable, ConnectableFlowable>() {

            @Override
            public ConnectableFlowable apply(ConnectableFlowable co) throws Exception {
                return new ConnectableFlowable() {

                    @Override
                    public void connect(Consumer connection) {
                    }

                    @Override
                    public void reset() {
                    // nothing to do in this test
                    }

                    @SuppressWarnings("unchecked")
                    @Override
                    protected void subscribeActual(Subscriber subscriber) {
                        subscriber.onSubscribe(new ScalarSubscription(subscriber, 10));
                    }
                };
            }
        });
        Flowable.just(1).publish().autoConnect().test().assertResult(10);
    } finally {
        RxJavaPlugins.reset();
    }
    Flowable.just(1).publish().autoConnect().test().assertResult(1);
}
Also used : ConnectableFlowable(io.reactivex.rxjava3.flowables.ConnectableFlowable) ScalarSubscription(io.reactivex.rxjava3.internal.subscriptions.ScalarSubscription) Test(org.junit.Test)

Aggregations

ConnectableFlowable (io.reactivex.rxjava3.flowables.ConnectableFlowable)1 ScalarSubscription (io.reactivex.rxjava3.internal.subscriptions.ScalarSubscription)1 Test (org.junit.Test)1