public void testSessionEnd_Pc_ParentPc() { MockFlowSession parentSession = newFlowSession(true, null); MockFlowSession childSession = newFlowSession(true, parentSession); getListener().sessionStarting(requestContext, parentSession, null); getListener().sessionStarting(requestContext, childSession, null); assertCommitState(true, false); requestContext.setActiveSession(childSession); // sessionEnding is a no-op getListener().sessionEnding(requestContext, childSession, "success", null); assertSessionBound(); assertCommitState(true, false); // sessionEnded binds Parent PersistenceContext getListener().sessionEnded(requestContext, childSession, "success", null); assertSessionBound(); }
public void testSessionStarting_NoPc_ParentPc() { MockFlowSession parentSession = newFlowSession(true, null); MockFlowSession childSession = newFlowSession(false, parentSession); getListener().sessionStarting(new MockRequestContext(), parentSession, null); assertSessionBound(); assertSessionInScope(parentSession); getListener().sessionStarting(new MockRequestContext(), childSession, null); assertSessionNotBound(); assertSessionNotInScope(childSession); }
protected final void setUp() throws Exception { requestContext = new MockRequestContext(); DataSource dataSource = createDataSource(); jdbcTemplate = new JdbcTemplate(dataSource); populateDataBase(dataSource); setUpResources(dataSource); }
public void testSessionStarting_Pc_ParentPc() { MockFlowSession parentSession = newFlowSession(true, null); MockFlowSession childSession = newFlowSession(true, parentSession); getListener().sessionStarting(new MockRequestContext(), parentSession, null); assertSessionBound(); assertSessionInScope(parentSession); getListener().sessionStarting(new MockRequestContext(), childSession, null); assertSessionBound(); assertSessionInScope(childSession); assertSame("Parent PersistenceContext should be re-used", parentSession.getScope().get("persistenceContext"), childSession.getScope().get("persistenceContext")); }
public void testSessionEnd_Pc_NoParentPc() { MockFlowSession parentSession = newFlowSession(false, null); MockFlowSession childSession = newFlowSession(true, parentSession); getListener().sessionStarting(requestContext, parentSession, null); getListener().sessionStarting(requestContext, childSession, null); assertCommitState(true, false); requestContext.setActiveSession(childSession); // Session ending commits, unbinds/closes PersistenceContext getListener().sessionEnding(requestContext, childSession, "success", null); assertSessionNotBound(); // sessionEnded has no effect getListener().sessionEnded(requestContext, childSession, "success", null); assertSessionNotBound(); assertCommitState(false, true); }
private void assertSessionInScope(FlowSession session) { assertTrue(session.getScope().contains("persistenceContext")); }
private void assertSessionNotInScope(FlowSession session) { assertFalse(session.getScope().contains("persistenceContext")); }