@Test
public void testBufferOutputStream() throws Exception {

	byte[] data = new byte[1024];
	_random.nextBytes(data);
	Serializer serializer = new Serializer();
	BufferOutputStream bufferOutputStream = new BufferOutputStream(
		serializer);
	for (byte b : data) {
		bufferOutputStream.write(b);
	}
	ByteBuffer byteBuffer = serializer.toByteBuffer();
	Assert.assertArrayEquals(data, byteBuffer.array());
	serializer = new Serializer();
	bufferOutputStream = new BufferOutputStream(serializer);
	bufferOutputStream.write(data);
	byteBuffer = serializer.toByteBuffer();
	Assert.assertArrayEquals(data, byteBuffer.array());
}