}
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"));
hibernateListener.paused(context);
assertSessionNotBound();
hibernateListener.resuming(context);
TestBean bean2 = new TestBean("Keith Donald");
hibernateTemplate.save(bean2);
assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
assertSessionBound();
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
flowSession.setState(endState);
hibernateListener.sessionEnded(context, flowSession, "success", null);
assertEquals("Table should only have three rows", 3, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
assertFalse(flowSession.getScope().contains("hibernate.session"));
assertSessionNotBound();
assertFalse(flowSession.getScope().contains("hibernate.session"));
}