*
*/
@Test
public void testWriteRaidTask() throws IOException {
// xor
RaidTask task = generateRaidTask(RaidCodec.getCodec("xor"), 2, 11, 1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
task.write(new DataOutputStream(out));
byte[] buffer = out.toByteArray();
// read and verify
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
RaidTask newTask = new RaidTask();
newTask.readFields(new DataInputStream(in));
assertTrue(verifyRaidTask(task, newTask));
// rs
task = generateRaidTask(RaidCodec.getCodec("rs"), 1, 14, 4);
out = new ByteArrayOutputStream();
task.write(new DataOutputStream(out));
buffer = out.toByteArray();
// read and verify
in = new ByteArrayInputStream(buffer);
newTask = new RaidTask();
newTask.readFields(new DataInputStream(in));
assertTrue(verifyRaidTask(task, newTask));
}