@Test
public void connectConsumerThrows() {

    ConnectableFlowable<Integer> cf = Flowable.range(1, 2)
    .replay();
    try {
        cf.connect(new Consumer<Disposable>() {
            @Override
            public void accept(Disposable t) throws Exception {
                throw new TestException();
            }
        });
        fail("Should have thrown");
    } catch (TestException ex) {
        // expected
    }
    cf.test().assertEmpty().cancel();
    cf.connect();
    cf.test().assertResult(1, 2);
}