@Test
public void testChannelFactoryFailureNotifiesPromise() throws Exception {

    final RuntimeException exception = new RuntimeException("newChannel crash");
    final Bootstrap bootstrap = new Bootstrap()
            .handler(dummyHandler)
            .group(groupA)
            .channelFactory(new ChannelFactory<Channel>() {
        @Override
        public Channel newChannel() {
            throw exception;
        }
    });
    ChannelFuture connectFuture = bootstrap.connect(LocalAddress.ANY);
    // Should fail with the RuntimeException.
    assertThat(connectFuture.await(10000), is(true));
    assertThat(connectFuture.cause(), sameInstance((Throwable) exception));
    assertThat(connectFuture.channel(), is(nullValue()));
}