private Connection createConnectionsAndWriteMessage(final boolean isSenderInView,
      final boolean isCancelInProgress, final boolean waitUntilReaderExits)
      throws IOException, InterruptedException, ExecutionException {
    final DMStats stats = mock(DMStats.class);
    final BufferPool bufferPool = new BufferPool(stats);
    final ServerSocketChannel acceptorSocket = createReceiverSocket();

    final int serverSocketPort = acceptorSocket.socket().getLocalPort();
    final CompletableFuture<Connection> readerFuture =
        createReaderFuture(acceptorSocket, isSenderInView);

    final Connection sender =
        createWriter(serverSocketPort, isCancelInProgress, waitUntilReaderExits);

    final Connection reader = readerFuture.get();
    final ReplyMessage msg = createReplyMessage(sender);

    final List<Connection> connections = new ArrayList<>();
    connections.add(sender);

    final BaseMsgStreamer streamer = MsgStreamer.create(connections, msg, false, stats, bufferPool);
    streamer.writeMessage();
    return reader;
  }
Create a sender connection and a receiver connection and pass data from
one to the other.

This test uses a real socket, but mocks all other collaborators
of connection, such as the InternalDistributedSystem.
geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTransmissionTest.java