@Test
  public void replicateBlobRequestResponseTest() throws IOException {
    final MockClusterMap clusterMap = new MockClusterMap();
    final short accountId = Utils.getRandomShort(TestUtils.RANDOM);
    final short containerId = Utils.getRandomShort(TestUtils.RANDOM);
    final String clientId = "client";
    final BlobId id1 = new BlobId(CommonTestUtils.getCurrentBlobIdVersion(), BlobId.BlobIdType.NATIVE,
        ClusterMap.UNKNOWN_DATACENTER_ID, accountId, containerId,
        clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
        BlobId.BlobDataType.DATACHUNK);
    final String sourceHostName = "datacenter1_host1";
    final int sourceHostPort = 15058;
    final int correlationId = TestUtils.RANDOM.nextInt();

    final RequestOrResponseType operationType =
        RequestOrResponseType.values()[Utils.getRandomShort(TestUtils.RANDOM) % RequestOrResponseType.values().length];
    final long operationTime = SystemTime.getInstance().milliseconds() + TestUtils.RANDOM.nextInt();
    final short lifeVersion = Utils.getRandomShort(TestUtils.RANDOM);
    final long operationParameter = Utils.getRandomLong(TestUtils.RANDOM, Long.MAX_VALUE);
    short[] versions = new short[]{ReplicateBlobRequest.VERSION_1, ReplicateBlobRequest.VERSION_2};
    for (short version : versions) {
      final ReplicateBlobRequest replicateBlobRequest;
      if (version == ReplicateBlobRequest.VERSION_1) {
        replicateBlobRequest = new ReplicateBlobRequest(correlationId, clientId, id1, sourceHostName, sourceHostPort);
      } else {
        replicateBlobRequest =
            new ReplicateBlobRequest(correlationId, clientId, id1, sourceHostName, sourceHostPort, operationType,
                operationTime, lifeVersion, operationParameter);
      }

      DataInputStream requestStream = serAndPrepForRead(replicateBlobRequest, -1, true);
      final ReplicateBlobRequest deserializedReplicateBlobRequest =
          ReplicateBlobRequest.readFrom(requestStream, clusterMap);
      verifyReplicateBlobRequest(replicateBlobRequest, deserializedReplicateBlobRequest);
      replicateBlobRequest.release();

      final ReplicateBlobResponse response =
          new ReplicateBlobResponse(correlationId, clientId, ServerErrorCode.NoError);
      requestStream = serAndPrepForRead(response, -1, false);
      final ReplicateBlobResponse deserializedReplicateBlobResponse = ReplicateBlobResponse.readFrom(requestStream);
      verifyReplicateBlobResponse(response, deserializedReplicateBlobResponse);
      response.release();
    }
  }
Tests for {@link ReplicateBlobRequest} and {@link ReplicateBlobResponse}.
@throws IOException
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java