beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chad Schoettger <chad.schoett...@gmail.com>
Subject Control serialization tests...
Date Tue, 17 Jan 2006 20:55:13 GMT
I have just started writing some controls serialization tests and have come
up with a couple of questions about the expected behavior of a control being
serialized/deserialized.

1) When a control is deserialized should it receive an 'onCreate' event?
The behavior I am seeing is that this event is not being sent to the
control.

2) When I try to serialize a control whose impl contains a reference to
ResourceContext, the serialization fails due to a 'NotSerializiable'
exception for the ResourceContextImpl class.  This doesn't seem right.

Here's the code from my test (I've also attached all relevant files) perhaps
I am not serializing the control properly (it seems like the proper method
though).  Any thoughts /comments from the list are appreciated.

     @Control
    private ControlSerialization _serializationControl;

    public void testSimpleSerialization1() throws Exception {
        assertNotNull(_serializationControl);

        _serializationControl.setControlState(6);
        _serializationControl.clearLifecycleEvents();

        // serialize the contents of the ctcc
        ObjectOutputStream oos = new ObjectOutputStream(new
FileOutputStream("sertest.tmp"));
        ControlContainerContext ccc = getControlContainerContext();
        ControlTestContainerContext ctcc = (ControlTestContainerContext)ccc;
        ctcc.writeChildren(oos);
        oos.close();

        // change the control state of the in-memory control, sanity check
        _serializationControl.setControlState(2);

        // deserialize the ctcc contents
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("
sertest.tmp"));
        ctcc.readChildren(ois);
        ois.close();

        // now find the value of the deserialized control in the ctcc
        Object[] ctrls = ctcc.toArray();
        ControlSerialization deserializedControl = null;
        for (Object c : ctrls) {
            if (c instanceof ControlSerializationBean &&
!c.equals(_serializationControl)) {
                deserializedControl = (ControlSerialization)c;
                break;
            }
        }

        assertNotNull(deserializedControl);
        assertEquals(6, deserializedControl.getControlState());
    }

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message