private void standaloneWarRedeployTest(boolean restartCache)
throws Exception
{
++testCount;
String passDir = getPassivationDir(testCount, 1);
JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, true, passDir, false, false, null, caches);
PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 3, 1);
jbcm.init("test.war", webMetaData);
jbcm.start();
assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
// Set up a session
createAndUseSession(jbcm, "1", true, true);
assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
// And a 2nd
createAndUseSession(jbcm, "2", true, true);
assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 2, jbcm.getLocalActiveSessionCount());
assertEquals("Created session count correct", 2, jbcm.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
// Sleep past minIdleTime
SessionTestUtil.sleepThread(1100);
assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
createAndUseSession(jbcm, "3", true, true);
assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 2, jbcm.getLocalActiveSessionCount());
assertEquals("Created session count correct", 3, jbcm.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
jbcm.stop();
if (restartCache)
{
cache.stop();
cache.destroy();
caches.remove(cache);
passDir = getPassivationDir(testCount, 1);
jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, caches);
}
else
{
jbcm = SessionTestUtil.createManager("test" + testCount, 5, cache, null);
}
jbcm.init("test.war", webMetaData);
jbcm.start();
assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 0, jbcm.getLocalActiveSessionCount());
assertEquals("Created session count correct", 0, jbcm.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
// Sleep past minIdleTime
SessionTestUtil.sleepThread(1100);
createAndUseSession(jbcm, "4", true, true);