Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockRequestContext


    listener.transitionExecuting(context, transition);
  }

  public void testTransitionExecutingWithSecurity() {
    SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener();
    RequestContext context = new MockRequestContext();
    Transition transition = new Transition(new DefaultTargetStateResolver("target"));
    SecurityRule rule = getSecurityRuleAnyAuthorized();
    ((LocalAttributeMap) transition.getAttributes()).put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule);
    configureSecurityContext();
    listener.transitionExecuting(context, transition);
View Full Code Here


    HibernateTransactionManager tm = new HibernateTransactionManager(sessionFactory);
    hibernateListener = new HibernateFlowExecutionListener(sessionFactory, tm);
  }

  public void testSameSession() {
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    // Session created and bound to conversation
    final Session hibSession = (Session) flowSession.getScope().get("persistenceContext");
    assertNotNull("Should have been populated", hibSession);
View Full Code Here

    hibernateListener.paused(context);
    assertSessionNotBound();
  }

  public void testFlowNotAPersistenceContext() {
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    hibernateListener.sessionStarting(context, flowSession, null);
    assertSessionNotBound();
  }
View Full Code Here

    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");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = new TestBean("Keith Donald");
    hibernateTemplate.save(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");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

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

  }

  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");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = new TestBean("Keith Donald");
    hibernateTemplate.save(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");
    hibernateListener.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");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean1 = new TestBean("Keith Donald");
    hibernateTemplate.save(bean1);
    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();
    hibernateListener.exceptionThrown(context, new FlowExecutionException("foo", "bar", "test"));
    assertSessionNotBound();
View Full Code Here

    hibernateListener.exceptionThrown(context, new FlowExecutionException("foo", "bar", "test"));
    assertSessionNotBound();
  }

  public void testLazyInitializedCollection() {
    MockRequestContext context = new MockRequestContext();
    MockFlowSession flowSession = new MockFlowSession();
    flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
    hibernateListener.sessionStarting(context, flowSession, null);
    context.setActiveSession(flowSession);
    assertSessionBound();

    TestBean bean = (TestBean) hibernateTemplate.get(TestBean.class, Long.valueOf(0));
    assertFalse("addresses should not be initialized", Hibernate.isInitialized(bean.getAddresses()));
    hibernateListener.paused(context);
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.