Package org.springframework.webflow.conversation

Examples of org.springframework.webflow.conversation.Conversation


    ExternalContextHolder.setExternalContext(null);
  }

  public void testConversationLifeCycle() {
    ExternalContextHolder.setExternalContext(new MockExternalContext());
    Conversation conversation = conversationManager.beginConversation(new ConversationParameters("test", "test",
        "test"));
    ConversationId conversationId = conversation.getId();
    assertNotNull(conversationManager.getConversation(conversationId));
    conversation.lock();
    conversation.end();
    conversation.unlock();
    try {
      conversationManager.getConversation(conversationId);
      fail("Conversation should have ben removed");
    } catch (ConversationException e) {
    }
View Full Code Here


    }
  }

  public void testNoPassivation() {
    ExternalContextHolder.setExternalContext(new MockExternalContext());
    Conversation conversation = conversationManager.beginConversation(new ConversationParameters("test", "test",
        "test"));
    conversation.lock();
    conversation.putAttribute("testAttribute", "testValue");
    ConversationId conversationId = conversation.getId();

    Conversation conversation2 = conversationManager.getConversation(conversationId);
    assertSame(conversation, conversation2);
    conversation2.lock();
    assertEquals("testValue", conversation2.getAttribute("testAttribute"));
    conversation.end();
    conversation.unlock();
    conversation2.unlock();
  }
View Full Code Here

  }

  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();
  }
View Full Code Here

  }

  public void testMaxConversations() {
    conversationManager.setMaxConversations(2);
    ExternalContextHolder.setExternalContext(new MockExternalContext());
    Conversation conversation1 = conversationManager.beginConversation(new ConversationParameters("test", "test",
        "test"));
    conversation1.lock();
    assertNotNull(conversationManager.getConversation(conversation1.getId()));
    Conversation conversation2 = conversationManager.beginConversation(new ConversationParameters("test", "test",
        "test"));
    assertNotNull(conversationManager.getConversation(conversation1.getId()));
    assertNotNull(conversationManager.getConversation(conversation2.getId()));
    Conversation conversation3 = conversationManager.beginConversation(new ConversationParameters("test", "test",
        "test"));
    try {
      conversation1.end();
      conversation1.unlock();
      conversationManager.getConversation(conversation1.getId());
      fail();
    } catch (ConversationException e) {
    }
    assertNotNull(conversationManager.getConversation(conversation2.getId()));
    assertNotNull(conversationManager.getConversation(conversation3.getId()));
  }
View Full Code Here

    private ConversationManager mockConversationManager;

    @Before
    public void setUp() {
        final Map<Object, Object> attributes = new HashMap<Object, Object>();
        final Conversation mockConversation = mock(Conversation.class);
        when(mockConversation.getId()).thenReturn(new SimpleConversationId("ABC123"));
        when(mockConversation.getAttribute(anyString())).thenAnswer(new Answer() {
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return attributes.get(invocation.getArguments()[0]);
            }
        });
        doAnswer(new Answer() {
View Full Code Here

  public FlowExecution getFlowExecution(FlowExecutionKey key) {
    if (logger.isDebugEnabled()) {
      logger.debug("Getting flow execution with key '" + key + "'");
    }
    Conversation conversation = getConversation(key);
    FlowExecutionSnapshot snapshot;
    try {
      snapshot = getSnapshotGroup(conversation).getSnapshot(getSnapshotId(key));
    } catch (SnapshotNotFoundException e) {
      throw new FlowExecutionRestorationFailureException(key, e);
View Full Code Here

    assertKeySet(flowExecution);
    if (logger.isDebugEnabled()) {
      logger.debug("Putting flow execution '" + flowExecution + "' into repository");
    }
    FlowExecutionKey key = flowExecution.getKey();
    Conversation conversation = getConversation(key);
    FlowExecutionSnapshotGroup snapshotGroup = getSnapshotGroup(conversation);
    FlowExecutionSnapshot snapshot = snapshot(flowExecution);
    if (logger.isDebugEnabled()) {
      logger.debug("Adding new snapshot to group with id " + getSnapshotId(key));
    }
View Full Code Here

  // implementing flow execution key factory

  public void updateFlowExecutionSnapshot(FlowExecution execution) {
    FlowExecutionKey key = execution.getKey();
    Conversation conversation = getConversation(key);
    getSnapshotGroup(conversation).updateSnapshot(getSnapshotId(key), snapshot(execution));
  }
View Full Code Here

    getSnapshotGroup(conversation).updateSnapshot(getSnapshotId(key), snapshot(execution));
  }

  public void removeFlowExecutionSnapshot(FlowExecution execution) {
    FlowExecutionKey key = execution.getKey();
    Conversation conversation = getConversation(key);
    getSnapshotGroup(conversation).removeSnapshot(getSnapshotId(key));
  }
View Full Code Here

    Conversation conversation = getConversation(key);
    getSnapshotGroup(conversation).removeSnapshot(getSnapshotId(key));
  }

  public void removeAllFlowExecutionSnapshots(FlowExecution execution) {
    Conversation conversation = getConversation(execution.getKey());
    getSnapshotGroup(conversation).removeAllSnapshots();
  }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.conversation.Conversation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.