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

        ClubFounder founder = new ClubFounder();
        founder.setName("some_glee_club_founder");

        Club gleeClub = new Club();
        gleeClub.setName("glee");

        founder.setClub(gleeClub);

        addPartnerStudentTo(gleeClub, "jake");

        // cyclic
        Student john = new Student();
        john.setName("john");
        john.addClub(gleeClub);
        gleeClub.addStudent(john);

        Student jane = new Student();
        jane.setName("jane");
        jane.addClub(gleeClub);
        gleeClub.addStudent(jane);

        // check that our scenario is coded correctly.
        checkLinks(founder);

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

        // from byte array

        ClubFounder founderFromByteArray = new ClubFounder();
        GraphTest.mergeFrom(data, 0, data.length, founderFromByteArray, schema);

        // verify parsed message
        checkLinks(founderFromByteArray);

        // from inputstream

        ClubFounder founderFromStream = new ClubFounder();
        ByteArrayInputStream in = new ByteArrayInputStream(data);
        GraphTest.mergeFrom(in, founderFromStream, schema);

        // verify parsed message
        checkLinks(founderFromStream);
    }
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