ReportingInputStream extends ProxyInputStream { @Override protected synchronized void afterRead(int bytes) { if (bytes == -1) { report.finishedFile(); } else { report.progress(bytes); } } ReportingInputStream(InputStream wrappedStream, ProgressReport report); @Override synchronized long skip(final long length);  }
@Test public void reportsEndOfTransfer() throws Exception { stream.afterRead(-1); verify(report).finishedFile(); }