KeepOpenInputStream extends FilterInputStream { public void doClose() throws IOException { super.close(); } KeepOpenInputStream(InputStream is); @Override void close(); void doClose(); static void closeStream(InputStream is);  }
@Test public void testDoClose() throws IOException { when(is.markSupported()).thenReturn(true); KeepOpenInputStream keepOpenInputStream = new KeepOpenInputStream(is); keepOpenInputStream.doClose(); verify(is).close(); }