@Test
  public void compressChunk()
      throws IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {
    // Setup router config.
    Properties properties = new Properties();
    properties.setProperty("router.hostname", "localhost");
    properties.setProperty("router.datacenter.name", "DC1");
    properties.setProperty("router.max.put.chunk.size.bytes", Integer.toString(chunkSize));
    properties.setProperty("router.put.request.parallelism", Integer.toString(requestParallelism));
    properties.setProperty("router.put.success.target", Integer.toString(successTarget));
    RouterConfig routerConfig = new RouterConfig(new VerifiableProperties(properties));

    // Create the blob properties for testing.
    BlobProperties blobProperties = new BlobProperties(-1, "serviceId", "memberId",
        "text/javascript", false, Utils.Infinite_Time, Utils.getRandomShort(TestUtils.RANDOM),
        Utils.getRandomShort(TestUtils.RANDOM), false, null, null, null);

    // Create an instance of PutOperation.
    int numChunks = routerConfig.routerMaxInMemPutChunks + 1;
    byte[] userMetadata = new byte[10];
    byte[] content = new byte[chunkSize * numChunks];
    ReadableStreamChannel channel = new ByteBufferReadableStreamChannel(ByteBuffer.wrap(content));
    FutureResult<String> future = new FutureResult<>();
    MockNetworkClient mockNetworkClient = new MockNetworkClient();
    PutOperation op = PutOperation.forUpload(routerConfig, routerMetrics, mockClusterMap, new LoggingNotificationSystem(),
        new InMemAccountService(true, false), userMetadata, channel, PutBlobOptions.DEFAULT, future, null,
        new RouterCallback(mockNetworkClient, new ArrayList<>()), null, null, null, null, time, blobProperties,
        MockClusterMap.DEFAULT_PARTITION_CLASS, quotaChargeCallback, compressionService);

    // PutOperation constructor creates an instance of PutChunk.  Set the PutChunk's source buffer.
    byte[] sourceBuffer = ("Test Message for testing purpose.  The Message is part of the testing message."
        + "Test Message for testing purpose.  The Message is part of the testing message."
        + "Test Message for testing purpose.  The Message is part of the testing message.").getBytes();
    ByteBuf sourceByteBuf = Unpooled.wrappedBuffer(sourceBuffer);
    PutOperation.PutChunk putChunk = op.new PutChunk();
    putChunk.buf = sourceByteBuf;

    // Invoke the PutChunk.compressChunk() method.  The new buffer is stored in "buf" field.
    MethodUtils.invokeMethod(putChunk, true, "compressChunk", false);

    // Verify the chunk is compressed.
    Assert.assertTrue((boolean) FieldUtils.readField(putChunk, "isChunkCompressed", true));

    // Release the buf field.
    ByteBuf buf = (ByteBuf) FieldUtils.readField(putChunk, "buf", true);
    buf.release();
  }
Get the {@link ResponseInfo} for the given {@link RequestInfo} using the {@link MockServer}
@param requestInfo the {@link RequestInfo} for which the response is to be returned.
@return the {@link ResponseInfo} the response for the request.
@throws IOException if there is an error sending the request.
ambry-router/src/test/java/com/github/ambry/router/PutOperationTest.java