@Test(expected = IOException.class) public void testOpenChannelSyncFailure() throws Exception { this.eventLoopGroup = new NioEventLoopGroup(1); final Bootstrap bootstrap = PowerMockito.mock(Bootstrap.class); PowerMockito.when(bootstrap.group()).thenReturn(eventLoopGroup); final Exception exception = new RuntimeException("Testing purposes!"); try (final NettyNetworkManager networkManager = new NettyNetworkManager(bootstrap)) { when(bootstrap.clone()).thenReturn(bootstrap); when(bootstrap.register()).thenThrow(exception); networkManager.openChannel(); } }
@Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } }
NettyNetworkManager implements SynchronousNetworkManager<Channel>, AsynchronousNetworkManager<Channel> { @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } } }
NettyNetworkManager implements SynchronousNetworkManager<Channel>, AsynchronousNetworkManager<Channel> { @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } } NettyNetworkManager();  NettyNetworkManager(int threadCount);  NettyNetworkManager(Bootstrap bootstrap); }
NettyNetworkManager implements SynchronousNetworkManager<Channel>, AsynchronousNetworkManager<Channel> { @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } } NettyNetworkManager();  NettyNetworkManager(int threadCount);  NettyNetworkManager(Bootstrap bootstrap); @Override Channel openChannel(); @Override void openChannel(FutureCallback<Channel> callback); @Override void close(); @Override void close(FutureCallback<Void> callback); }
NettyNetworkManager implements SynchronousNetworkManager<Channel>, AsynchronousNetworkManager<Channel> { @Override public Channel openChannel() throws IOException, IllegalStateException { assertOpen(); try { return this.bootstrap.clone().register().sync().channel(); } catch (Exception e) { throw new IOException("Could not open channel.", e); } } NettyNetworkManager();  NettyNetworkManager(int threadCount);  NettyNetworkManager(Bootstrap bootstrap); @Override Channel openChannel(); @Override void openChannel(FutureCallback<Channel> callback); @Override void close(); @Override void close(FutureCallback<Void> callback);  }