}
public void testWriteAndReadBulkByte() {
byte data[] = new byte[10];
Packet packet = createTestPacket(data.length*10);
for(int i=0; i < 10; i++) {
Arrays.fill(data,(byte)i);
assertEquals(data.length, packet.write(data,0,data.length));
}
assertEquals(-1, packet.write(data,0,data.length));
byte buffer[] = new byte[data.length];
packet.flip();
for(int i=0; i < 10; i++) {
assertEquals(buffer.length, packet.read(buffer,0,buffer.length));
Arrays.fill(data,(byte)i);
assertEquals(buffer, data);
}
assertEquals(-1, packet.read(buffer,0,buffer.length));
}