@Test
  public void testSelectorError() throws Exception {
    ServerErrorCode[] serverErrorCodes = new ServerErrorCode[9];
    Arrays.fill(serverErrorCodes, ServerErrorCode.NoError);
    HashMap<MockSelectorState, RouterErrorCode> errorCodeHashMap = new HashMap<>();
    errorCodeHashMap.put(MockSelectorState.DisconnectOnSend, RouterErrorCode.OperationTimedOut);
    errorCodeHashMap.put(MockSelectorState.ThrowExceptionOnAllPoll, RouterErrorCode.OperationTimedOut);
    errorCodeHashMap.put(MockSelectorState.ThrowExceptionOnConnect, RouterErrorCode.OperationTimedOut);
    errorCodeHashMap.put(MockSelectorState.ThrowExceptionOnSend, RouterErrorCode.OperationTimedOut);
    errorCodeHashMap.put(MockSelectorState.ThrowThrowableOnSend, RouterErrorCode.RouterClosed);
    for (MockSelectorState state : MockSelectorState.values()) {
      if (state == MockSelectorState.Good || state == MockSelectorState.FailConnectionInitiationOnPoll) {
        // FailConnectionInitiationOnPoll is temporarily used for warm up failure test, skip it here
        continue;
      }
      mockSelectorState.set(state);
      setServerErrorCodes(serverErrorCodes, partition, serverLayout, localDc);
      CountDownLatch operationCompleteLatch = new CountDownLatch(1);
      future = router.deleteBlob(null, blobIdString, null, new ClientCallback(operationCompleteLatch), quotaChargeCallback);
      do {
        // increment mock time
        mockTime.sleep(1000);
      } while (!operationCompleteLatch.await(10, TimeUnit.MILLISECONDS));
      assertFailureAndCheckErrorCode(future, errorCodeHashMap.get(state));
    }
  }
Test the case when the {@link com.github.ambry.network.Selector} of {@link SocketNetworkClient}
experiences various exceptions. The order of received responses is the same as defined in {@code serverErrorCodes}.
ambry-router/src/test/java/com/github/ambry/router/DeleteManagerTest.java