[jboss-cvs] JBossAS SVN: r95749 - trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 29 08:08:18 EDT 2009


Author: bstansberry at jboss.com
Date: 2009-10-29 08:08:18 -0400 (Thu, 29 Oct 2009)
New Revision: 95749

Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
Log:
[JBAS-7205] Beef up tests of state transfer / loading from persisted store around redeploy/restart 

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java	2009-10-29 12:07:42 UTC (rev 95748)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java	2009-10-29 12:08:18 UTC (rev 95749)
@@ -749,26 +749,42 @@
    {
       log.info("Enter testReplicatedRedeploy");
       
-      replicatedWarRedeployTest(false, false, false, false);
+      replicatedWarRedeployTest(false, false, false, false, false);
    }
    
+   public void testReplicatedRedeployWarAndCache() throws Exception
+   {
+      log.info("Enter testReplicatedRedeployWarAndCache");
+      
+      replicatedWarRedeployTest(true, false, false, false, false);
+   }
+   
    public void testReplicatedRestart() throws Exception
    {
       log.info("Enter testReplicatedRestart");
       
-      replicatedWarRedeployTest(true, true, false, false);
+      replicatedWarRedeployTest(true, true, false, false, false);
       
    }
    
+   public void testReplicatedRestartWithPurge() throws Exception
+   {
+      log.info("Enter testReplicatedRestartWithPurge");
+      
+      replicatedWarRedeployTest(true, true, false, false, true);
+      
+   }
+   
    private void replicatedWarRedeployTest(boolean restartCache, 
                                           boolean fullRestart,
                                           boolean totalReplication,
-                                          boolean marshalling)
+                                          boolean marshalling, 
+                                          boolean purgeOnStartStop)
          throws Exception
    {
       ++testCount;
       String passDir = getPassivationDir(testCount, 1);
-      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
       PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
       
       JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 30, 1);
@@ -782,7 +798,7 @@
       assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
       
       passDir = getPassivationDir(testCount, 2);
-      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
       PojoCache cache1 = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
       
       jbcm1.init("test.war", webMetaData);
@@ -854,7 +870,8 @@
          caches.remove(cache);
          
          passDir = getPassivationDir(testCount, 1);
-         jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
+         jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
+         cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
       }
       else
       {
@@ -867,16 +884,36 @@
       assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
       assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
       assertEquals("Correct max idle time", 30, jbcm.getPassivationMaxIdleTime());
-      assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());     
+      assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());        
       
-      int expected = (totalReplication && marshalling && fullRestart) ? 0 : 2;
-      assertEquals("Session count correct", expected, 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());
-      expected = (totalReplication && !(marshalling && fullRestart)) ? 1 : 0;
-      assertEquals("Passivated session count correct", expected, jbcm.getPassivatedSessionCount());
+      // Do we expect content?
+      boolean expectContent = true;
+      // First, see if we expect a purge on redeploy
+      boolean expectPurge = purgeOnStartStop && (!totalReplication || marshalling);
+      // Even with a purge, if the other cache is available we may have state transfer
+      // on redeploy
+      if (expectPurge && !fullRestart)
+      {
+         expectContent = (restartCache || !totalReplication || marshalling);
+      }
       
+      if (expectContent)
+      {
+         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());
+      }      
+      else
+      {
+         assertEquals("Session count correct", 0, 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", 0, jbcm.getPassivatedSessionCount());         
+      }
+      
       if (!fullRestart)
       {
          assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
@@ -885,6 +922,7 @@
          assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
          assertEquals("Passivated session count correct", 1, jbcm1.getPassivatedSessionCount());
       }
+
       // Sleep past minIdleTime
       SessionTestUtil.sleepThread(1100);
       
@@ -895,50 +933,98 @@
    {
       log.info("Enter testTotalReplicatedRedeploy");
       
-      replicatedWarRedeployTest(false, false, true, false);
+      replicatedWarRedeployTest(false, false, true, false, false);
       
    }
    
+   public void testTotalReplicatedRedeployWarAndCache() throws Exception
+   {
+      log.info("Enter testTotalReplicatedRedeployWarAndCache");
+      
+      replicatedWarRedeployTest(true, false, true, false, false);
+      
+   }
+   
    public void testTotalReplicatedRestart() throws Exception
    {
       log.info("Enter testTotalReplicatedRestart");
       
-      replicatedWarRedeployTest(true, true, true, false);
+      replicatedWarRedeployTest(true, true, true, false, false);
       
    }
    
+   public void testTotalReplicatedRestartWithPurge() throws Exception
+   {
+      log.info("Enter testTotalReplicatedRestartWithPurge");
+      
+      replicatedWarRedeployTest(true, true, true, false, true);
+      
+   }
+   
    public void testMarshalledRedeploy() throws Exception
    {
       log.info("Enter testMarshalledRedeploy");
       
-      replicatedWarRedeployTest(false, false, false, true);
+      replicatedWarRedeployTest(false, false, false, true, false);
       
    }
    
+   public void testMarshalledRedeployWarAndCache() throws Exception
+   {
+      log.info("Enter testMarshalledRedeployWarAndCache");
+      
+      replicatedWarRedeployTest(true, false, false, true, false);
+      
+   }
+   
    public void testMarshalledRestart() throws Exception
    {
       log.info("Enter testMarshalledRestart");
       
-      replicatedWarRedeployTest(true, true, false, true);
+      replicatedWarRedeployTest(true, true, false, true, false);
       
    }
    
+   public void testMarshalledRestartWithPurge() throws Exception
+   {
+      log.info("Enter testMarshalledRestartWithPurge");
+      
+      replicatedWarRedeployTest(true, true, false, true, true);
+      
+   }
+   
    public void testTotalMarshalledRedeploy() throws Exception
    {
       log.info("Enter testTotalMarshalledRedeploy");
       
-      replicatedWarRedeployTest(false, false, true, true);
+      replicatedWarRedeployTest(false, false, true, true, false);
       
    }
    
+   public void testTotalMarshalledRedeployWarAndCache() throws Exception
+   {
+      log.info("Enter testTotalMarshalledRedeployWarAndCache");
+      
+      replicatedWarRedeployTest(true, false, true, true, false);
+      
+   }
+   
    public void testTotalMarshalledRestart() throws Exception
    {
       log.info("Enter testTotalMarshalledRestart");
       
-      replicatedWarRedeployTest(true, true, true, true);
+      replicatedWarRedeployTest(true, true, true, true, false);
       
    }
    
+   public void testTotalMarshalledRestartWithPurge() throws Exception
+   {
+      log.info("Enter testTotalMarshalledRestartWithPurge");
+      
+      replicatedWarRedeployTest(true, true, true, true, true);
+      
+   }
+   
    private Session createAndUseSession(JBossCacheManager jbcm, String id, 
                            boolean canCreate, boolean access)
          throws Exception




More information about the jboss-cvs-commits mailing list