EofSensorInputStream extends InputStream { @Override public void close() throws IOException { selfClosed = true; checkClose(); } EofSensorInputStream(final InputStream in,
                                final EofSensorWatcher watcher); @Override int read(); @Override int read(final byte[] b, final int off, final int len); @Override int read(final byte[] b); @Override int available(); @Override void close(); void abort();  }
@Test public void testClose() throws Exception { Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE); eofstream.close(); Assert.assertTrue(eofstream.isSelfClosed()); Assert.assertNull(eofstream.getWrappedStream()); Mockito.verify(inStream, Mockito.times(1)).close(); Mockito.verify(eofwatcher).streamClosed(inStream); eofstream.close(); }