### Question:
ThrottledInputStream extends InputStream { @Override public int read() throws IOException { throttle(); int data = rawStream.read(); if (data != -1) { bytesRead++; } return data; } ThrottledInputStream(InputStream rawStream);  ThrottledInputStream(InputStream rawStream, long maxBytesPerSec); @Override void close(); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); int read(long position, byte[] buffer, int offset, int length); long getTotalBytesRead(); long getBytesPerSec(); long getTotalSleepTime(); @Override String toString();  }### Answer:
@Test public void read() { File tmpFile; File outFile; try { tmpFile = createFile(1024); outFile = createFile(); tmpFile.deleteOnExit(); outFile.deleteOnExit(); long maxBandwidth = copyAndAssert(tmpFile, outFile, 0, 1, -1, CB.BUFFER); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.BUFFER); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.BUFF_OFFSET); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.ONE_C); } catch (IOException e) { LOG.error("Exception encountered ", e); } }
@Test public void testRead() { File tmpFile; File outFile; try { tmpFile = createFile(1024); outFile = createFile(); tmpFile.deleteOnExit(); outFile.deleteOnExit(); long maxBandwidth = copyAndAssert(tmpFile, outFile, 0, 1, -1, CB.BUFFER); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.BUFFER); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.BUFF_OFFSET); copyAndAssert(tmpFile, outFile, maxBandwidth, 20, 0, CB.ONE_C); } catch (IOException e) { LOG.error("Exception encountered ", e); } }