@Test
  public void testFailureOnAllPollThatSends() throws Exception {
    requestAndResultsList.clear();
    requestAndResultsList.add(new RequestAndResult(chunkSize * 5));
    mockSelectorState.set(MockSelectorState.ThrowExceptionOnSend);
    // In the case of an error in poll, the router gets closed, and all the ongoing operations are finished off with
    // RouterClosed error.
    Exception expectedException = new RouterException("", RouterErrorCode.OperationTimedOut);
    submitPutsAndAssertFailure(expectedException, true, true, true);
    // router should get closed automatically
    Assert.assertFalse("Router should be closed", router.isOpen());
    assertEquals("No ChunkFiller threads should be running after the router is closed", 0,
        TestUtils.numThreadsByThisName("ChunkFillerThread"));
    assertEquals("No RequestResponseHandler threads should be running after the router is closed", 0,
        TestUtils.numThreadsByThisName("RequestResponseHandlerThread"));
    assertEquals("All operations should have completed", 0, router.getOperationsCount());
  }
Tests a failure scenario where selector poll throws an exception when there is anything to send.
ambry-router/src/test/java/com/github/ambry/router/PutManagerTest.java