@Test
public void testExceptionInfo() throws Exception {

  final ClientProtocol goodMock = mock(ClientProtocol.class);
  when(goodMock.getStats()).thenAnswer(new Answer<long[]>() {
    private boolean first = true;
    @Override
    public long[] answer(InvocationOnMock invocation)
        throws Throwable {
      if (first) {
        Thread.sleep(1000);
        first = false;
        return new long[] {1};
      } else {
        throw new IOException("Expected Exception Info");
      }
    }
  });
  final ClientProtocol badMock = mock(ClientProtocol.class);
  when(badMock.getStats()).thenAnswer(new Answer<long[]>() {
    @Override
    public long[] answer(InvocationOnMock invocation)
        throws Throwable {
      throw new IOException("Bad Mock! This is Standby!");
    }
  });
  RequestHedgingProxyProvider<ClientProtocol> provider =
      new RequestHedgingProxyProvider<>(conf, nnUri, ClientProtocol.class,
          createFactory(badMock, goodMock));
  ClientProtocol proxy = provider.getProxy().proxy;
  proxy.getStats();
  // Test getting the exception when the successful proxy encounters one.
  try {
    proxy.getStats();
  } catch (IOException e) {
    assertExceptionContains("Expected Exception Info", e);
  }
}