Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestContext


    assertSessionNotBound();
  }

  public void testFlowCommitsInSingleRequest() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    jpaListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = new TestBean(1, "Keith Donald");
    jpaTemplate.persist(bean);
    assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
View Full Code Here


    assertFalse(flowSession.getScope().contains("hibernate.session"));
  }

  public void testFlowCommitsAfterMultipleRequests() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    jpaListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean1 = new TestBean(1, "Keith Donald");
    jpaTemplate.persist(bean1);
    assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
View Full Code Here

    assertFalse(flowSession.getScope().contains("hibernate.session"));
  }

  public void testCancelEndState() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    jpaListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = new TestBean(1, "Keith Donald");
    jpaTemplate.persist(bean);
    assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
View Full Code Here

    assertFalse(flowSession.getScope().contains("hibernate.session"));
  }

  public void testNoCommitAttributeSetOnEndState() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    jpaListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel");
    flowSession.setState(endState);

View Full Code Here

    assertFalse(flowSession.getScope().contains("hibernate.session"));
  }

  public void testExceptionThrown() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    jpaListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = new TestBean(1, "Keith Donald");
    jpaTemplate.persist(bean);
    assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
View Full Code Here

  }

  public void testExceptionThrownWithNothingBound() {
    assertEquals("Table should only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    assertSessionNotBound();
    jpaListener.exceptionThrown(context, new FlowExecutionException("foo", "bar", "test"));
    assertSessionNotBound();
View Full Code Here

    Action[] actions = new Action[] { actionMock };
    tested = new CompositeAction(actions);
  }

  public void testDoExecute() throws Exception {
    MockRequestContext mockRequestContext = new MockRequestContext();
    LocalAttributeMap attributes = new LocalAttributeMap();
    attributes.put("some key", "some value");
    EasyMock.expect(actionMock.execute(mockRequestContext)).andReturn(new Event(this, "some event", attributes));
    EasyMock.replay(new Object[] { actionMock });
    Event result = tested.doExecute(mockRequestContext);
View Full Code Here

    assertEquals(1, result.getAttributes().size());
  }

  public void testDoExecuteWithError() throws Exception {
    tested.setStopOnError(true);
    MockRequestContext mockRequestContext = new MockRequestContext();
    EasyMock.expect(actionMock.execute(mockRequestContext)).andReturn(new Event(this, "error"));
    EasyMock.replay(new Object[] { actionMock });
    Event result = tested.doExecute(mockRequestContext);
    EasyMock.verify(new Object[] { actionMock });
    assertEquals("error", result.getId());
View Full Code Here

    assertEquals("error", result.getId());
  }

  public void testDoExecuteWithNullResult() throws Exception {
    tested.setStopOnError(true);
    MockRequestContext mockRequestContext = new MockRequestContext();
    EasyMock.expect(actionMock.execute(mockRequestContext)).andReturn(null);
    EasyMock.replay(new Object[] { actionMock });
    Event result = tested.doExecute(mockRequestContext);
    EasyMock.verify(new Object[] { actionMock });
    assertEquals("Expecting success since no check is performed if null result,", "success", result.getId());
View Full Code Here

    }, new Action() {
      public Event execute(RequestContext context) throws Exception {
        return new Event(this, "bar");
      }
    } });
    assertEquals("Result of last executed action should be returned", "bar", ca.execute(new MockRequestContext())
        .getId());
  }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.test.MockRequestContext

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.