}
}
public void testRandomWrites() throws IOException {
final TemporaryBuffer b = new TemporaryBuffer.LocalFile();
final TestRng rng = new TestRng(getName());
final int max = TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 2;
final byte[] expect = new byte[max];
try {
int written = 0;
boolean onebyte = true;
while (written < max) {
if (onebyte) {
final byte v = (byte) rng.nextInt();
b.write(v);
expect[written++] = v;
} else {
final int len = Math
.min(rng.nextInt() & 127, max - written);
final byte[] tmp = rng.nextBytes(len);
b.write(tmp, 0, len);
System.arraycopy(tmp, 0, expect, written, len);
written += len;
}
onebyte = !onebyte;