/** * Tests the read(buffer) method by reading a file one buffer at a time. * * @throws IOException */ @Test public void testReadBuffer() throws IOException { byte[] buffer = new byte[1024]; long buffersRead = 0; for (int bytesRead = pis.read(buffer); bytesRead != -1; bytesRead = pis.read(buffer)) { buffersRead++; } assertEquals(getExpectedBufferReads(file.length(), buffer.length), buffersRead); LOGGER.trace("Done"); }
/** * Tests the read(buffer, offset, length) method by read a file one buffer at the file using the * offset and length. * * @throws IOException */ @Test public void testReadBufferOffLen() throws IOException { byte[] buffer = new byte[2048]; int off = 512; int len = 1024; initByteArrayWith0(buffer); long buffersRead = 0; for (int bytesRead = pis.read(buffer, off, len); bytesRead != -1; bytesRead = pis.read(buffer, off, len)) { buffersRead++; } assertEquals(getExpectedBufferReads(file.length(), len), buffersRead); LOGGER.trace("Done"); }
/** * Tests the read() method by reading a file one byte at a time. * * @throws IOException */ @Test public void testRead() throws IOException { int numBytesRead = 0; while (pis.read() != -1) numBytesRead++; assertEquals(file.length(), numBytesRead); LOGGER.trace("Done"); }