You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by Eddie O'Neil <ek...@gmail.com> on 2006/02/15 08:23:55 UTC

Re: Control serialization tests...

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 <ch...@gmail.com> 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());
>      }
>

Re: Control serialization tests...

Posted by Chad Schoettger <ch...@gmail.com>.
It was user error, I wasn't ending the control context before serialization
in my test case, once I did that the test works as expected.

 - Chad

On 2/15/06, Eddie O'Neil <ek...@gmail.com> wrote:
>
> 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 <ch...@gmail.com> 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());
> >      }
> >
>