@Test
public void testConnectWithNoSubscriber() {

    TestScheduler scheduler = new TestScheduler();
    ConnectableFlowable<Long> cf = Flowable.interval(10, 10, TimeUnit.MILLISECONDS, scheduler).take(3).publish();
    cf.connect();
    // Emit 0
    scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS);
    TestSubscriber<Long> subscriber = new TestSubscriber<Long>();
    cf.subscribe(subscriber);
    // Emit 1 and 2
    scheduler.advanceTimeBy(50, TimeUnit.MILLISECONDS);
    subscriber.assertValues(1L, 2L);
    subscriber.assertNoErrors();
    subscriber.assertTerminated();
}