}
}
@Test
public void testRandomSerialize() throws Exception {
DataTransferHeaderOptions options = new DataTransferHeaderOptions();
for (int c = 0; c < 4; c++) {
for (int data = 0; data < 8; data++) {
for (int advise = 0; advise < 6; advise++) {
options.setFadvise(advise);
options.setIoprio(c, data);
// Serialize.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bos);
options.write(out);
byte[] buf = bos.toByteArray();
out.close();
// De - Serialize
DataInputStream in = new DataInputStream(
new ByteArrayInputStream(buf));
DataTransferHeaderOptions expectedOptions = new DataTransferHeaderOptions();
expectedOptions
.readFields(in);
assertEquals(advise, expectedOptions.getFadvise());
assertEquals(c, expectedOptions.getIoprioClass());
assertEquals(data, expectedOptions.getIoprioData());
}
}
}
}