}
public void testPassivation() throws Exception {
MockExternalContext externalContext = new MockExternalContext();
ExternalContextHolder.setExternalContext(externalContext);
Conversation conversation = conversationManager.beginConversation(new ConversationParameters("test", "test",
"test"));
conversation.lock();
conversation.putAttribute("testAttribute", "testValue");
ConversationId conversationId = conversation.getId();
ExternalContextHolder.setExternalContext(null);
// simulate write out of session
byte[] passiveSession = passivate(externalContext.getSessionMap());
// simulate start-up of server
conversationManager = new SessionBindingConversationManager();
String id = conversationId.toString();
conversationId = conversationManager.parseConversationId(id);
// simulate restore of session
externalContext.setSessionMap(activate(passiveSession));
ExternalContextHolder.setExternalContext(externalContext);
Conversation conversation2 = conversationManager.getConversation(conversationId);
assertNotSame(conversation, conversation2);
assertEquals("testValue", conversation2.getAttribute("testAttribute"));
conversation.end();
conversation.unlock();
}