Chad--
Were you able to work through this? FWIW, it seems like the
framework shouldn't fire "onCreate" for Controls that are deserialized
as they aren't really being created. Not sure about the
ResourceContext problem -- has the onRelease() method been called on
the Control before serialization?
Apologies for taking so long to get back to this...
Eddie
On 1/17/06, Chad Schoettger <[EMAIL PROTECTED]> wrote:
> 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());
> }
>