@Test
public void testBlockWrite() throws Exception {

	ByteArrayOutputStream byteArrayOutputStream =
		new ByteArrayOutputStream();
	UnsyncBufferedOutputStream unsyncBufferedOutputStream =
		new UnsyncBufferedOutputStream(byteArrayOutputStream, _SIZE * 2);
	byte[] buffer = (byte[])_bufferField.get(unsyncBufferedOutputStream);
	Assert.assertEquals(Arrays.toString(buffer), _SIZE * 2, buffer.length);
	unsyncBufferedOutputStream.write(_BUFFER);
	for (int i = 0; i < _SIZE; i++) {
		Assert.assertEquals(i, buffer[i]);
	}
	unsyncBufferedOutputStream.write(_BUFFER);
	for (int i = _SIZE; i < (_SIZE * 2); i++) {
		Assert.assertEquals(i - _SIZE, buffer[i]);
	}
	unsyncBufferedOutputStream.write(100);
	buffer = (byte[])_bufferField.get(unsyncBufferedOutputStream);
	Assert.assertEquals(100, buffer[0]);
	Assert.assertEquals(_SIZE * 2, byteArrayOutputStream.size());
	byteArrayOutputStream.reset();
	unsyncBufferedOutputStream = new UnsyncBufferedOutputStream(
		byteArrayOutputStream, _SIZE + 1);
	unsyncBufferedOutputStream.write(100);
	unsyncBufferedOutputStream.write(110);
	Assert.assertEquals(0, byteArrayOutputStream.size());
	unsyncBufferedOutputStream.write(_BUFFER);
	Assert.assertEquals(2, byteArrayOutputStream.size());
	byte[] bytes = byteArrayOutputStream.toByteArray();
	Assert.assertEquals(100, bytes[0]);
	Assert.assertEquals(110, bytes[1]);
	buffer = (byte[])_bufferField.get(unsyncBufferedOutputStream);
	for (int i = 0; i < _SIZE; i++) {
		Assert.assertEquals(i, buffer[i]);
	}
	byteArrayOutputStream.reset();
	unsyncBufferedOutputStream = new UnsyncBufferedOutputStream(
		byteArrayOutputStream, _SIZE / 2);
	unsyncBufferedOutputStream.write(_BUFFER);
	Assert.assertArrayEquals(_BUFFER, byteArrayOutputStream.toByteArray());
}