- public void testInjectOnlyOnceAfterDeserialisation() throws Exception {
- InjectionBehavior behavior = new InjectionBehavior();
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream os = new ObjectOutputStream(bos);
- os.writeObject(behavior);
- os.flush();
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
- behavior = (InjectionBehavior)ois.readObject();
-
- behavior.beforeRender(component);
- verify(injector).inject(same(component));
+ public void testInjectOnlyOnceAfterDeserialisation() throws Exception {
+ Component component = mock(Component.class);
+ InjectionBehavior behavior = new InjectionBehavior(component);
+
+ behavior = ObjectSerializationUtils.deserialize(
+ ObjectSerializationUtils.serialize(behavior),
+ InjectionBehavior.class);
+
+ verify(injector).inject(any(Component.class));