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

        HotElement hot = new HotElement(null);
        ColdElement cold = new ColdElement(hot);
        // self reference
        cold.next = cold;

        LinkedElementContainer container = new LinkedElementContainer();
        container.element = hot;

        verifyGraph(container);

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

        LinkedElementContainer containerFromByteArray = new LinkedElementContainer();
        GraphTest.mergeFrom(data, 0, data.length, containerFromByteArray,
                schema);

        verifyGraph(containerFromByteArray);

        LinkedElementContainer containerFromStream = new LinkedElementContainer();
        ByteArrayInputStream in = new ByteArrayInputStream(data);
        GraphTest.mergeFrom(in, containerFromStream, schema);

        verifyGraph(containerFromStream);
    }
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