Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestControlContext


    assertEquals(context, model.get("flowRequestContext"));
    assertNull(model.get(BindingResult.MODEL_KEY_PREFIX + "bindBean"));
  }

  public void testRenderWithBindingModel() throws Exception {
    MockRequestControlContext context = new MockRequestControlContext();
    context.setCurrentState(new ViewState(context.getRootFlow(), "test", new StubViewFactory()));
    Object 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.setConversionService(new DefaultConversionService());
    view.render();
    assertEquals(context.getFlowScope().get("bindBean"), model.get("bindBean"));
    BindingModel bm = (BindingModel) model.get(BindingResult.MODEL_KEY_PREFIX + "bindBean");
    assertNotNull(bm);
    assertEquals(null, bm.getFieldValue("stringProperty"));
    assertEquals("3", bm.getFieldValue("integerProperty"));
    assertEquals("2008-01-01", bm.getFieldValue("dateProperty"));
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());
    state.resume(context);
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
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

    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.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertFalse(context.getFlowExecutionContext().isActive());
  }
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.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
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);
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals(1, action.getExecutionCount());
    assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
    assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  }
View Full Code Here

      public void restoreReferences(Object value, RequestContext context) {
      }
    }));
    state.getTransitionSet().add(new Transition(on("submit"), to("next")));
    new ViewState(flow, "next", viewFactory);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    state.enter(context);
    assertTrue(context.getViewScope().contains("foo"));
    context = new MockRequestControlContext(context.getFlowExecutionContext());
    context.putRequestParameter("_eventId", "submit");
    state.resume(context);
    assertTrue(context.getFlowExecutionContext().isActive());
    assertEquals("next", context.getCurrentState().getId());
    assertFalse(context.getViewScope().contains("foo"));
  }
View Full Code Here

    flow.getGlobalTransitionSet().add(t);
    assertSame(t, flow.getGlobalTransitionSet().toArray()[1]);
  }

  public void testStart() {
    MockRequestControlContext context = new MockRequestControlContext(flow);
    flow.start(context, new LocalAttributeMap());
    assertEquals("Wrong start state", "myState1", context.getCurrentState().getId());
  }
View Full Code Here

    flow.start(context, new LocalAttributeMap());
    assertEquals("Wrong start state", "myState1", context.getCurrentState().getId());
  }

  public void testStartWithoutStartState() {
    MockRequestControlContext context = new MockRequestControlContext(flow);
    try {
      Flow empty = new Flow("empty");
      empty.start(context, null);
      fail("should have failed");
    } catch (IllegalStateException e) {
View Full Code Here

    }
  }

  public void testStartWithAction() {
    MockRequestControlContext context = new MockRequestControlContext(flow);
    TestAction action = new TestAction();
    flow.getStartActionList().add(action);
    flow.start(context, new LocalAttributeMap());
    assertEquals("Wrong start state", "myState1", context.getCurrentState().getId());
    assertEquals(1, action.getExecutionCount());
  }
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.