freeBucket(bucket);
}
}
public void testReadWrite() throws IOException {
Bucket bucket = makeBucket(Math.max(DATA1.length, DATA2.length));
try {
assertEquals("Size-0", 0, bucket.size());
// Write
OutputStream os = bucket.getOutputStream();
os.write(DATA1);
os.close();
assertEquals("Size-1", DATA1.length, bucket.size());
// Read byte[]
InputStream is = bucket.getInputStream();
byte[] data = new byte[DATA1.length];
int read = is.read(data, 0, DATA1.length);
is.close();
assertEquals("SimpleRead-1-SIZE", DATA1.length, read);
assertEquals("SimpleRead-1", new ByteArrayWrapper(DATA1), new ByteArrayWrapper(data));
// Read byte
is = bucket.getInputStream();
for (byte b : DATA1)
assertEquals("SimpleRead-2", b, (byte) is.read());
// EOF
assertEquals("SimpleRead-EOF0", -1, is.read(new byte[4]));