Package org.springframework.webflow.engine

Examples of org.springframework.webflow.engine.ViewState


    }
  }

  public void testDispatchWithCurrentStateId() throws Exception {
    MockFlowSession session = context.getMockFlowExecutionContext().getMockActiveSession();
    session.setState(new ViewState(session.getDefinitionInternal(), "increment", new StubViewFactory()));
    action.execute(context);
    assertEquals(1, action.counter);
  }
View Full Code Here


  private Map<String, ?> 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");
View Full Code Here

    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);
View Full Code Here

  public void testStateEnteringNoSecurity() {
    SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener();
    RequestContext context = new MockRequestContext();
    Flow flow = new Flow("flow");
    ViewState state = new ViewState(flow, "view", new StubViewFactory());
    listener.stateEntering(context, state);
  }
View Full Code Here

  public void testStateEnteringWithSecurity() {
    SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener();
    RequestContext context = new MockRequestContext();
    Flow flow = new Flow("flow");
    ViewState state = new ViewState(flow, "view", new StubViewFactory());
    SecurityRule rule = getSecurityRuleAllAuthorized();
    state.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule);
    configureSecurityContext();
    listener.stateEntering(context, state);
  }
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());
View Full Code Here

    }
  }

  public void testResumeException() {
    Flow flow = new Flow("flow");
    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

    }
  }

  public void testResumeFlowExecutionException() {
    Flow flow = new Flow("flow");
    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

    }
  }

  public void testExecuteTransition() {
    Flow flow = new Flow("flow");
    ViewState state = new ViewState(flow, "view", new StubViewFactory()) {
      public void resume(RequestControlContext context) {
        context.execute(getRequiredTransition(context));
      }
    };
    state.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("finish")));
    new EndState(flow, "finish");
    MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
    FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
    execution.setListeners(listeners);
View Full Code Here

    assertEquals(1, mockListener.getTransitionExecutingCount());
  }

  public void testRequestContextManagedOnStartAndResume() {
    Flow flow = new Flow("flow");
    new ViewState(flow, "view", new StubViewFactory()) {
      public void resume(RequestControlContext context) {
        assertSame(context, RequestContextHolder.getRequestContext());
      }
    };
    FlowExecutionImpl execution = new FlowExecutionImpl(flow);
View Full Code Here

TOP

Related Classes of org.springframework.webflow.engine.ViewState

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.