KeepOpenInputStream extends FilterInputStream { @Override public void close() throws IOException { LOG.debug("Not closing stream yet"); } KeepOpenInputStream(InputStream is); @Override void close(); void doClose(); static void closeStream(InputStream is);  }
@Test public void testClose() throws IOException { when(is.markSupported()).thenReturn(true); KeepOpenInputStream keepOpenInputStream = new KeepOpenInputStream(is); keepOpenInputStream.close(); verify(is).markSupported(); verifyNoMoreInteractions(is); }