mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
added persistence support for clearing ReplicatingCacheManager and ReplicatingCache; added session garbage collection upon SecurityService construction
Change-Id: I78475411ef01916678e383922d9d0bd11dfd5aec
This commit is contained in:
+29
@@ -84,4 +84,33 @@ public class SessionPersistenceTest {
|
||||
mof.removeSession(cacheName, session);
|
||||
assertTrue(dof.loadSessionsByCacheName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionExpiry() throws InterruptedException {
|
||||
final String cacheName = "shiroSessionCache";
|
||||
final String host = "myHost";
|
||||
final String id = UUID.randomUUID().toString();
|
||||
final Date start = new Date();
|
||||
final Date last = new Date();
|
||||
final long timeout = 5000l; // 5s
|
||||
final SimpleSession session = new SimpleSession();
|
||||
session.setId(id);
|
||||
session.setHost(host);
|
||||
session.setStartTimestamp(start);
|
||||
session.setLastAccessTime(last);
|
||||
session.setTimeout(timeout);
|
||||
mof.storeSession(cacheName, session);
|
||||
final Map<String, Set<Session>> sessions = dof.loadSessionsByCacheName();
|
||||
// expecting the session to be still there because the 10s haven't expired yet:
|
||||
final Session readSession = sessions.get(cacheName).iterator().next();
|
||||
assertEquals(session, readSession);
|
||||
assertEquals(id, readSession.getId());
|
||||
assertEquals(host, readSession.getHost());
|
||||
assertEquals(start, readSession.getStartTimestamp());
|
||||
assertEquals(last, readSession.getLastAccessTime());
|
||||
assertEquals(timeout, readSession.getTimeout());
|
||||
Thread.sleep(timeout);
|
||||
final Map<String, Set<Session>> sessionsWithoutExpired = dof.loadSessionsByCacheName();
|
||||
assertTrue(sessionsWithoutExpired.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user