TransferProgressFileInputStream extends FileInputStream { @Override public int read() throws IOException { int b = super.read(); this.transferProgress.notify(new byte[]{(byte) b}, 1); return b; } TransferProgressFileInputStream(File file, TransferProgress transferProgress); @Override int read(); @Override int read(byte b[]); @Override int read(byte b[], int off, int len);  }
@Test public void read() throws IOException { int expected = this.inputStream.read(); assertArrayEquals(new byte[]{(byte) expected}, this.transferProgress.getBuffer()); assertEquals(1, this.transferProgress.getLength()); }
@Test public void readByteArray() throws IOException { byte[] buffer = new byte[SIZE]; int length = this.inputStream.read(buffer); assertArrayEquals(buffer, this.transferProgress.getBuffer()); assertEquals(length, this.transferProgress.getLength()); }
@Test public void readyByteArrayLength() throws IOException { byte[] buffer = new byte[SIZE]; int length = this.inputStream.read(buffer, 0, SIZE); assertArrayEquals(buffer, this.transferProgress.getBuffer()); assertEquals(length, this.transferProgress.getLength()); }
@Test public void readyByteArrayOffsetLength() throws IOException { byte[] buffer = new byte[BIG_SIZE]; int length = this.inputStream.read(buffer, START_POSITION, SIZE); byte[] expected = new byte[SIZE]; System.arraycopy(buffer, START_POSITION, expected, 0, SIZE); assertArrayEquals(expected, this.transferProgress.getBuffer()); assertEquals(length, this.transferProgress.getLength()); }