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

        LinkedNode first = new LinkedNode("first", null);
        LinkedNode second = new LinkedNode("second", first);
        LinkedNode third = new LinkedNode("third", second);
        // self reference
        third.next = third;

        LinkedNodeContainer container = new LinkedNodeContainer();
        container.node = first;

        verifyGraph(container);

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

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

        verifyGraph(containerFromByteArray);

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

        verifyGraph(containerFromStream);
    }
Test ser/deser of graph objects (references and cyclic dependencies) with runtime schemas.

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