s.embeddedRefBlockContentID = -1;
s.globalRecordCounter = 16;
s.nofRecords = 17;
s.sequenceId = 18;
s.refMD5 = "1234567890123456".getBytes();
s.coreBlock = new Block(BlockCompressionMethod.GZIP.ordinal(),
BlockContentType.CORE, 0, "core123457890".getBytes(), null);
s.external = new HashMap<Integer, Block>();
for (int i = 1; i < 5; i++) {
Block e1 = new Block(BlockCompressionMethod.GZIP.ordinal(),
BlockContentType.EXTERNAL, i,
"external123457890".getBytes(), null);
s.external.put(i, e1);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SliceIO sio = new SliceIO();
sio.write(s, baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
Slice s2 = new Slice();
sio.read(s2, bais);
assertEquals(s.contentIDs.length, s2.external.size());
assertArrayEquals(s.headerBlock.getRawContent(),
s2.headerBlock.getRawContent());
assertArrayEquals(s.coreBlock.getRawContent(),
s2.coreBlock.getRawContent());
for (int id : s.contentIDs) {
Block e1 = s.external.get(id);
Block e2 = s2.external.get(id);
assertArrayEquals(e1.getRawContent(), e2.getRawContent());
}
}