}
private void check(byte[] bytes) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Serializer s = new Serializer(baos);
s.serialize(new AppendStdErrEvent(bytes, 0, bytes.length));
s.flush();
s.close();
Deserializer deserializer = new Deserializer(new ByteArrayInputStream(baos.toByteArray()),
Thread.currentThread().getContextClassLoader());
IEvent deserialize = deserializer.deserialize();
Assert.assertTrue(deserialize instanceof AppendStdErrEvent);
AppendStdErrEvent e = ((AppendStdErrEvent) deserialize);
baos.reset();
e.copyTo(baos);
Assert.assertTrue(
"Exp: " + Arrays.toString(bytes) + "\n" +
"was: " + Arrays.toString(baos.toByteArray()),
Arrays.equals(bytes, baos.toByteArray()));
}