public void testPolymorphicAndCyclic() throws Exception
    {
        Schema<HtmlDocumentRequest> schema = RuntimeSchema
                .getSchema(HtmlDocumentRequest.class);

        Document document = new Document(null);

        attachHead(document);
        attachBody(document);

        HtmlDocumentRequest docRequest = new HtmlDocumentRequest();
        docRequest.document = document;

        verifyGraph(docRequest);
        byte[] data = GraphTest.toByteArray(docRequest, schema);

        HtmlDocumentRequest docRequestFromByteArray = new HtmlDocumentRequest();
        GraphTest.mergeFrom(data, 0, data.length, docRequestFromByteArray,
                schema);

        verifyGraph(docRequestFromByteArray);

        HtmlDocumentRequest docRequestFromStream = new HtmlDocumentRequest();
        ByteArrayInputStream in = new ByteArrayInputStream(data);
        GraphTest.mergeFrom(in, docRequestFromStream, schema);

        verifyGraph(docRequestFromStream);
    }
Test ser/deser of polymorphic graph objects (references and cyclic dependencies).

@author David Yu
@created Jan 19, 2011
protostuff-runtime/src/test/java/io/protostuff/runtime/PolymorphicRuntimeGraphTest.java