Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockExternalContext


    context.setEventId("finish");
    flowExecution.resume(context);
  }

  public void testManagedFlowWithUnmanagedSubflow() {
    MockExternalContext context = new MockExternalContext();
    flowExecution.start(null, context);
    context.setEventId("notmanaged");
    flowExecution.resume(context);
  }
View Full Code Here


  protected void tearDown() throws Exception {
    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();
View Full Code Here

    } catch (ConversationException e) {
    }
  }

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

    conversation.unlock();
    conversation2.unlock();
  }

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

    conversation.unlock();
  }

  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",
View Full Code Here

    assertNotNull(conversationManager.getConversation(conversation3.getId()));
  }

  public void testCustomSessionKey() {
    conversationManager.setSessionKey("foo");
    MockExternalContext context = new MockExternalContext();
    ExternalContextHolder.setExternalContext(context);
    conversationManager.beginConversation(new ConversationParameters("test", "test", "test"));
    assertNotNull(context.getSessionMap().get("foo"));
  }
View Full Code Here

      }
    };
    FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
    factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener));
    FlowExecution execution = factory.createFlowExecution(flow);
    execution.start(null, new MockExternalContext());
    assertTrue("Should have ended", !execution.isActive());
  }
View Full Code Here

    TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler();
    handler.add(TestException.class, "end");
    flow.getExceptionHandlerSet().add(handler);
    FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow);
    try {
      execution.start(null, new MockExternalContext());
      fail("Should have failed no such state");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

  }

  public void testStateExceptionHandlingRethrow() {
    FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow);
    try {
      execution.start(null, new MockExternalContext());
      fail("Should have rethrown");
    } catch (FlowExecutionException e) {
      // expected
    }
  }
View Full Code Here

        return Flow.create(getContext().getFlowId(), getContext().getFlowAttributes());
      }
    };
    Flow flow = new FlowAssembler(builder, new MockFlowBuilderContext("flow")).assembleFlow();
    FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow);
    execution.start(null, new MockExternalContext());
    assertTrue(execution.isActive());
  }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.test.MockExternalContext

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.