}
assertEquals(3, iterationCount);
}
public final void testMessagesAreSerializable() throws Exception {
DefaultMessageContext messageContext = new DefaultMessageContext();
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
EasyMock.replay(new Object[] { this.requestContext });
this.facesContext.addMessage("TESTID", new FacesMessage("summary1"));
FacesMessage sourceMessage = this.facesContext.getMessages("TESTID").next();
sourceMessage.setSummary("summary2");
sourceMessage.setSeverity(FacesMessage.SEVERITY_FATAL);
Serializable mementoWrite = messageContext.createMessagesMemento();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(mementoWrite);
oos.flush();
byte[] byteArray = bos.toByteArray();
oos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(bis);
Serializable mementoRead = (Serializable) ois.readObject();
ois.close();
messageContext.restoreMessages(mementoRead);
EasyMock.reset(new Object[] { this.requestContext });
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
EasyMock.replay(new Object[] { this.requestContext });
FacesContext newFacesContext = new FlowFacesContext(this.requestContext, this.jsf.facesContext());