SEC-243: SessionRegistry.getAllSessions() now accepts an "includeExpiredSessions" argument.
This commit is contained in:
parent
0648c65b0b
commit
22aa0e898f
|
@ -88,7 +88,7 @@ public class SessionRegistryImplTests extends TestCase {
|
||||||
.getLastRequest());
|
.getLastRequest());
|
||||||
|
|
||||||
// Retrieve existing session by principal
|
// Retrieve existing session by principal
|
||||||
assertEquals(1, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(1, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
|
|
||||||
// Sleep to ensure SessionRegistryImpl will update time
|
// Sleep to ensure SessionRegistryImpl will update time
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -102,14 +102,14 @@ public class SessionRegistryImplTests extends TestCase {
|
||||||
|
|
||||||
// Check it retrieves correctly when looked up via principal
|
// Check it retrieves correctly when looked up via principal
|
||||||
assertEquals(retrieved,
|
assertEquals(retrieved,
|
||||||
sessionRegistry.getAllSessions(principal)[0].getLastRequest());
|
sessionRegistry.getAllSessions(principal, false)[0].getLastRequest());
|
||||||
|
|
||||||
// Clear session information
|
// Clear session information
|
||||||
sessionRegistry.removeSessionInformation(sessionId);
|
sessionRegistry.removeSessionInformation(sessionId);
|
||||||
|
|
||||||
// Check attempts to retrieve cleared session return null
|
// Check attempts to retrieve cleared session return null
|
||||||
assertNull(sessionRegistry.getSessionInformation(sessionId));
|
assertNull(sessionRegistry.getSessionInformation(sessionId));
|
||||||
assertNull(sessionRegistry.getAllSessions(principal));
|
assertNull(sessionRegistry.getAllSessions(principal, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTwoSessionsOnePrincipalExpiring() throws Exception {
|
public void testTwoSessionsOnePrincipalExpiring() throws Exception {
|
||||||
|
@ -120,15 +120,15 @@ public class SessionRegistryImplTests extends TestCase {
|
||||||
|
|
||||||
// Register new Session
|
// Register new Session
|
||||||
sessionRegistry.registerNewSession(sessionId1, principal);
|
sessionRegistry.registerNewSession(sessionId1, principal);
|
||||||
assertEquals(1, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(1, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
assertEquals(sessionId1,
|
assertEquals(sessionId1,
|
||||||
sessionRegistry.getAllSessions(principal)[0].getSessionId());
|
sessionRegistry.getAllSessions(principal, false)[0].getSessionId());
|
||||||
|
|
||||||
// Register new Session
|
// Register new Session
|
||||||
sessionRegistry.registerNewSession(sessionId2, principal);
|
sessionRegistry.registerNewSession(sessionId2, principal);
|
||||||
assertEquals(2, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(2, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
assertEquals(sessionId2,
|
assertEquals(sessionId2,
|
||||||
sessionRegistry.getAllSessions(principal)[1].getSessionId());
|
sessionRegistry.getAllSessions(principal, false)[1].getSessionId());
|
||||||
|
|
||||||
// Expire one session
|
// Expire one session
|
||||||
SessionInformation session = sessionRegistry.getSessionInformation(sessionId2);
|
SessionInformation session = sessionRegistry.getSessionInformation(sessionId2);
|
||||||
|
@ -147,25 +147,25 @@ public class SessionRegistryImplTests extends TestCase {
|
||||||
|
|
||||||
// Register new Session
|
// Register new Session
|
||||||
sessionRegistry.registerNewSession(sessionId1, principal);
|
sessionRegistry.registerNewSession(sessionId1, principal);
|
||||||
assertEquals(1, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(1, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
assertEquals(sessionId1,
|
assertEquals(sessionId1,
|
||||||
sessionRegistry.getAllSessions(principal)[0].getSessionId());
|
sessionRegistry.getAllSessions(principal, false)[0].getSessionId());
|
||||||
|
|
||||||
// Register new Session
|
// Register new Session
|
||||||
sessionRegistry.registerNewSession(sessionId2, principal);
|
sessionRegistry.registerNewSession(sessionId2, principal);
|
||||||
assertEquals(2, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(2, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
assertEquals(sessionId2,
|
assertEquals(sessionId2,
|
||||||
sessionRegistry.getAllSessions(principal)[1].getSessionId());
|
sessionRegistry.getAllSessions(principal, false)[1].getSessionId());
|
||||||
|
|
||||||
// Clear session information
|
// Clear session information
|
||||||
sessionRegistry.removeSessionInformation(sessionId1);
|
sessionRegistry.removeSessionInformation(sessionId1);
|
||||||
assertEquals(1, sessionRegistry.getAllSessions(principal).length);
|
assertEquals(1, sessionRegistry.getAllSessions(principal, false).length);
|
||||||
assertEquals(sessionId2,
|
assertEquals(sessionId2,
|
||||||
sessionRegistry.getAllSessions(principal)[0].getSessionId());
|
sessionRegistry.getAllSessions(principal, false)[0].getSessionId());
|
||||||
|
|
||||||
// Clear final session
|
// Clear final session
|
||||||
sessionRegistry.removeSessionInformation(sessionId2);
|
sessionRegistry.removeSessionInformation(sessionId2);
|
||||||
assertNull(sessionRegistry.getSessionInformation(sessionId2));
|
assertNull(sessionRegistry.getSessionInformation(sessionId2));
|
||||||
assertNull(sessionRegistry.getAllSessions(principal));
|
assertNull(sessionRegistry.getAllSessions(principal, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue