private Document serializeAndDeserialize(Document doc, DocumentTypeManager manager) {
        GrowableByteBuffer buffer = new GrowableByteBuffer(1024);
        DocumentSerializer serializer = DocumentSerializerFactory.createHead(buffer);
        serializer.write(doc);
        buffer.flip();

        DocumentDeserializer deserializer = DocumentDeserializerFactory.createHead(manager, buffer);
        return new Document(deserializer);
    }
Test for bug 4066566. No assertions, but works if it runs without exceptions.
document/src/test/java/com/yahoo/document/datatypes/StringTestCase.java