### Question:
ContentGenerator { public void write(OutputStream outputStream) throws IOException { for (long nrRemaining = keySize; nrRemaining > 0; nrRemaining -= bufferSize) { int curSize = (int) Math.min(bufferSize, nrRemaining); if (copyBufferSize == 1) { for (int i = 0; i < curSize; i++) { outputStream.write(buffer[i]); } } else { for (int i = 0; i < curSize; i += copyBufferSize) { outputStream.write(buffer, i, Math.min(copyBufferSize, curSize - i)); } } } } ContentGenerator(long keySize, int bufferSize);   ContentGenerator(long keySize, int bufferSize, int copyBufferSize); void write(OutputStream outputStream);  }### Answer:
@Test public void writeWithSmallerBuffers() throws IOException { ContentGenerator generator = new ContentGenerator(10000, 1024, 3); ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); generator.write(baos); Assert.assertEquals(10000, baos.toByteArray().length); }