@Test
public void testHedgingWhenFileNotFoundException() throws Exception {

  ClientProtocol active = Mockito.mock(ClientProtocol.class);
  Mockito
      .when(active.getBlockLocations(anyString(),
          anyLong(), anyLong()))
      .thenThrow(new RemoteException("java.io.FileNotFoundException",
          "File does not exist!"));
  ClientProtocol standby = Mockito.mock(ClientProtocol.class);
  Mockito
      .when(standby.getBlockLocations(anyString(),
          anyLong(), anyLong()))
      .thenThrow(
          new RemoteException("org.apache.hadoop.ipc.StandbyException",
          "Standby NameNode"));
  RequestHedgingProxyProvider<ClientProtocol> provider =
      new RequestHedgingProxyProvider<>(conf, nnUri,
        ClientProtocol.class, createFactory(active, standby));
  try {
    provider.getProxy().proxy.getBlockLocations("/tmp/test.file", 0L, 20L);
    Assert.fail("Should fail since the active namenode throws"
        + " FileNotFoundException!");
  } catch (MultiException me) {
    for (Exception ex : me.getExceptions().values()) {
      Exception rEx = ((RemoteException) ex).unwrapRemoteException();
      if (rEx instanceof StandbyException) {
        continue;
      }
      Assert.assertTrue(rEx instanceof FileNotFoundException);
    }
  }
  Mockito.verify(active).getBlockLocations(anyString(),
      anyLong(), anyLong());
  Mockito.verify(standby).getBlockLocations(anyString(),
      anyLong(), anyLong());
}