Package org.springframework.webflow.execution

Examples of org.springframework.webflow.execution.TestAction


  public void testResumeViewStateForEventStateNotExitedNonAjax() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    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


  public void testResumeViewStateForEventStateNotExitedAjax() {
    Flow flow = new Flow("myFlow");
    StubViewFactory viewFactory = new StubViewFactory();
    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 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

    flow.resume(context);
    assertTrue(context.getFlowScope().getBoolean("renderCalled").booleanValue());
  }

  public void testEnd() {
    TestAction action = new TestAction();
    flow.getEndActionList().add(action);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    LocalAttributeMap sessionOutput = new LocalAttributeMap();
    flow.end(context, "finish", sessionOutput);
    assertEquals(1, action.getExecutionCount());
  }
View Full Code Here

    new EndState(flow, "finish");
    context = new MockRequestControlContext(flow);
  }

  public void testExecuteSingleAction() {
    state.getActionList().add(new TestAction());
    state.getTransitionSet().add(new Transition(on("success"), to("finish")));
    state.enter(context);
    assertEquals(1, ((TestAction) state.getActionList().get(0)).getExecutionCount());
  }
View Full Code Here

      // expected
    }
  }

  public void testExecuteActionCannotHandleResultEvent() {
    state.getActionList().add(new TestAction());
    try {
      state.enter(context);
      fail("Should've failed");
    } catch (NoMatchingTransitionException e) {
      assertEquals(1, ((TestAction) state.getActionList().get(0)).getExecutionCount());
View Full Code Here

      assertEquals(1, ((TestAction) state.getActionList().get(0)).getExecutionCount());
    }
  }

  public void testExecuteActionChain() {
    state.getActionList().add(new TestAction("not mapped result"));
    state.getActionList().add(new TestAction(null));
    state.getActionList().add(new TestAction(""));
    state.getActionList().add(new TestAction("success"));
    state.getTransitionSet().add(new Transition(on("success"), to("finish")));
    state.enter(context);
    Action[] actions = state.getActionList().toArray();
    for (int i = 0; i < actions.length; i++) {
      TestAction action = (TestAction) actions[i];
      assertEquals(1, action.getExecutionCount());
    }
  }
View Full Code Here

  }

  public void testResolveAction() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getBeanFactory().registerSingleton("action", new TestAction());
    context.getRootFlow().setApplicationContext(ac);
    Expression exp = parser.parseExpression("action", new FluentParserContext().evaluate(RequestContext.class));
    assertSame(ac.getBean("action"), exp.getValue(context));
  }
View Full Code Here

  public void testResolveSpringBean() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getBeanFactory().registerSingleton("testBean", new TestBean());
    ac.getBeanFactory().registerSingleton("action", new TestAction());
    ac.getBeanFactory().registerSingleton("multiAction", new FormAction(TestBean.class));
    context.getRootFlow().setApplicationContext(ac);
    context.getConversationScope().put("foo", "bar");
    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
View Full Code Here

  public void testResolveAction() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getBeanFactory().registerSingleton("testBean", new TestBean());
    ac.getBeanFactory().registerSingleton("action", new TestAction());
    context.getRootFlow().setApplicationContext(ac);
    Expression exp = parser.parseExpression("action", new FluentParserContext().evaluate(RequestContext.class));
    assertSame(ac.getBean("action"), exp.getValue(context));
  }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.execution.TestAction

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.