Set<ApplicationContext> applicationContextSet =
SpringApplicationContextProvider.getApplicationContextSet();
Iterator<ApplicationContext> i = applicationContextSet.iterator();
ApplicationContext applicationContext1 = i.next();
ApplicationContext applicationContext2 = i.next();
SessionRegistry sessionRegistry1 = applicationContext1.getBean(SessionRegistry.class);
SessionRegistry sessionRegistry2 = applicationContext2.getBean(SessionRegistry.class);
SpringSecuritySession sss = login(null);
request("hello.jsp", serverPort1, sss.cookieStore);
String sessionId = sss.getSessionId();
String hazelcastSessionId = sss.getHazelcastSessionId();
assertTrue(
"Native session must not exist in both Spring session registry of Node-1 and Node-2 after login",
sessionRegistry1.getSessionInformation(sessionId) == null &&
sessionRegistry2.getSessionInformation(sessionId) == null);
assertTrue(
"Hazelcast session must exist locally in one of the Spring session registry of Node-1 and Node-2 after login",
sessionRegistry1.getSessionInformation(hazelcastSessionId) != null ||
sessionRegistry2.getSessionInformation(hazelcastSessionId) != null);
logout(sss);
assertTrue(
"Native session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
sessionRegistry1.getSessionInformation(sessionId) == null &&
sessionRegistry2.getSessionInformation(sessionId) == null);
assertTrue(
"Hazelcast session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
sessionRegistry1.getSessionInformation(hazelcastSessionId) == null &&
sessionRegistry2.getSessionInformation(hazelcastSessionId) == null);
}