static void verifyGraph(HtmlDocumentRequest docRequest)
    {
        assertNotNull(docRequest);

        Document document = docRequest.document;

        assertNotNull(document);

        assertTrue(document == document.self.get());
        assertTrue(document.getNodeCount() == 2);
        assertTrue(document.getNode(0) instanceof Head);
        assertTrue(document.getNode(1) instanceof Body);

        Head head = (Head) document.getNode(0);
        assertTrue(head == head.self.get());
        assertTrue(head.parent == document);
        assertTrue(head.root == document);
        assertEquals(head.tagName, "head");

        assertTrue(head.getNodeCount() == 2);
        assertTrue(head.getNode(0) instanceof Title);
        assertTrue(head.getNode(1) instanceof Link);

        Title title = (Title) head.getNode(0);
        assertTrue(title == title.self.get());
        assertTrue(title.parent == head);
        assertTrue(title.root == document);
        assertEquals(title.tagName, "title");
        assertEquals(title.text,
                "Hello world from protostuff-runtime graph ser/deser!");

        Link link = (Link) head.getNode(1);
        assertTrue(link == link.self.get());
        assertTrue(link.parent == head);
        assertTrue(link.root == document);
        assertEquals(link.tagName, "link");
        assertEquals(link.rel, "shortcut icon");
        assertEquals(link.href, "/favicon.ico");
        assertEquals(link.type, "image/x-icon");

        Body body = (Body) document.getNode(1);
        assertTrue(body == body.self.get());
        assertTrue(body.parent == document);
        assertTrue(body.root == document);
        assertEquals(body.tagName, "body");

        assertTrue(body.getNodeCount() == 2);
        assertTrue(body.getNode(0) instanceof Div);
        assertTrue(body.getNode(1) instanceof Div);

        Div div = (Div) body.getNode(0);
        assertTrue(div == div.self.get());
        assertTrue(div.parent == body);
        assertTrue(div.root == document);
        assertEquals(div.tagName, "div");
        assertEquals(div.id, "firstDiv");
        assertEquals(div.name, "firstDiv");
        assertEquals(div.text, "TextArea");
        assertEquals("bar", div.getAttribute("foo"));
        assertTrue(div.display == Div.Display.INLINE);
        assertTrue(div.getNodeCount() == 0);

        Div anotherDiv = (Div) body.getNode(1);
        assertTrue(anotherDiv == anotherDiv.self.get());
        assertTrue(anotherDiv.parent == body);
        assertTrue(anotherDiv.root == document);
        assertEquals(anotherDiv.tagName, "div");
        assertEquals(anotherDiv.id, "secondDiv");
        assertEquals(anotherDiv.name, "secondDiv");
        assertTrue(anotherDiv.display == Div.Display.BLOCK);
        assertNull(anotherDiv.text);

        assertTrue(anotherDiv.getNodeCount() == 1);
        assertTrue(anotherDiv.getNode(0) instanceof TextArea);

        TextArea ta = (TextArea) anotherDiv.getNode(0);
        assertTrue(ta == ta.self.get());
        assertTrue(ta.parent == anotherDiv);
        assertTrue(ta.root == document);
        assertEquals(ta.tagName, "textarea");
        assertEquals(ta.id, "ta");
        assertEquals(ta.name, "ta");
        assertTrue(ta.rows == 10);
        assertTrue(ta.cols == 20);

        assertTrue(document.getNodeById("firstDiv") == div);
        assertTrue(document.getNodeById("secondDiv") == anotherDiv);
        assertTrue(document.getNodeById("ta") == ta);
    }
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