@Test
public void testCloseFailed() throws IOException {

  EventLogHttpTransferListener listener = new EventLogHttpTransferListener();
  InputStream in = mock(InputStream.class);
  doThrow(new IOException("test")).when(in).close();
  InputStream oin = new ObservableInputStream(in, listener);
  try {
    oin.close();
    fail("expected exception not thrown");
  } catch (IOException e) {
    assertEquals("test", e.getMessage());
  }
  assertEquals(of(Closed.INSTANCE), listener.getEventLog());
}