@Test
public void testHedgingWhenConnectAndEOFException() throws Exception {

  ClientProtocol active = Mockito.mock(ClientProtocol.class);
  Mockito.when(active.getStats()).thenThrow(new EOFException());
  ClientProtocol standby = Mockito.mock(ClientProtocol.class);
  Mockito.when(standby.getStats()).thenThrow(new ConnectException());
  RequestHedgingProxyProvider<ClientProtocol> provider =
      new RequestHedgingProxyProvider<>(conf, nnUri,
        ClientProtocol.class, createFactory(active, standby));
  try {
    provider.getProxy().proxy.getStats();
    Assert.fail("Should fail since both active and standby namenodes throw"
        + " Exceptions!");
  } catch (MultiException me) {
    for (Exception ex : me.getExceptions().values()) {
      if (!(ex instanceof ConnectException) &&
          !(ex instanceof EOFException)) {
        Assert.fail("Unexpected Exception " + ex.getMessage());
      }
    }
  }
  Mockito.verify(active).getStats();
  Mockito.verify(standby).getStats();
}