bufferTest2(10000,2);
bufferTest2(10000,1);
}
private void bufferTest(int streamByteBufferSize, int testBufferSize) throws IOException {
StreamByteBuffer streamBuf = new StreamByteBuffer(streamByteBufferSize);
OutputStream output = streamBuf.getOutputStream();
for (int i = 0; i < testBufferSize; i++) {
output.write(i % (Byte.MAX_VALUE*2));
}
output.close();
byte[] buffer = new byte[testBufferSize];
InputStream input = streamBuf.getInputStream();
assertEquals(testBufferSize, input.available());
int readBytes = input.read(buffer);
assertEquals(readBytes, testBufferSize);
for (int i = 0; i < buffer.length; i++) {
assertEquals((byte)(i % (Byte.MAX_VALUE*2)), buffer[i]);