@Test
public void connectThrows() {

    ConnectableFlowable<Integer> cf = Flowable.<Integer>empty().publish();
    try {
        cf.connect(new Consumer<Disposable>() {
            @Override
            public void accept(Disposable s) throws Exception {
                throw new TestException();
            }
        });
    } catch (TestException ex) {
        // expected
    }
}