Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestControlContext


    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
  }

  public void testSetViewScope() {
    MockRequestControlContext context = new MockRequestControlContext();
    ViewState state = new ViewState(context.getRootFlow(), "view", new StubViewFactory());
    context.setCurrentState(state);
    context.getViewScope().put("foo", "bar");
    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    exp.setValue(context, "baz");
    assertEquals("baz", exp.getValue(context));
  }
View Full Code Here


    assertEquals("3", bindBean.getListProperty().get(2));
    assertFalse(bindBean.validationMethodInvoked);
  }

  public void testResumeEventBindingErrors() throws Exception {
    MockRequestControlContext context = new MockRequestControlContext();
    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("integerProperty", "bogus 1");
    context.putRequestParameter("dateProperty", "bogus 2");
    BindBean bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    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.processUserEvent();
    assertFalse(view.hasFlowEvent());
    view.render();
    assertEquals(context.getFlowScope().get("bindBean"), model.get("bindBean"));
    BindingModel bm = (BindingModel) model.get(BindingResult.MODEL_KEY_PREFIX + "bindBean");
    assertNotNull(bm);
    assertEquals("bogus 1", bm.getFieldValue("integerProperty"));
    assertEquals("bogus 2", bm.getFieldValue("dateProperty"));
  }
View Full Code Here

    exp.setValue(context, "baz");
    assertEquals("baz", exp.getValue(context));
  }

  public void testResolveViewScope() {
    MockRequestControlContext context = new MockRequestControlContext();
    ViewState state = new ViewState(context.getRootFlow(), "view", new StubViewFactory());
    context.setCurrentState(state);
    context.getViewScope().put("foo", "bar");
    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
  }
View Full Code Here

    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
  }

  public void testSetViewScope() {
    MockRequestControlContext context = new MockRequestControlContext();
    ViewState state = new ViewState(context.getRootFlow(), "view", new StubViewFactory());
    context.setCurrentState(state);
    context.getViewScope().put("foo", "bar");
    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    exp.setValue(context, "baz");
    assertEquals("baz", exp.getValue(context));
  }
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);
    context.setAlwaysRedirectOnPause(true);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.setAlwaysRedirectOnPause(true);
    context.putRequestParameter("_eventId", "submit");
    context.getFlashScope().put("foo", "bar");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    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

    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);
    context.getMockExternalContext().setAjaxRequest(true);
    state.enter(context);
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    context.getMockExternalContext().setAjaxRequest(true);
    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

        return success();
      }
    };
    t.setExecutionCriteria(new ActionTransitionCriteria(action));
    state.getTransitionSet().add(t);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    context.getFlowScope().remove("renderCalled");
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    context.getFlashScope().put("Foo", "bar");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    assertTrue(context.getExternalContext().isResponseComplete());
    assertFalse("Render 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

        return success();
      }
    };
    t.setExecutionCriteria(new ActionTransitionCriteria(action));
    state.getTransitionSet().add(t);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    context.getFlowScope().remove("renderCalled");
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    context.getFlashScope().put("foo", "bar");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    assertTrue(context.getExternalContext().isResponseComplete());
    assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
    assertTrue(context.getFlashScope().contains("foo"));
    assertEquals(StubViewFactory.USER_EVENT_STATE, context.getFlashScope().get(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.setAlwaysRedirectOnPause(false);
    context.setRedirectInSameState(true);
    context.getFlowScope().remove("renderCalled");
    context.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
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);
    context.getMockExternalContext().setAjaxRequest(true);
    context.setEmbeddedMode();
    context.setAlwaysRedirectOnPause(true);
    context.setRedirectInSameState(true);
    state.enter(context);
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
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.