### Question:
ByteCountingCallbackInputStreamWrapper extends InputStream { @Override public int read() throws IOException { return inputStream.read(); } ByteCountingCallbackInputStreamWrapper(
			final ConnectionProgressStatusListener connectionProgressStatusListener, final InputStream inputStream); @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(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override synchronized void reset(); @Override long skip(final long n);  }### Answer:
@Test public void testReadByteArray() throws Exception { int expectedLen = 100; InputStream dummyInputStream = Mockito.mock(InputStream.class); ConnectionProgressStatusListener listener = Mockito.mock(ConnectionProgressStatusListener.class); @SuppressWarnings("resource") ByteCountingCallbackInputStreamWrapper byteCountingCallbackInputStream = new ByteCountingCallbackInputStreamWrapper( listener, dummyInputStream); byte[] readBuffer = new byte[100]; Mockito.when(dummyInputStream.read(readBuffer)).thenReturn(expectedLen); int actualRead = byteCountingCallbackInputStream.read(readBuffer); Assert.assertEquals("did not get expected length back", expectedLen, actualRead); Mockito.verify(listener).connectionProgressStatusCallback(Matchers.isA(ConnectionProgressStatus.class)); }
@Test public void testReadByteArrayIntInt() throws Exception { int expectedLen = 100; InputStream dummyInputStream = Mockito.mock(InputStream.class); ConnectionProgressStatusListener listener = Mockito.mock(ConnectionProgressStatusListener.class); @SuppressWarnings("resource") ByteCountingCallbackInputStreamWrapper byteCountingCallbackInputStream = new ByteCountingCallbackInputStreamWrapper( listener, dummyInputStream); byte[] readBuffer = new byte[100]; Mockito.when(dummyInputStream.read(readBuffer, 0, expectedLen)).thenReturn(expectedLen); int actualRead = byteCountingCallbackInputStream.read(readBuffer, 0, expectedLen); Assert.assertEquals("did not get expected length back", expectedLen, actualRead); Mockito.verify(listener).connectionProgressStatusCallback(Matchers.isA(ConnectionProgressStatus.class)); }