public void testReference() throws Exception
    {
        Foo fooCompare = newFoo();

        // verify
        checkReference(fooCompare);

        byte[] data = toByteArray(fooCompare, Foo.getSchema());

        // from byte array

        Foo fooFromByteArray = new Foo();

        mergeFrom(data, 0, data.length, fooFromByteArray, Foo.getSchema());

        SerializableObjects.assertEquals(fooCompare, fooFromByteArray);

        // verify parsed message
        checkReference(fooFromByteArray);

        // from inputstream

        Foo fooFromStream = new Foo();

        ByteArrayInputStream in = new ByteArrayInputStream(data);

        mergeFrom(in, fooFromStream, Foo.getSchema());

        SerializableObjects.assertEquals(fooCompare, fooFromStream);

        // verify parsed message
        checkReference(fooFromStream);
    }
Test ser/deser of graph objects (references and cyclic dependencies).

@author David Yu
@created Dec 10, 2010
protostuff-core/src/test/java/io/protostuff/GraphTest.java