[jboss-cvs] JBossAS SVN: r64679 - in trunk/testsuite/src: main/org/jboss/test/cluster/web and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 18 11:23:54 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-08-18 11:23:53 -0400 (Sat, 18 Aug 2007)
New Revision: 64679

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/SessionCountUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java
   trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
Log:
[JBAS-4613] JBossCacheManager active session count should include backup sessions

Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/SessionCountUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/SessionCountUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/SessionCountUnitTestCase.java	2007-08-18 15:23:53 UTC (rev 64679)
@@ -0,0 +1,988 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.defaultcfg.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.catalina.Manager;
+import org.apache.catalina.Session;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.metadata.web.PassivationConfig;
+import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.web.tomcat.service.session.JBossCacheManager;
+
+/**
+ * Unit tests of session count management.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class SessionCountUnitTestCase extends TestCase
+{
+   private static final Logger log = Logger.getLogger(SessionCountUnitTestCase.class);
+   private static final String UDP_PORT = "34567";
+   
+   private static long testCount = System.currentTimeMillis();
+   
+   private String bind_address;
+   private String udp_group;
+   private String udp_port;
+   private Set<PojoCache> caches = new HashSet<PojoCache>();
+   private String tempDir;
+   
+   /**
+    * Create a new SessionCountUnitTestCase.
+    * 
+    * @param name
+    */
+   public SessionCountUnitTestCase(String name)
+   {
+      super(name);
+   }  
+   
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      // Set system properties to properly bind JGroups channels
+      
+      // First, preserve any existing values
+      bind_address = System.getProperty("bind.address");
+      udp_group = System.getProperty("jboss.partition.udpGroup");
+      udp_port = System.getProperty("jboss.partition.udpPort");
+      
+      System.setProperty("bind.address", "127.0.0.1");
+      String grp = System.getProperty("jbosstest.udpGroup");
+      if (grp != null && grp.length() > 0)
+      {
+         System.setProperty("jboss.partition.udpGroup", grp);
+      }
+      System.setProperty("jboss.partition.udpPort", UDP_PORT);
+      
+      File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+      File root = new File(tmpDir, getClass().getSimpleName());
+      tempDir = root.getAbsolutePath();
+    }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      // Restore any system properties we set in setUp
+      if (bind_address == null)
+         System.clearProperty("bind.address");
+      else
+         System.setProperty("bind.address", bind_address);
+      if (udp_group == null)
+         System.clearProperty("jboss.partition.udpGroup");
+      else
+         System.setProperty("jboss.partition.udpGroup", udp_group);
+      
+      if (udp_port == null)
+         System.clearProperty("jboss.partition.udpPort");
+      else
+         System.setProperty("jboss.partition.udpPort", udp_port);
+      
+      for (PojoCache cache : caches)
+      { 
+         // Try to clean up so we avoid loading sessions 
+         // from storage in later tests
+         try
+         {
+            log.info("Removing /JSESSION from " + cache.getCache().getLocalAddress());
+            cache.getCache().removeNode(Fqn.fromString("/JSESSION"));
+         }
+         catch (Exception e)
+         {
+            log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+         }
+         
+         try
+         {
+            cache.stop();
+            cache.destroy();
+         }
+         catch (Exception e)
+         {
+            log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+         }
+      }
+      
+      caches.clear();
+      
+      if (tempDir != null)
+      {
+         File dir = new File(tempDir);
+         if (dir.exists())
+            dir.delete();
+         if (dir.exists())
+            dir.deleteOnExit();
+      }
+   }
+
+   public void testStandaloneMaxSessions() throws Exception
+   {
+      log.info("Enter testStandaloneMaxSessions");
+      
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, null, false, false);
+      caches.add(jbcm.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(2);
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      jbcm.start();
+      
+      assertFalse("Passivation is disabled", jbcm.isPassivationEnabled());
+      assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
+      
+      // Set up a session
+      Session sess1 = createAndUseSession(jbcm, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      
+      createAndUseSession(jbcm, "2", true, true);
+      
+      assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 2, jbcm.getLocalActiveSessionCount());
+      
+      // Should fail to create a 3rd
+      createAndUseSession(jbcm, "3", false, false);
+      
+      // Confirm a session timeout clears space
+      sess1.setMaxInactiveInterval(1);       
+      sleep(1100);      
+      
+      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", 1, jbcm.getExpiredSessionCount());
+   }
+   
+   public void testStandaloneMaxSessionsWithMaxIdle()
+         throws Exception
+   {
+      log.info("Enter testStandaloneMaxSessionsWithMaxIdle");
+      
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, tempDir, false, false);
+      caches.add(jbcm.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 1, -1);
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      jbcm.start();
+      
+      assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 1, jbcm.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", -1, jbcm.getPassivationMinIdleTime());
+
+      // Set up a session
+      Session sess1 = createAndUseSession(jbcm, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm, "2", false, false);
+      
+      // Confirm a session timeout clears space
+      sess1.setMaxInactiveInterval(1);       
+      sleep(1100);      
+      
+      createAndUseSession(jbcm, "2", true, true);      
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 2, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 1, jbcm.getExpiredSessionCount());
+      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
+
+      //    Sleep past maxIdleTime
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
+      
+      createAndUseSession(jbcm, "3", true, true);      
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 3, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 1, jbcm.getExpiredSessionCount());
+      assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
+      
+   }
+   
+   public void testStandaloneMaxSessionsWithMinIdle() throws Exception
+   {
+      log.info("Enter testStandaloneMaxSessionsWithMinIdle");
+      
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, tempDir, false, false);
+      caches.add(jbcm.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 3, 1);
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      jbcm.start();
+      
+      assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
+      
+      // Set up a session
+      Session sess1 = createAndUseSession(jbcm, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm, "2", false, false);
+      
+      // Confirm a session timeout clears space
+      sess1.setMaxInactiveInterval(1);       
+      sleep(1100);      
+      
+      createAndUseSession(jbcm, "2", true, false);      
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());     
+      assertEquals("Created session count correct", 2, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 1, jbcm.getExpiredSessionCount());
+
+      //    Sleep past minIdleTime
+      sleep(1100);        
+      
+//      assertTrue("Session 2 still valid", sess2.isValid());
+      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
+      
+      createAndUseSession(jbcm, "3", true, true);      
+      
+      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 3, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 1, jbcm.getExpiredSessionCount());
+      assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
+   }
+   
+   public void testReplicatedMaxSessions() throws Exception
+   {
+      log.info("Enter testReplicatedMaxSessions");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, null, false, false);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertFalse("Passivation is disabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max inactive interval", 1, jbcm0.getMaxInactiveInterval());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, null, false, false);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertFalse("Passivation is disabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max inactive interval", 1, jbcm1.getMaxInactiveInterval());
+      
+      // Set up a session
+      Session sess1 = createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);
+      
+      // Confirm a session timeout clears space
+      sess1.setMaxInactiveInterval(1);     
+      useSession(jbcm0, "1");
+      sleep(jbcm0.getMaxInactiveInterval() * 1000 + 100);      
+      
+      createAndUseSession(jbcm1, "2", true, true);      
+      
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());
+   }
+   
+   public void testReplicatedMaxSessionsWithMaxIdle() throws Exception
+   {
+      log.info("Enter testReplicatedMaxSessionsWithMaxIdle");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, tempDir, false, false);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 1, -1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertTrue("Passivation is enabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 1, jbcm0.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", -1, jbcm0.getPassivationMinIdleTime());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, tempDir, false, false);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 1, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", -1, jbcm1.getPassivationMinIdleTime());
+      
+      // Set up a session
+      createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);      
+      
+      //    Sleep past maxIdleTime      
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+       
+      createAndUseSession(jbcm1, "2", true, true);      
+       
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+       
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+   }
+   
+   public void testReplicatedMaxSessionsWithMinIdle() throws Exception
+   {
+      log.info("Enter testReplicatedMaxSessionsWithMinIdle");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, tempDir, false, false);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 3, 1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertTrue("Passivation is enabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm0.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, tempDir, false, false);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
+      
+      // Set up a session
+      createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);      
+      
+      // Sleep past maxIdleTime      
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+       
+      createAndUseSession(jbcm1, "2", true, true);      
+       
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+       
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+      
+   }
+   
+   public void testTotalReplication() throws Exception
+   {
+      log.info("Enter testTotalReplication");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, tempDir, true, false);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 3, 1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertTrue("Passivation is enabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm0.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, tempDir, true, false);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
+      
+      // Set up a session
+      createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);      
+      
+      // Sleep past maxIdleTime      
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+       
+      createAndUseSession(jbcm1, "2", true, true);      
+       
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+       
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+      
+   }
+   
+   public void testRegionBasedMarshalling() throws Exception
+   {
+      log.info("Enter testRegionBasedMarshalling");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, tempDir, false, true);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 3, 1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertTrue("Passivation is enabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm0.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, tempDir, false, true);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
+      
+      // Set up a session
+      createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);      
+      
+      // Sleep past maxIdleTime      
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+       
+      createAndUseSession(jbcm1, "2", true, true);      
+       
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+       
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+      
+   }
+   
+   public void testTotalReplicationWithMarshalling() throws Exception
+   {
+      log.info("Enter testTotalReplicationWithMarshalling");
+      
+      JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + ++testCount, 1, false, tempDir, true, true);
+      caches.add(jbcm0.getPojoCache());
+      
+      WebMetaData webMetaData = createWebMetaData(1, true, 3, 1);
+      jbcm0.init("test.war", webMetaData, false, true);
+      
+      jbcm0.start();
+      
+      assertTrue("Passivation is enabled", jbcm0.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm0.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm0.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, tempDir, true, true);
+      caches.add(jbcm1.getPojoCache());
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 1, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
+      
+      // Set up a session
+      createAndUseSession(jbcm0, "1", true, true);
+      
+      assertEquals("Session count correct", 1, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());      
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Should fail to create a 2nd
+      createAndUseSession(jbcm1, "2", false, false);      
+      
+      // Sleep past maxIdleTime      
+      sleep(1100);        
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+       
+      createAndUseSession(jbcm1, "2", true, true);      
+       
+      assertEquals("Session count correct", 2, jbcm0.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+       
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm0.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm0.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm0.getExpiredSessionCount());      
+      
+   }
+   
+   public void testStandaloneRedeploy() throws Exception
+   {
+      log.info("Enter testStandaloneRedeploy");
+      
+      standaloneWarRedeployTest(false);
+   }
+   
+   public void testStandaloneRestart() throws Exception
+   {
+      log.info("Enter testStandaloneRedeploy");
+      
+      standaloneWarRedeployTest(true);
+   }
+   
+   private void standaloneWarRedeployTest(boolean restartCache)
+         throws Exception
+   {
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + ++testCount, 300, true, tempDir, false, false);
+      PojoCache cache = jbcm.getPojoCache();
+      caches.add(cache);
+      
+      WebMetaData webMetaData = createWebMetaData(2, true, 3, 1);
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      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());
+      
+      // Should fail to create 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
+      sleep(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);
+         
+         jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, tempDir, false, false);
+         caches.add(jbcm.getPojoCache());
+      }
+      else
+      {
+         jbcm = SessionTestUtil.createManager("test" + testCount, 5, cache);
+      }
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      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
+      sleep(1100);
+      
+      createAndUseSession(jbcm, "4", true, true); 
+   }
+   
+   public void testReplicatedRedeploy() throws Exception
+   {
+      log.info("Enter testReplicatedRedeploy");
+      
+      replicatedWarRedeployTest(false, false, false, false);
+   }
+   
+   public void testReplicatedRestart() throws Exception
+   {
+      log.info("Enter testReplicatedRestart");
+      
+      replicatedWarRedeployTest(true, true, false, false);
+      
+   }
+   
+   private void replicatedWarRedeployTest(boolean restartCache, 
+                                          boolean fullRestart,
+                                          boolean totalReplication,
+                                          boolean marshalling)
+         throws Exception
+   {
+      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + ++testCount, 300, false, tempDir, totalReplication, marshalling);
+      PojoCache cache = jbcm.getPojoCache();
+      caches.add(cache);
+      
+      WebMetaData webMetaData = createWebMetaData(2, true, 3, 1);
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      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());
+      
+      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, tempDir, totalReplication, marshalling);
+      PojoCache cache1 = jbcm1.getPojoCache();
+      caches.add(cache1);
+      
+      jbcm1.init("test.war", webMetaData, false, true);
+      
+      jbcm1.start();
+      
+      SessionTestUtil.blockUntilViewsReceived(new Cache[]{ cache.getCache(), cache1.getCache()}, 10000);
+      
+      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
+      assertEquals("Correct max active count", 2, jbcm1.getMaxActiveAllowed());
+      assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+      assertEquals("Correct min idle time", 1, jbcm1.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());    
+      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
+      
+      // Create a 2nd
+      createAndUseSession(jbcm1, "2", true, true);     
+      
+      assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());     
+      assertEquals("Created session count correct", 1, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
+      assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());     
+      assertEquals("Created session count correct", 1, jbcm1.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
+
+      //    Sleep past minIdleTime
+      sleep(1100);
+      
+      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
+      
+      createAndUseSession(jbcm1, "3", true, true);      
+      
+      assertEquals("Session count correct", 3, jbcm.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 1, jbcm.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
+      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
+      assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
+      assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());
+      assertEquals("Created session count correct", 2, jbcm1.getCreatedSessionCount());
+      assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
+      assertEquals("Passivated session count correct", 1, jbcm1.getPassivatedSessionCount());
+      
+      if (fullRestart)
+      {
+        jbcm1.stop();
+        cache1.stop();
+        cache1.destroy();
+        caches.remove(cache1);
+      }
+      
+      jbcm.stop();
+      
+      if (restartCache)
+      {
+         cache.stop();
+         cache.destroy();
+         caches.remove(cache);
+         
+         jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, tempDir, totalReplication, marshalling);
+         caches.add(jbcm.getPojoCache());
+      }
+      else
+      {
+         jbcm = SessionTestUtil.createManager("test" + testCount, 300, cache);
+      }
+      jbcm.init("test.war", webMetaData, false, true);
+      
+      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
+      sleep(1100);
+      
+      createAndUseSession(jbcm, "4", true, true); 
+   }
+   
+   public void testTotalReplicatedRedeploy() throws Exception
+   {
+      log.info("Enter testTotalReplicatedRedeploy");
+      
+      replicatedWarRedeployTest(false, false, true, false);
+      
+   }
+   
+   public void testTotalReplicatedRestart() throws Exception
+   {
+      log.info("Enter testTotalReplicatedRestart");
+      
+      replicatedWarRedeployTest(true, true, true, false);
+      
+   }
+   
+   public void testMarshalledRedeploy() throws Exception
+   {
+      log.info("Enter testStandaloneRedeploy");
+      
+      replicatedWarRedeployTest(false, false, false, true);
+      
+   }
+   
+   public void testMarshalledRestart() throws Exception
+   {
+      log.info("Enter testStandaloneRestart");
+      
+      replicatedWarRedeployTest(true, true, false, true);
+      
+   }
+   
+   private WebMetaData createWebMetaData(int maxSessions)
+   {
+      return createWebMetaData(maxSessions, false, -1, -1);
+   }
+   
+   private WebMetaData createWebMetaData(int maxSessions, boolean passivation,
+                                         int maxIdle, int minIdle)
+   {
+      WebMetaData webMetaData = new WebMetaData();
+      webMetaData.setDistributable(true);
+      webMetaData.setMaxActiveSessionsAllowed(maxSessions);
+      PassivationConfig pcfg = new PassivationConfig();
+      pcfg.setUseSessionPassivation(passivation ? "true" : "false");
+      pcfg.setPassivationMaxIdleTime(Integer.toString(maxIdle));
+      pcfg.setPassivationMinIdleTime(Integer.toString(minIdle));
+      webMetaData.setPassivationConfig(pcfg);
+      return webMetaData;
+   }
+   
+   private Session createAndUseSession(JBossCacheManager jbcm, String id, 
+                           boolean canCreate, boolean access)
+         throws Exception
+   {
+      //    Shift to Manager interface when we simulate Tomcat
+      Manager mgr = jbcm;
+      Session sess = mgr.findSession(id);
+      assertNull("session does not exist", sess);
+      try
+      {
+         sess = mgr.createSession(id);
+         if (!canCreate)
+            fail("Could not create session" + id);
+      }
+      catch (IllegalStateException ise)
+      {
+         if (canCreate)
+         {
+            log.error("Failed to create session " + id, ise);
+            fail("Could create session " + id);
+         }
+      }
+      
+      if (access)
+      {
+         sess.access();
+         sess.getSession().setAttribute("test", "test");
+         
+         jbcm.storeSession(sess);
+         
+         sess.endAccess();
+      }
+      
+      return sess;
+   }
+   
+   private void useSession(JBossCacheManager jbcm, String id)
+         throws Exception
+   {
+      //    Shift to Manager interface when we simulate Tomcat
+      Manager mgr = jbcm;
+      Session sess = mgr.findSession(id);
+      assertNotNull("session exists", sess);
+      
+      sess.access();
+      sess.getSession().setAttribute("test", "test");
+      
+      jbcm.storeSession(sess);
+      
+      sess.endAccess();
+   }
+
+   private void sleep(long time)
+   {
+      try
+      {
+         Thread.sleep(time);
+      }
+      catch (InterruptedException e) {}
+   }
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/SessionCountUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java	2007-08-18 15:23:53 UTC (rev 64679)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web;
+
+import org.apache.catalina.Loader;
+import org.apache.catalina.Manager;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.core.ContainerBase;
+import org.apache.catalina.core.StandardPipeline;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Mock Container impl to wrap a JBossCacheManager in unit tests.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class MockContainer extends ContainerBase
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private Log log = LogFactory.getLog(getClass());
+   
+   private Loader loader;
+   
+   private Pipeline pipeline;
+
+   @Override
+   public Loader getLoader()
+   {
+      if (loader == null)
+      {
+         loader = new MockLoader();
+         loader.setContainer(this);
+      }
+      return loader;
+   }
+
+   public Log getLogger()
+   {
+      return log;
+   }
+
+   public Pipeline getPipeline()
+   {
+      if (pipeline == null)
+      {
+         pipeline = new StandardPipeline(this);
+      }
+      return pipeline;
+   }
+
+   public void setLoader(Loader loader)
+   {
+      this.loader = loader;
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java	2007-08-18 15:23:53 UTC (rev 64679)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web;
+
+import java.beans.PropertyChangeListener;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Loader;
+
+/**
+ * Mock Loader impl for use in unit tests.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class MockLoader implements Loader
+{
+   private Container container;
+   
+   public void addPropertyChangeListener(PropertyChangeListener listener)
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public void addRepository(String repository)
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public void backgroundProcess()
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public String[] findRepositories()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public ClassLoader getClassLoader()
+   {      
+      return container == null ? getClass().getClassLoader() 
+                               : container.getClass().getClassLoader();
+   }
+
+   public Container getContainer()
+   {
+      return container;
+   }
+
+   public boolean getDelegate()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public String getInfo()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public boolean getReloadable()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean modified()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public void removePropertyChangeListener(PropertyChangeListener listener)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   public void setContainer(Container container)
+   {
+      this.container = container;
+   }
+
+   public void setDelegate(boolean delegate)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   public void setReloadable(boolean reloadable)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml	2007-08-18 15:23:53 UTC (rev 64679)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Can be parsed to create a basic configuration for unit tests -->
+
+<server>
+
+    <mbean code="org.jboss.cache.pojo.impl.PojoCacheImpl"
+        name="jboss.cache:service=TomcatClusteringTestCache">
+
+        <attribute name="ClusterName">Tomcat-TestCluster</attribute>
+
+        <!-- make sure to specify BatchModeTransactionManager only! -->
+        <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.BatchModeTransactionManagerLookup</attribute>
+
+        <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+        <attribute name="CacheMode">REPL_SYNC</attribute>
+
+        <attribute name="SyncReplTimeout">20000</attribute>
+
+        <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+        <attribute name="UseRegionBasedMarshalling">false</attribute>
+        <attribute name="InactiveOnStartup">false</attribute>
+
+        <attribute name="BuddyReplicationConfig">
+            <config>
+                <buddyReplicationEnabled>true</buddyReplicationEnabled>
+                <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+                <buddyLocatorProperties>
+                    numBuddies = 1
+                    ignoreColocatedBuddies = true
+                </buddyLocatorProperties>
+
+                <buddyPoolName>default</buddyPoolName>
+                <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+                <autoDataGravitation>false</autoDataGravitation>
+                <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+                <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+            </config>
+        </attribute>
+ 
+        <attribute name="CacheLoaderConfig">
+            <config>
+                <passivation>true</passivation>
+                <preload>/</preload>
+                <shared>false</shared>
+                <cacheloader>
+                    <class>org.jboss.cache.loader.FileCacheLoader</class>
+                    <properties>
+                        location=/tmp
+                    </properties>
+                    <async>false</async>
+                    <fetchPersistentState>true</fetchPersistentState>
+                    <ignoreModifications>false</ignoreModifications>
+                </cacheloader>
+            </config>
+        </attribute>
+         
+    </mbean>
+
+</server>


Property changes on: trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list