@Test
public void subscriberLiveSwap() {

    final ConnectableFlowable<Integer> cf = Flowable.range(1, 5).publish();
    final TestSubscriber<Integer> ts2 = new TestSubscriber<Integer>(0);
    TestSubscriber<Integer> ts1 = new TestSubscriber<Integer>() {
        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            cancel();
            onComplete();
            cf.subscribe(ts2);
        }
    };
    cf.subscribe(ts1);
    cf.connect();
    ts1.assertResult(1);
    ts2
    .assertEmpty()
    .requestMore(4)
    .assertResult(2, 3, 4, 5);
}