Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestControlContext


  public void testEnterViewStateWithAlwaysRedirectOnPause() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    context.getFlashScope().put("foo", "bar");
    context.setAlwaysRedirectOnPause(true);
    state.enter(context);
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertTrue(context.getFlashScope().contains("foo"));
  }
View Full Code Here


  public void testResumeViewStateForRefresh() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.getFlashScope().put("foo", "bar");
    state.resume(context);
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getExternalContext().isResponseComplete());
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertFalse(context.getFlashScope().contains("foo"));
  }
View Full Code Here

    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.getTransitionSet().add(new Transition(on("submit"), to("finish")));
    new EndState(flow, "finish");
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.getFlowScope().remove("renderCalled");
    context.getFlashScope().put("foo", "bar");
    context.getExternalContext().recordResponseComplete();
    state.resume(context);
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertFalse(context.getFlashScope().contains("foo"));
  }
View Full Code Here

      public void restoreReferences(Object value, RequestContext context) {
        ((TestBean) value).datum1 = "Restored";
      }
    }));
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    state.resume(context);
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertEquals("Restored", ((TestBean) context.getViewScope().get("foo")).datum1);
  }
View Full Code Here

    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.getTransitionSet().add(new Transition(on("submit"), to("finish")));
    EndState end = new EndState(flow, "finish");
    TestAction testAction = new TestAction();
    end.setFinalResponseAction(testAction);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getExternalContext().isResponseComplete());
    assertFalse(context.getFlowExecutionContext().isActive());
    assertTrue(testAction.isExecuted());
  }
View Full Code Here

    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.getTransitionSet().add(new Transition(on("submit"), to("next")));
    ViewState next = new ViewState(flow, "next", viewFactory);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    context.setAlwaysRedirectOnPause(true);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getExternalContext().isResponseComplete());
    assertTrue(context.getFlowExecutionContext().isActive());
    assertSame(next, context.getCurrentState());
    assertTrue(context.getFlowScope().contains("saveStateCalled"));
  }
View Full Code Here

    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.getTransitionSet().add(new Transition(on("submit"), to("next")));
    ViewState next = new ViewState(flow, "next", viewFactory);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    context.setAlwaysRedirectOnPause(false);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getExternalContext().isResponseComplete());
    assertTrue(context.getFlowExecutionContext().isActive());
    assertSame(next, context.getCurrentState());
    assertFalse(context.getFlowScope().contains("saveStateCalled"));
  }
View Full Code Here

    ViewState state = new ViewState(flow, "viewState", viewFactory);
    Transition t = new Transition(on("submit"), null);
    TestAction action = new TestAction();
    t.setExecutionCriteria(new ActionTransitionCriteria(action));
    state.getTransitionSet().add(t);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.getFlowScope().remove("renderCalled");
    context.putRequestParameter("_eventId", "submit");
    context.getFlashScope().put("foo", "bar");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    assertTrue(context.getExternalContext().isResponseComplete());
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertFalse(context.getFlashScope().contains("foo"));
    assertFalse(context.getFlashScope().contains(View.USER_EVENT_STATE_ATTRIBUTE));
  }
View Full Code Here

    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    Transition t = new Transition(on("submit"), null);
    state.getTransitionSet().add(t);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.getFlowScope().remove("renderCalled");
    context.putRequestParameter("_eventId", "submit");
    context.getMockExternalContext().setResponseAllowed(false);
    context.getFlashScope().put("foo", "bar");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertTrue(context.getExternalContext().isResponseComplete());
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertEquals(StubViewFactory.USER_EVENT_STATE, context.getFlashScope().get(View.USER_EVENT_STATE_ATTRIBUTE));
    assertTrue(context.getFlashScope().contains("foo"));
  }
View Full Code Here

    };
  }

  public void testStateEnter() {
    assertEquals("myState", state.getId());
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertEquals(state, context.getCurrentState());
    assertTrue(entered);
  }
View Full Code Here

TOP

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

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.