import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.wamblee.general.ObjectSerializationUtils;
import org.wamblee.inject.Injector;
import org.wamblee.inject.InjectorBuilder;
import org.wamblee.inject.InjectorFactory;
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 = ObjectSerializationUtils.deserialize(ObjectSerializationUtils.serialize(behavior), InjectionBehavior.class);
+
behavior.beforeRender(component);
verify(injector).inject(same(component));
reset(injector);