@Test
    public void testDocumentDataType() {
        //use documenttypemanagerconfigurer to read config
        docMan = new DocumentTypeManager();
        DocumentTypeManagerConfigurer.configure(docMan, "file:src/test/document/docindoc.cfg");

        //get a document type
        docMan.getDocumentType("outerdoc");

        //create document and necessary structures
        Document outerdoc = new Document(docMan.getDocumentType("outerdoc"), new DocumentId("id:recursion:outerdoc::"));
        Document innerdoc = new Document(docMan.getDocumentType("innerdoc"), new DocumentId("id:recursion:innerdoc::"));

        innerdoc.setFieldValue("intfield", 55);

        outerdoc.setFieldValue("stringfield", "boooo");
        outerdoc.setFieldValue("docfield", innerdoc);

        //serialize document
        int size = outerdoc.getSerializedSize();
        GrowableByteBuffer buf = new GrowableByteBuffer(size, 2.0f);
        outerdoc.serialize(buf);

        assertEquals(size, buf.position());

        //deserialize document
        buf.position(0);
        Document outerdoc2 = docMan.createDocument(buf);

        //compare values
        assertEquals(outerdoc, outerdoc2);
    }
Test for Document and all its features, including (de)serialization.

@author Thomas Gundersen
@author bratseth
document/src/test/java/com/yahoo/document/DocumentTestCase.java