### Question:
ConnectionManager { public void initAndRunWorker(ServerChannelRegister serverChannelRegister) throws IOException { boolean wasInit = alreadyInit.getAndSet(true); if (wasInit) { throw new IllegalStateException("connection manager was already initialized"); } myServerSocketChannel = serverChannelRegister.channelFor(selector); myServerSocketChannel.register(selector, SelectionKey.OP_ACCEPT, new AcceptAttachmentImpl(myContext)); myBindPort = myServerSocketChannel.socket().getLocalPort(); String serverName = myServerSocketChannel.socket().toString(); myConnectionWorker = new ConnectionWorker(selector, Arrays.asList( new InvalidKeyProcessor(), new AcceptableKeyProcessor(selector, serverName, myTimeService, myIncomingConnectionAllower, socketTimeoutStorage, mySendBufferSize, myReceiveBufferSize), new ConnectableKeyProcessor(selector, myTimeService, socketTimeoutStorage, mySendBufferSize, myReceiveBufferSize), new ReadableKeyProcessor(serverName), new WritableKeyProcessor()), DEFAULT_SELECTOR_SELECT_TIMEOUT_MILLIS, DEFAULT_CLEANUP_RUN_TIMEOUT_MILLIS, myTimeService, new CleanupKeyProcessor(myTimeService), myOutgoingConnectionAllower); myWorkerFuture = myContext.getExecutor().submit(myConnectionWorker); } ConnectionManager(ConnectionManagerContext context,
                           TimeService timeService,
                           NewConnectionAllower newIncomingConnectionAllower,
                           NewConnectionAllower newOutgoingConnectionAllower,
                           SelectorFactory selectorFactory,
                           AtomicInteger mySendBufferSize,
                           AtomicInteger myReceiveBufferSize); void initAndRunWorker(ServerChannelRegister serverChannelRegister); void setSelectorSelectTimeout(int timeout); boolean offerConnect(ConnectTask connectTask, int timeout, TimeUnit timeUnit); boolean offerWrite(WriteTask writeTask, int timeout, TimeUnit timeUnit); int getBindPort(); void close(int timeout, TimeUnit timeUnit); void close(); void setCleanupTimeout(long timeoutMillis); void setSocketConnectionTimeout(long timeoutMillis); void closeChannel(Channel channel);  }### Answer:
@Test(expectedExceptions = IllegalStateException.class) public void testThatDoubleInitThrowException() { try { myConnectionManager.initAndRunWorker(new FirstAvailableChannel(6881, 6889)); } catch (IOException e) { fail("unable to init and run worker", e); } try { myConnectionManager.initAndRunWorker(new FirstAvailableChannel(6881, 6889)); } catch (IOException e) { fail("unable to init and run worker", e); } }