public static byte[] serializeDocument(Document doc) {
        GrowableByteBuffer out = new GrowableByteBuffer();
        DocumentSerializerFactory.createHead(out).write(doc);
        out.flip();
        byte[] buf = new byte[out.remaining()];
        out.get(buf);
        return buf;
    }
Helper class with utils used in serialization and deserialization test cases.

@author geirst
document/src/test/java/com/yahoo/document/serialization/SerializationTestUtils.java