@Test
public void testConnectWithNoSubscriber() {

    TestScheduler scheduler = new TestScheduler();
    ConnectableObservable<Long> co = Observable.timer(10, 10, TimeUnit.MILLISECONDS, scheduler).take(3).publish();
    co.connect();
    // Emit 0
    scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS);
    TestSubscriber subscriber = new TestSubscriber<Long>();
    co.subscribe(subscriber);
    // Emit 1 and 2
    scheduler.advanceTimeBy(50, TimeUnit.MILLISECONDS);
    subscriber.assertReceivedOnNext(Arrays.asList(1L, 2L));
    subscriber.assertNoErrors();
    subscriber.assertTerminalEvent();
}