@Test
  public void testBadChannelPutFailure() throws Exception {
    router = getNonBlockingRouter();
    int blobSize = chunkSize * random.nextInt(10) + 1;
    RequestAndResult requestAndResult = new RequestAndResult(blobSize);
    requestAndResultsList.add(requestAndResult);
    MockReadableStreamChannel putChannel = new MockReadableStreamChannel(blobSize, false);
    CompletableFuture<String> future =
        router.putBlob(requestAndResult.putBlobProperties, requestAndResult.putUserMetadata, putChannel,
            requestAndResult.options);
    ByteBuffer src = ByteBuffer.wrap(requestAndResult.putContent);

    //Make the channel act bad.
    putChannel.beBad();

    pushWithDelay(src, putChannel, blobSize, future);
    requestAndResult.result = future;
    Exception expectedException = new Exception("Channel encountered an error");
    assertFailure(expectedException, true);
    assertCloseCleanup();
  }
Test a put where the put channel encounters an exception and finishes prematurely. Ensures that the operation
completes and with failure.
ambry-router/src/test/java/com/github/ambry/router/PutManagerTest.java