private void simpleRequest(Port targetPort) throws IOException, InterruptedException {
    byte[] bytesToSend = new byte[1028];
    new Random().nextBytes(bytesToSend);
    ByteBuffer byteBufferToSend = ByteBuffer.wrap(bytesToSend);
    byteBufferToSend.putLong(0, 1028);
    BoundedByteBufferSend bufferToSend = new BoundedByteBufferSend(byteBufferToSend);
    BlockingChannel channel = null;
    if (targetPort.getPortType() == PortType.SSL) {
      channel =
          new SSLBlockingChannel("localhost", targetPort.getPort(), new MetricRegistry(), 10000, 10000, 1000, 2000,
              clientSSLSocketFactory, clientSSLConfig);
    } else {
      channel = new BlockingChannel("localhost", targetPort.getPort(), 10000, 10000, 1000, 2000);
    }
    channel.connect();
    channel.send(bufferToSend);
    RequestResponseChannel requestResponseChannel = server.getRequestResponseChannel();
    NetworkRequest request = requestResponseChannel.receiveRequest();
    DataInputStream requestStream = new DataInputStream(request.getInputStream());
    byte[] outputBytes = new byte[1020];
    requestStream.readFully(outputBytes);
    for (int i = 0; i < 1020; i++) {
      Assert.assertEquals(bytesToSend[8 + i], outputBytes[i]);
    }

    // send response back and ensure response is received
    byte[] responseBytes = new byte[2048];
    new Random().nextBytes(responseBytes);
    ByteBuffer byteBufferToSendResponse = ByteBuffer.wrap(responseBytes);
    byteBufferToSendResponse.putLong(0, 2048);
    BoundedByteBufferSend responseToSend = new BoundedByteBufferSend(byteBufferToSendResponse);
    requestResponseChannel.sendResponse(responseToSend, request, null);
    DataInputStream streamResponse = channel.receive().getInputStream();
    byte[] responseBytesReceived = new byte[2040];
    streamResponse.read(responseBytesReceived);
    for (int i = 0; i < 2040; i++) {
      Assert.assertEquals(responseBytes[8 + i], responseBytesReceived[i]);
    }
    channel.disconnect();
  }
Run only once for all tests
ambry-network/src/test/java/com/github/ambry/network/SocketServerTest.java