Package org.springframework.webflow.execution

Examples of org.springframework.webflow.execution.MockFlowExecutionListener


public class FlowExecutionImplTests extends TestCase {

  public void testStartAndEnd() {
    Flow flow = new Flow("flow");
    new EndState(flow, "end");
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    MockExternalContext context = new MockExternalContext();
    assertFalse(execution.hasStarted());
    execution.start(null, context);
    assertTrue(execution.hasStarted());
    assertFalse(execution.isActive());
    assertEquals(1, mockListener.getRequestsSubmittedCount());
    assertEquals(1, mockListener.getRequestsProcessedCount());
    assertEquals(1, mockListener.getSessionCreatingCount());
    assertEquals(1, mockListener.getSessionStartingCount());
    assertEquals(1, mockListener.getSessionStartedCount());
    assertEquals(1, mockListener.getStateEnteringCount());
    assertEquals(1, mockListener.getStateEnteredCount());
    assertEquals(1, mockListener.getSessionEndingCount());
    assertEquals(1, mockListener.getSessionEndedCount());
    assertEquals(0, mockListener.getEventSignaledCount());
    assertEquals(0, mockListener.getTransitionExecutingCount());
    assertEquals(0, mockListener.getPausedCount());
    assertEquals(0, mockListener.getResumingCount());
    assertEquals(0, mockListener.getExceptionThrownCount());
    assertEquals(0, mockListener.getFlowNestingLevel());
  }
View Full Code Here


    new State(flow, "state") {
      protected void doEnter(RequestControlContext context) throws FlowExecutionException {
        // no op
      }
    };
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    assertTrue(execution.isActive());
    assertEquals(1, mockListener.getPausedCount());
  }
View Full Code Here

    new State(flow, "state") {
      protected void doEnter(RequestControlContext context) throws FlowExecutionException {
        // no op
      }
    };
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener() {
      public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) {
        super.sessionStarting(context, session, input);
        assertNotNull(input);
      }
    };
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    assertTrue(execution.isActive());
    assertEquals(1, mockListener.getPausedCount());
  }
View Full Code Here

  }

  public void testResume() {
    Flow flow = new Flow("flow");
    new ViewState(flow, "view", new StubViewFactory());
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    execution.setKeyFactory(new MockFlowExecutionKeyFactory());
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    context = new MockExternalContext();
    execution.resume(context);
    assertEquals(1, mockListener.getResumingCount());
    assertEquals(2, mockListener.getPausedCount());
  }
View Full Code Here

    new State(flow, "state") {
      protected void doEnter(RequestControlContext context) throws FlowExecutionException {
        // no-op
      }
    };
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    context = new MockExternalContext();
    try {
      execution.resume(context);
      assertEquals(1, mockListener.getResumingCount());
      fail("Should have failed");
    } catch (FlowExecutionException e) {

    }
  }
View Full Code Here

    ViewState state = new ViewState(flow, "view", new StubViewFactory()) {
      public void resume(RequestControlContext context) {
        throw new IllegalStateException("Oops");
      }
    };
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    execution.setKeyFactory(new MockFlowExecutionKeyFactory());
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    context = new MockExternalContext();
    try {
      execution.resume(context);
    } catch (FlowExecutionException e) {
      assertEquals(flow.getId(), e.getFlowId());
      assertEquals(state.getId(), e.getStateId());
      assertEquals(1, mockListener.getResumingCount());
      assertEquals(2, mockListener.getPausedCount());
    }
  }
View Full Code Here

    ViewState state = new ViewState(flow, "view", new StubViewFactory()) {
      public void resume(RequestControlContext context) {
        throw new FlowExecutionException("flow", "view", "oops");
      }
    };
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    execution.setKeyFactory(new MockFlowExecutionKeyFactory());
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    context = new MockExternalContext();
    try {
      execution.resume(context);
    } catch (FlowExecutionException e) {
      assertEquals(flow.getId(), e.getFlowId());
      assertEquals(state.getId(), e.getStateId());
      assertEquals(1, mockListener.getResumingCount());
      assertEquals(2, mockListener.getPausedCount());
    }
  }
View Full Code Here

        context.execute(getRequiredTransition(context));
      }
    };
    state.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("finish")));
    EndState end = new EndState(flow, "finish");
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    execution.setKeyFactory(new MockFlowExecutionKeyFactory());
    MockExternalContext context = new MockExternalContext();
    execution.start(null, context);
    assertEquals(0, mockListener.getTransitionExecutingCount());
    execution.resume(context);
    assertTrue(execution.hasEnded());
    assertEquals(1, mockListener.getTransitionExecutingCount());
  }
View Full Code Here

public class FlowExecutionImplTests extends TestCase {

  public void testStartAndEnd() {
    Flow flow = new Flow("flow");
    new EndState(flow, "end");
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
    MockExternalContext context = new MockExternalContext();
    assertFalse(execution.hasStarted());
    execution.start(null, context);
    assertTrue(execution.hasStarted());
    assertFalse(execution.isActive());
    assertTrue(execution.hasEnded());
    try {
      execution.getActiveSession();
      fail("should have failed");
    } catch (IllegalStateException e) {

    }
    assertEquals(1, mockListener.getRequestsSubmittedCount());
    assertEquals(1, mockListener.getRequestsProcessedCount());
    assertEquals(1, mockListener.getSessionCreatingCount());
    assertEquals(1, mockListener.getSessionStartingCount());
    assertEquals(1, mockListener.getSessionStartedCount());
    assertEquals(1, mockListener.getStateEnteringCount());
    assertEquals(1, mockListener.getStateEnteredCount());
    assertEquals(1, mockListener.getSessionEndingCount());
    assertEquals(1, mockListener.getSessionEndedCount());
    assertEquals(0, mockListener.getEventSignaledCount());
    assertEquals(0, mockListener.getTransitionExecutingCount());
    assertEquals(0, mockListener.getPausedCount());
    assertEquals(0, mockListener.getResumingCount());
    assertEquals(0, mockListener.getExceptionThrownCount());
    assertEquals(0, mockListener.getFlowNestingLevel());
  }
View Full Code Here

  }

  public void testStartAndEndSavedMessages() {
    Flow flow = new Flow("flow");
    new EndState(flow, "end");
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener() {
      public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) {
        super.sessionStarting(context, session, input);
        context.getMessageContext().addMessage(new MessageBuilder().source("foo").defaultText("bar").build());
      }
    };
View Full Code Here

TOP

Related Classes of org.springframework.webflow.execution.MockFlowExecutionListener

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.