Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestControlContext


    subflowState = new SubflowState(parentFlow, "subflow", new AbstractGetValueExpression() {
      public Object getValue(Object context) throws EvaluationException {
        return subflow;
      }
    });
    context = new MockRequestControlContext(parentFlow);
    context.setCurrentState(subflowState);
  }
View Full Code Here


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

      }

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

  public void testEnterViewStateWithLocalRedirect() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.setRedirect(Boolean.TRUE);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
View Full Code Here

  public void testEnterViewStateWithNoLocalRedirect() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.setRedirect(Boolean.FALSE);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertTrue("Render called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
View Full Code Here

    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    ViewState state = new ViewState(flow, "viewState", viewFactory);
    state.setRedirect(Boolean.TRUE);
    state.setPopup(true);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertTrue(context.getMockExternalContext().getRedirectInPopup());
  }
View Full Code Here

  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.setAlwaysRedirectOnPause(true);
    state.enter(context);
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
View Full Code Here

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

  private boolean renderCalled;

  private Map model;

  public void testRender() throws Exception {
    MockRequestControlContext context = new MockRequestControlContext();
    context.setCurrentState(new ViewState(context.getRootFlow(), "test", new StubViewFactory()));
    context.getRequestScope().put("foo", "bar");
    context.getFlowScope().put("bar", "baz");
    context.getFlowScope().put("bindBean", new BindBean());
    context.getConversationScope().put("baz", "boop");
    context.getFlashScope().put("boop", "bing");
    context.getMockExternalContext().setCurrentUser("Keith");
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
    context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1"));
    org.springframework.web.servlet.View mvcView = new MockView();
    AbstractMvcView view = new MockMvcView(mvcView, context);
    view.setExpressionParser(DefaultExpressionParserFactory.getExpressionParser());
    view.render();
    assertTrue(renderCalled);
View Full Code Here

    assertEquals("/mockFlow?execution=c1v1", model.get("flowExecutionUrl"));
    assertNull(model.get(BindingResult.MODEL_KEY_PREFIX + "bindBean"));
  }

  public void testRenderNoKey() throws Exception {
    MockRequestControlContext context = new MockRequestControlContext();
    EndState endState = new EndState(context.getRootFlow(), "end");
    endState.setFinalResponseAction(new ViewFactoryActionAdapter(new StubViewFactory()));
    context.setCurrentState(endState);
    context.getRequestScope().put("foo", "bar");
    context.getFlowScope().put("bar", "baz");
    context.getFlowScope().put("bindBean", new BindBean());
    context.getConversationScope().put("baz", "boop");
    context.getFlashScope().put("boop", "bing");
    context.getMockExternalContext().setCurrentUser("Keith");
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
    org.springframework.web.servlet.View mvcView = new MockView();
    AbstractMvcView view = new MockMvcView(mvcView, context);
    view.setExpressionParser(DefaultExpressionParserFactory.getExpressionParser());
    view.render();
    assertTrue(renderCalled);
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.