Package org.jboss.serial.data

Examples of org.jboss.serial.data.TestParent


{
    public void testReadAndWriteObjects() throws Exception
    {
        DataContainer container = new DataContainer(true);

        TestParent myTest = new TestParent(0);
        myTest.setA(33);

        for (int i=0;i<100;i++)
        {
            myTest.map.put("key" + i,"value" + i);

        }

        Child child = new Child();
        myTest.setChild(child);
        child.setParent(myTest);

        System.out.println("MyTest(original) = " + myTest);

        TestParent myTest2 = new TestParent(0);
        myTest2.setA(34);
        myTest2.setChild(child);
        myTest2.value=myTest.value;
        myTest2.map = myTest.map;
        // This value shouldn't be serialized as the reference has already written


        ObjectOutput output = container.getOutput();
        output.writeObject(myTest);
        output.writeObject(myTest2);
        myTest2.setA(99);
        output.flush();

        ObjectInput input = container.getInput();

        TestParent obj = (TestParent)input.readObject();
        TestParent obj2 = (TestParent)input.readObject();
        System.out.println("MyTest(read) = " + obj);

        System.out.println(obj2);

        assertEquals(34,obj2.getA());

    }
View Full Code Here

TOP

Related Classes of org.jboss.serial.data.TestParent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.