### Question:
TcpManager { public void launch(final Nuklei nuklei) { nuklei.spinUp(messagingNukleus); tcpReceiver.launch(nuklei); tcpSender.launch(nuklei); } TcpManager(final MpscArrayBuffer<Object> commandQueue, final AtomicBuffer sendBuffer); void launch(final Nuklei nuklei); void launch(final Nuklei manageNuklei, final Nuklei receiverNuklei, final Nuklei senderNuklei); void close();  }### Answer:
@Test(timeout = 1000) public void shouldBeAbleToSpinUpAndShutdownTcpManagerWithSingleNuklei() throws Exception { tcpManager.launch(dedicatedNuklei); }
@Test(timeout = 1000) public void shouldHandleConnectAndSendReceiveOfDataWithSingleNuklei() throws Exception { tcpManager.launch(dedicatedNuklei); tcpManagerProxy.attach(PORT, new InetAddress[0], receiveBuffer); Thread.sleep(100); senderChannel = SocketChannel.open(); senderChannel.connect(new InetSocketAddress("localhost", PORT)); int messages = receiveSingleMessage((typeId, buffer, offset, length) -> { assertThat(typeId, is(TcpManagerEvents.NEW_CONNECTION_TYPE_ID)); assertThat(buffer.getLong(offset), is(0L)); }); assertThat(messages, is(1)); sendChannelBuffer.clear(); sendChannelBuffer.putInt(MAGIC_PAYLOAD_INT); sendChannelBuffer.flip(); senderChannel.write(sendChannelBuffer); messages = receiveSingleMessage((typeId, buffer, offset, length) -> { assertThat(typeId, is(TcpManagerEvents.RECEIVED_DATA_TYPE_ID)); assertThat(buffer.getLong(offset), is(0L)); assertThat(length, is(BitUtil.SIZE_OF_INT + BitUtil.SIZE_OF_LONG)); assertThat(buffer.getInt(offset + BitUtil.SIZE_OF_LONG), is(MAGIC_PAYLOAD_INT)); }); assertThat(messages, is(1)); }
@Test(timeout = 1000) public void shouldHandleConnectAndReceiveOfDataWithSingleNuklei() throws Exception { tcpManager.launch(dedicatedNuklei); tcpManagerProxy.attach(PORT, new InetAddress[0], receiveBuffer); Thread.sleep(100); receiverChannel = SocketChannel.open(); receiverChannel.connect(new InetSocketAddress("localhost", PORT)); receiverChannel.configureBlocking(false); int messages = receiveSingleMessage((typeId, buffer, offset, length) -> { assertThat(typeId, is(TcpManagerEvents.NEW_CONNECTION_TYPE_ID)); assertThat(buffer.getLong(offset), is(0L)); }); assertThat(messages, is(1)); sendAtomicBuffer.putLong(0, 0); sendAtomicBuffer.putInt(BitUtil.SIZE_OF_LONG, MAGIC_PAYLOAD_INT); tcpManagerProxy.send(sendAtomicBuffer, 0, BitUtil.SIZE_OF_LONG + BitUtil.SIZE_OF_INT); receiveChannelBuffer.clear(); messages = receiveSingleMessage(receiverChannel, (buffer) -> { assertThat(buffer.position(), is(BitUtil.SIZE_OF_INT)); assertThat(buffer.getInt(0), is(MAGIC_PAYLOAD_INT)); }); assertThat(messages, is(1)); }