ReleasableInputStream extends InputStream { @Override public void close() throws IOException { try { delegate.close(); } finally { safeClose(); } } ReleasableInputStream(InputStream delegate, Runnable onClose); @Override int read(); @Override int read(byte[] bytes); @Override int read(byte[] bytes, int i, int i1); @Override long skip(long l); @Override int available(); @Override void close(); @Override void mark(int i); @Override void reset(); @Override boolean markSupported();  }
@Test public void close() throws Exception { releasableInputStream.close(); assertTrue(wasCalled.get()); }