[jboss-cvs] JBossAS SVN: r102777 - in trunk/testsuite: src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 23 08:43:49 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-03-23 08:43:47 -0400 (Tue, 23 Mar 2010)
New Revision: 102777
Removed:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/TreeCacheSSOClusterManagerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/DelegatingMockCache.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/JBossCacheUtil.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockTransactionManagerLookup.java
trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
Modified:
trunk/testsuite/imports/sections/cluster.xml
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/AttributeBasedMaxUnreplicatedIntervalTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionMemoryLeakTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ConcurrentFailoverRequestsTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FailedExpirationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FieldBasedMaxUnreplicatedIntervalTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JBossCacheManagerConfigurationUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/MultipleWarSingleRedeployTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionExpirationUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/StoppedManagerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossCacheConfigTestSetupDelegate.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java
Log:
[JBAS-7848] Reduce direct testsuite dependency on JBoss Cache
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/imports/sections/cluster.xml 2010-03-23 12:43:47 UTC (rev 102777)
@@ -504,14 +504,8 @@
<include name="*.jsp"/>
<include name="*.html"/>
</fileset>
- </war>
+ </war>
- <!-- Cache config file for standalone http tests -->
- <copy
- tofile="${build.resources}/jboss-web-test-service.xml"
- file="${build.resources}/cluster/http/jboss-web-test-service.xml"
- overwrite="true"/>
-
<!-- Build clustered classloader leak test archives -->
<war destfile="${build.lib}/cluster-clleak-simple.war"
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/AttributeBasedMaxUnreplicatedIntervalTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/AttributeBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/AttributeBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -48,7 +48,7 @@
public static Test suite() throws Exception
{
- return CacheConfigTestSetup.getTestSetup(AttributeBasedMaxUnreplicatedIntervalTestCase.class, pojoCaches, false, null, !useBuddyRepl, false);
+ return CacheConfigTestSetup.getTestSetup(AttributeBasedMaxUnreplicatedIntervalTestCase.class, dcmFactories, false, null, !useBuddyRepl, false);
}
protected ReplicationGranularity getReplicationGranularity()
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -37,7 +37,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
@@ -47,6 +46,7 @@
import org.jboss.test.cluster.web.mocks.InvalidateSessionRequestHandler;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Unit tests of failover with buddy replication
@@ -55,7 +55,7 @@
*/
public class BuddyReplicationFailoverUnitTestCase extends TestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[4];
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[4];
protected static long testId = System.currentTimeMillis();
@@ -72,7 +72,7 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, BuddyReplicationFailoverUnitTestCase.class.getSimpleName());
- return CacheConfigTestSetup.getTestSetup(BuddyReplicationFailoverUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), false, false);
+ return CacheConfigTestSetup.getTestSetup(BuddyReplicationFailoverUnitTestCase.class, dcmFactories, false, root.getAbsolutePath(), false, false);
}
@Override
@@ -84,8 +84,6 @@
}
finally
{
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
for (JBossCacheManager manager : managers)
manager.stop();
@@ -202,10 +200,10 @@
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxIdle, int maxUnreplicated)
throws Exception
{
- JBossCacheManager[] result = new JBossCacheManager[pojoCaches.length];
- for (int i = 0; i < pojoCaches.length; i++)
+ JBossCacheManager[] result = new JBossCacheManager[dcmFactories.length];
+ for (int i = 0; i < dcmFactories.length; i++)
{
- JBossCacheManager jbcm = createManager(warname, maxInactive, pojoCaches[i], null);
+ JBossCacheManager jbcm = createManager(warname, maxInactive, dcmFactories[i], null);
JBossWebMetaData metadata = createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1, true, maxUnreplicated);
jbcm.init(warname, metadata);
this.managers.add(jbcm);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -51,7 +51,7 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, BuddyReplicationToPassivatedSessionUnitTestCase.class.getSimpleName());
- return CacheConfigTestSetup.getTestSetup(BuddyReplicationToPassivatedSessionUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), false, false);
+ return CacheConfigTestSetup.getTestSetup(BuddyReplicationToPassivatedSessionUnitTestCase.class, dcmFactories, false, root.getAbsolutePath(), false, false);
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionMemoryLeakTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionMemoryLeakTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionMemoryLeakTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -35,7 +35,6 @@
import junit.framework.Test;
import org.apache.catalina.Session;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
@@ -49,6 +48,7 @@
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.test.cluster.web.notification.SessionSpecListenerAttribute;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Tests that references to cached sessions and attributes are released.
@@ -57,7 +57,7 @@
*/
public class ClusteredSessionMemoryLeakTestCase extends JBossTestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[2];
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[2];
protected static long testId = System.currentTimeMillis();
@@ -83,7 +83,7 @@
File root = new File(tmpDir, ClusteredSessionMemoryLeakTestCase.class.getSimpleName());
root.mkdirs();
root.deleteOnExit();
- return CacheConfigTestSetup.getTestSetup(ClusteredSessionMemoryLeakTestCase.class, pojoCaches, false, root.getAbsolutePath(), true, false);
+ return CacheConfigTestSetup.getTestSetup(ClusteredSessionMemoryLeakTestCase.class, dcmFactories, false, root.getAbsolutePath(), true, false);
}
@Override
@@ -317,13 +317,13 @@
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxIdle)
throws Exception
{
- JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[0], null);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[0], null);
JBossWebMetaData metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, maxIdle > 0, maxIdle, -1 ,false, 0);
jbcm0.init(warname, metadata);
this.managers.add(jbcm0);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[1], null);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[1], null);
metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1 ,false, 0);
jbcm1.init(warname, metadata);
this.managers.add(jbcm1);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -50,6 +50,7 @@
import org.jboss.test.cluster.web.notification.MockHttpSessionListener;
import org.jboss.test.cluster.web.notification.SessionSpecListenerAttribute;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Tests of handling of servlet spec notifications.
@@ -58,7 +59,7 @@
*/
public class ClusteredSessionNotificationPolicyTestCase extends JBossTestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[2];
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[2];
protected static long testId = System.currentTimeMillis();
@@ -87,7 +88,7 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, ClusteredSessionNotificationPolicyTestCase.class.getSimpleName());
- return CacheConfigTestSetup.getTestSetup(ClusteredSessionNotificationPolicyTestCase.class, pojoCaches, false, root.getAbsolutePath(), !useBuddyRepl, false);
+ return CacheConfigTestSetup.getTestSetup(ClusteredSessionNotificationPolicyTestCase.class, dcmFactories, false, root.getAbsolutePath(), !useBuddyRepl, false);
}
@@ -652,14 +653,14 @@
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxIdle)
throws Exception
{
- JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[0], null);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[0], null);
JBossWebMetaData metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, maxIdle > 0, maxIdle, -1 ,false, 0);
metadata.getReplicationConfig().setSessionNotificationPolicy(MockClusteredSessionNotificationPolicy.class.getName());
jbcm0.init(warname, metadata);
this.managers.add(jbcm0);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[1], null);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[1], null);
metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1 ,false, 0);
metadata.getReplicationConfig().setSessionNotificationPolicy(MockClusteredSessionNotificationPolicy.class.getName());
jbcm1.init(warname, metadata);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ConcurrentFailoverRequestsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ConcurrentFailoverRequestsTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ConcurrentFailoverRequestsTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -34,21 +34,17 @@
import junit.framework.TestCase;
import org.apache.catalina.Manager;
-import org.apache.catalina.Session;
import org.apache.catalina.Valve;
import org.apache.catalina.connector.Request;
-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.web.jboss.JBossWebMetaData;
-import org.jboss.test.cluster.testutil.JBossCacheUtil;
import org.jboss.test.cluster.testutil.JGroupsSystemPropertySupport;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.web.mocks.BasicRequestHandler;
import org.jboss.test.cluster.web.mocks.ConcurrentRequestHandler;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* JBAS-7379. Tests that multiple concurrent failover requests for
@@ -64,7 +60,7 @@
private static long testCount = System.currentTimeMillis();
private final JGroupsSystemPropertySupport jgSupport = new JGroupsSystemPropertySupport();
- private Set<PojoCache> caches = new HashSet<PojoCache>();
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
private ExecutorService threadPool;
@@ -102,35 +98,20 @@
threadPool.shutdownNow();
}
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
- for (PojoCache cache : caches)
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- // 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"));
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
-
}
- caches.clear();
+ dcmFactories.clear();
}
}
@@ -140,22 +121,17 @@
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(100);
String warName = "test" + testCount;
- JBossCacheManager jbcm0 = SessionTestUtil.createManager(warName, 30, false, null, false, false, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager(warName, 30, false, null, false, false, null, dcmFactories);
jbcm0.init(warName, webMetaData);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager(warName, 30, false, null, false, false, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager(warName, 30, false, null, false, false, null, dcmFactories);
jbcm1.init(warName, webMetaData);
jbcm1.start();
- Cache[] array = new Cache[caches.size()];
- int index = 0;
- for (PojoCache c : caches)
- {
- array[index] = c.getCache();
- index++;
- }
- JBossCacheUtil.blockUntilViewsReceived(array, 10000);
+ TestDistributedCacheManagerFactory[] array = new TestDistributedCacheManagerFactory[dcmFactories.size()];
+ array = dcmFactories.toArray(array);
+ SessionTestUtil.blockUntilViewsReceived(array, 10000);
Object value = "0";
Map<String, Object> attrs = Collections.unmodifiableMap(Collections.singletonMap("count", value));
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FailedExpirationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FailedExpirationTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FailedExpirationTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -22,7 +22,6 @@
package org.jboss.test.cluster.defaultcfg.simpleweb.test;
-import static org.jboss.test.cluster.testutil.SessionTestUtil.validateExpectedAttributes;
import static org.jboss.test.cluster.testutil.SessionTestUtil.validateNewSession;
import java.io.File;
@@ -38,16 +37,14 @@
import junit.framework.TestCase;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.test.cluster.testutil.JGroupsSystemPropertySupport;
import org.jboss.test.cluster.testutil.SessionTestUtil;
-import org.jboss.test.cluster.web.mocks.BasicRequestHandler;
import org.jboss.test.cluster.web.mocks.InvalidateSessionRequestHandler;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* A FailedExpirationTestCase.
@@ -62,7 +59,7 @@
private static long testCount = System.currentTimeMillis();
private final JGroupsSystemPropertySupport jgSupport = new JGroupsSystemPropertySupport();
- private Set<PojoCache> caches = new HashSet<PojoCache>();
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
private String tempDir;
/**
@@ -99,36 +96,21 @@
finally
{
jgSupport.restoreProperties();
-
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
- for (PojoCache cache : caches)
+
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- // 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"));
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
-
}
- caches.clear();
+ dcmFactories.clear();
SessionTestUtil.cleanFilesystem(tempDir);
}
@@ -141,7 +123,7 @@
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(10, true, 1, -1);
webMetaData.getReplicationConfig().setMaxUnreplicatedInterval(0);
String warName = "test" + testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, null, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, null, false, false, null, dcmFactories);
jbcm.init(warName, webMetaData);
jbcm.start();
@@ -178,7 +160,7 @@
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(10, true, 1, -1);
webMetaData.getReplicationConfig().setMaxUnreplicatedInterval(0);
String warName = "test" + testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, null, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, null, false, false, null, dcmFactories);
jbcm.init(warName, webMetaData);
jbcm.start();
@@ -211,7 +193,7 @@
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(10, true, 1, -1);
webMetaData.getReplicationConfig().setMaxUnreplicatedInterval(0);
String warName = "test" + testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, passivationDir, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager(warName, 2, true, passivationDir, false, false, null, dcmFactories);
jbcm.init(warName, webMetaData);
jbcm.start();
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FieldBasedMaxUnreplicatedIntervalTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FieldBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/FieldBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -48,7 +48,7 @@
public static Test suite() throws Exception
{
- return CacheConfigTestSetup.getTestSetup(FieldBasedMaxUnreplicatedIntervalTestCase.class, pojoCaches, false, null, !useBuddyRepl, true);
+ return CacheConfigTestSetup.getTestSetup(FieldBasedMaxUnreplicatedIntervalTestCase.class, dcmFactories, false, null, !useBuddyRepl, true);
}
protected ReplicationGranularity getReplicationGranularity()
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JBossCacheManagerConfigurationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JBossCacheManagerConfigurationUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JBossCacheManagerConfigurationUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -22,15 +22,11 @@
package org.jboss.test.cluster.defaultcfg.simpleweb.test;
-import java.io.File;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.spec.EmptyMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -41,6 +37,7 @@
import org.jboss.metadata.web.jboss.SnapshotMode;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Unit tests of session count management.
@@ -54,7 +51,7 @@
private static long testCount = System.currentTimeMillis();
- private Set<PojoCache> caches = new HashSet<PojoCache>();
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
private String tempDir;
/**
@@ -72,45 +69,24 @@
{
super.tearDown();
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
- for (PojoCache cache : caches)
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- if (CacheStatus.STARTED.equals(cache.getCache().getCacheStatus()))
- {
- // 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 + ": " + e.getMessage(), e);
- }
- }
-
try
{
- cache.stop();
- cache.destroy();
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
+
}
- caches.clear();
+ dcmFactories.clear();
if (tempDir != null)
{
- File dir = new File(tempDir);
- if (dir.exists())
- dir.delete();
- if (dir.exists())
- dir.deleteOnExit();
+ SessionTestUtil.cleanFilesystem(tempDir);
}
}
@@ -119,18 +95,18 @@
log.info("Enter testUseJK");
++testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, caches);
- PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ TestDistributedCacheManagerFactory factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, factory, null);
JBossWebMetaData webMetaData = createWebMetaData(null, null, null, null, null);
jbcm.init("test.war", webMetaData);
jbcm.start();
assertFalse("With no config, not using JK", jbcm.getUseJK());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
- jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, null, false, false, null, caches);
- cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, factory, null);
webMetaData = createWebMetaData(null, null, null, null, Boolean.TRUE);
jbcm.init("test.war", webMetaData);
@@ -138,10 +114,10 @@
assertTrue("With no jvmRoute but a config, using JK", jbcm.getUseJK());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
- jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, null, false, false, "test", caches);
- cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, factory, "test");
webMetaData = createWebMetaData(null, null, null, null, null);
jbcm.init("test.war", webMetaData);
@@ -149,10 +125,10 @@
assertTrue("With jvmRoute set, using JK", jbcm.getUseJK());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
- jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, null, false, false, "test", caches);
- cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, factory, "test");
webMetaData = createWebMetaData(null, null, null, null, Boolean.FALSE);
jbcm.init("test.war", webMetaData);
@@ -160,7 +136,7 @@
assertFalse("With a jvmRoute but config=false, not using JK", jbcm.getUseJK());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
}
public void testSnapshot() throws Exception
@@ -168,19 +144,20 @@
log.info("Enter testSnapshot");
++testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, caches);
- PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ TestDistributedCacheManagerFactory factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, factory, null);
+
JBossWebMetaData webMetaData = createWebMetaData(null, null, null, null, null);
jbcm.init("test.war", webMetaData);
jbcm.start();
assertEquals("With no config, using instant", SnapshotMode.INSTANT, jbcm.getSnapshotMode());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
- jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, true, null, false, false, null, caches);
- cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, null, false, false, false, dcmFactories);
+ jbcm = SessionTestUtil.createManager("test" + ++testCount, 5, factory, null);
webMetaData = createWebMetaData(null, null, null, null, Boolean.TRUE);
webMetaData.getReplicationConfig().setSnapshotMode(SnapshotMode.INTERVAL);
@@ -191,15 +168,15 @@
assertEquals("With config, using interval", SnapshotMode.INTERVAL, jbcm.getSnapshotMode());
assertEquals("With config, using 2 second interval", 2, jbcm.getSnapshotInterval());
- cleanupManager(jbcm, cache);
+ cleanupManager(jbcm, factory);
}
- private void cleanupManager(JBossCacheManager mgr, PojoCache cache) throws Exception
+ private void cleanupManager(JBossCacheManager mgr, TestDistributedCacheManagerFactory factory) throws Exception
{
mgr.stop();
- cache.stop();
- cache.destroy();
+ factory.cleanup(false);
+ dcmFactories.remove(factory);
}
private JBossWebMetaData createWebMetaData(Integer maxSessions,
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/MultipleWarSingleRedeployTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/MultipleWarSingleRedeployTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/MultipleWarSingleRedeployTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -41,6 +41,7 @@
import org.jboss.test.cluster.web.mocks.BasicRequestHandler;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Tests for JBAS-7205. Deploy two wars on each node, sharing a cache between
@@ -50,7 +51,7 @@
*/
public class MultipleWarSingleRedeployTestCase extends JBossTestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[2];
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[2];
protected static long testId = System.currentTimeMillis();
@@ -69,7 +70,7 @@
public static Test suite() throws Exception
{
- return CacheConfigTestSetup.getTestSetup(MultipleWarSingleRedeployTestCase.class, pojoCaches, false, null, !useBuddyRepl, true);
+ return CacheConfigTestSetup.getTestSetup(MultipleWarSingleRedeployTestCase.class, dcmFactories, false, null, !useBuddyRepl, true);
}
@@ -90,8 +91,6 @@
{
super.tearDown();
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
for (JBossCacheManager manager : managers)
manager.stop();
@@ -147,12 +146,12 @@
log.info("jbcmB1 stopped");
// Deploy again
- jbcmB1 = getCacheManager(warnameB, pojoCaches[1]);
+ jbcmB1 = getCacheManager(warnameB, dcmFactories[1]);
log.info("jbcmB1 started");
- log.info(pojoCaches[0].getCache().getMembers());
- log.info(pojoCaches[1].getCache().getMembers());
+// log.info(dcmFactories[0].getCache().getMembers());
+// log.info(dcmFactories[1].getCache().getMembers());
getHandler = new BasicRequestHandler(allAttributes.keySet(), false);
SessionTestUtil.invokeRequest(jbcmA1, getHandler, idA);
@@ -168,18 +167,18 @@
protected JBossCacheManager[] getCacheManagers(String warname)
throws Exception
{
- JBossCacheManager[] result = new JBossCacheManager[pojoCaches.length];
+ JBossCacheManager[] result = new JBossCacheManager[dcmFactories.length];
for (int i = 0; i < result.length; i++)
{
- result[i] = getCacheManager(warname, pojoCaches[i]);
+ result[i] = getCacheManager(warname, dcmFactories[i]);
}
return result;
}
- protected JBossCacheManager getCacheManager(String warname, PojoCache cache)
+ protected JBossCacheManager getCacheManager(String warname, TestDistributedCacheManagerFactory dcmFactory)
throws Exception
{
- JBossCacheManager jbcm = SessionTestUtil.createManager(warname, 100, cache, null);
+ JBossCacheManager jbcm = SessionTestUtil.createManager(warname, 100, dcmFactory, null);
JBossWebMetaData metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), true, 30);
jbcm.init(warname, metadata);
this.managers.add(jbcm);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -30,7 +30,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
@@ -39,6 +38,7 @@
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Unit tests of session expiration
@@ -47,8 +47,8 @@
*/
public class ReplicationToPassivatedSessionUnitTestCase extends TestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[2];
-
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[2];
+
protected static long testId = System.currentTimeMillis();
protected Logger log = Logger.getLogger(getClass());
@@ -64,7 +64,7 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, ReplicationToPassivatedSessionUnitTestCase.class.getSimpleName());
- return CacheConfigTestSetup.getTestSetup(ReplicationToPassivatedSessionUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), true, false);
+ return CacheConfigTestSetup.getTestSetup(ReplicationToPassivatedSessionUnitTestCase.class, dcmFactories, false, root.getAbsolutePath(), true, false);
}
@Override
@@ -76,8 +76,6 @@
}
finally
{
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
for (JBossCacheManager manager : managers)
manager.stop();
@@ -162,13 +160,13 @@
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxIdle, int maxUnreplicated)
throws Exception
{
- JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[0], null);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[0], null);
JBossWebMetaData metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1, true, maxUnreplicated);
jbcm0.init(warname, metadata);
this.managers.add(jbcm0);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[1], null);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[1], null);
metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1, true, -1);
jbcm1.init(warname, metadata);
this.managers.add(jbcm1);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -30,7 +30,6 @@
import junit.framework.Test;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
@@ -42,6 +41,7 @@
import org.jboss.test.cluster.web.mocks.MutableObject;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Tests of handling of ClusteredSession.maxUnreplicatedInterval. This base
@@ -51,8 +51,8 @@
*/
public class SessionBasedMaxUnreplicatedIntervalTestCase extends JBossTestCase
{
- protected static PojoCache[] pojoCaches = new PojoCache[2];
-
+ protected static TestDistributedCacheManagerFactory[] dcmFactories = new TestDistributedCacheManagerFactory[2];
+
protected static long testId = System.currentTimeMillis();
protected static boolean useBuddyRepl = Boolean.valueOf(System.getProperty("jbosstest.cluster.web.cache.br")).booleanValue();
@@ -72,7 +72,7 @@
public static Test suite() throws Exception
{
- return CacheConfigTestSetup.getTestSetup(SessionBasedMaxUnreplicatedIntervalTestCase.class, pojoCaches, false, null, !useBuddyRepl, false);
+ return CacheConfigTestSetup.getTestSetup(SessionBasedMaxUnreplicatedIntervalTestCase.class, dcmFactories, false, null, !useBuddyRepl, false);
}
@@ -102,8 +102,6 @@
{
super.tearDown();
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
for (JBossCacheManager manager : managers)
manager.stop();
@@ -286,13 +284,13 @@
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxUnreplicated)
throws Exception
{
- JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[0], null);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[0], null);
JBossWebMetaData metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), true, maxUnreplicated);
jbcm0.init(warname, metadata);
this.managers.add(jbcm0);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, pojoCaches[1], null);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager(warname, maxInactive, dcmFactories[1], null);
metadata = SessionTestUtil.createWebMetaData(getReplicationGranularity(), getReplicationTrigger(), true, maxUnreplicated);
jbcm1.init(warname, metadata);
this.managers.add(jbcm1);
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 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -30,14 +30,12 @@
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.web.jboss.JBossWebMetaData;
import org.jboss.test.cluster.testutil.JGroupsSystemPropertySupport;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Unit tests of session count management.
@@ -52,7 +50,7 @@
private static long testCount = System.currentTimeMillis();
private JGroupsSystemPropertySupport jgroupsSupport;
- private Set<PojoCache> caches = new HashSet<PojoCache>();
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
private String tempDir;
/**
@@ -91,41 +89,26 @@
{
try
{
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
// Restore any system properties we set in setUp
if (jgroupsSupport != null)
{
jgroupsSupport.restoreProperties();
}
- for (PojoCache cache : caches)
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- // 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"));
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
-
}
- caches.clear();
+ dcmFactories.clear();
}
finally
{
@@ -143,7 +126,7 @@
++testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2);
jbcm.init("test.war", webMetaData);
@@ -186,7 +169,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 1, -1);
jbcm.init("test.war", webMetaData);
@@ -240,7 +223,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 3, 1);
jbcm.init("test.war", webMetaData);
@@ -292,7 +275,7 @@
log.info("Enter testReplicatedMaxSessions");
++testCount;
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, null, false, false, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, null, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1);
jbcm0.init("test.war", webMetaData);
@@ -303,7 +286,7 @@
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, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, null, false, false, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -348,7 +331,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 1, -1);
jbcm0.init("test.war", webMetaData);
@@ -361,7 +344,7 @@
assertEquals("Correct min idle time", -1, jbcm0.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -411,7 +394,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 3, 1);
jbcm0.init("test.war", webMetaData);
@@ -424,7 +407,7 @@
assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, false, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -475,7 +458,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, false, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 3, 1);
jbcm0.init("test.war", webMetaData);
@@ -488,7 +471,7 @@
assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, false, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, false, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -535,7 +518,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, true, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, true, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 3, 1);
jbcm0.init("test.war", webMetaData);
@@ -548,7 +531,7 @@
assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, true, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, false, true, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -595,7 +578,7 @@
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, true, null, caches);
+ JBossCacheManager jbcm0 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, true, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(1, true, 3, 1);
jbcm0.init("test.war", webMetaData);
@@ -608,7 +591,7 @@
assertEquals("Correct min idle time", 1, jbcm0.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, true, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 1, false, passDir, true, true, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
@@ -668,8 +651,8 @@
{
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, true, passDir, false, false, null, caches);
- PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ TestDistributedCacheManagerFactory factory = SessionTestUtil.createTestDistributedCacheManagerFactory(true, passDir, false, false, false, dcmFactories);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, factory, null);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 3, 1);
jbcm.init("test.war", webMetaData);
@@ -712,16 +695,15 @@
if (restartCache)
{
- cache.stop();
- cache.destroy();
- caches.remove(cache);
+ factory.cleanup(false);
+ dcmFactories.remove(factory);
passDir = getPassivationDir(testCount, 1);
- jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, caches);
+ jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, dcmFactories);
}
else
{
- jbcm = SessionTestUtil.createManager("test" + testCount, 5, cache, null);
+ jbcm = SessionTestUtil.createManager("test" + testCount, 5, factory, null);
}
jbcm.init("test.war", webMetaData);
@@ -783,8 +765,8 @@
{
++testCount;
String passDir = getPassivationDir(testCount, 1);
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
- PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ TestDistributedCacheManagerFactory factory = SessionTestUtil.createTestDistributedCacheManagerFactory(false, passDir, totalReplication, marshalling, purgeOnStartStop, dcmFactories);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, factory, null);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 30, 1);
jbcm.init("test.war", webMetaData);
@@ -797,14 +779,14 @@
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
- PojoCache cache1 = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ TestDistributedCacheManagerFactory factory1 = SessionTestUtil.createTestDistributedCacheManagerFactory(false, passDir, totalReplication, marshalling, purgeOnStartStop, dcmFactories);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, factory1, null);
jbcm1.init("test.war", webMetaData);
jbcm1.start();
- SessionTestUtil.blockUntilViewsReceived(new Cache[]{ cache.getCache(), cache1.getCache()}, 10000);
+ SessionTestUtil.blockUntilViewsReceived(new TestDistributedCacheManagerFactory[]{ factory, factory1 }, 10000);
assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm1.getMaxActiveAllowed());
@@ -855,26 +837,24 @@
if (fullRestart)
{
jbcm1.stop();
- cache1.stop();
- cache1.destroy();
- caches.remove(cache1);
+ factory1.cleanup(false);
+ dcmFactories.remove(factory1);
}
jbcm.stop();
if (restartCache)
{
- cache.stop();
- cache.destroy();
- caches.remove(cache);
+ factory.cleanup(false);
+ dcmFactories.remove(factory);
passDir = getPassivationDir(testCount, 1);
- jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, purgeOnStartStop, null, caches);
- cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
+ factory = SessionTestUtil.createTestDistributedCacheManagerFactory(false, passDir, totalReplication, marshalling, purgeOnStartStop, dcmFactories);
+ jbcm = SessionTestUtil.createManager("test" + testCount, 300, factory, null);
}
else
{
- jbcm = SessionTestUtil.createManager("test" + testCount, 300, cache, null);
+ jbcm = SessionTestUtil.createManager("test" + testCount, 300, factory, null);
}
jbcm.init("test.war", webMetaData);
@@ -888,12 +868,13 @@
// Do we expect content?
boolean expectContent = true;
// First, see if we expect a purge on redeploy
- boolean expectPurge = purgeOnStartStop && (!totalReplication || marshalling);
+// boolean expectPurge = purgeOnStartStop && (!totalReplication || marshalling);
+ boolean expectPurge = purgeOnStartStop && restartCache;
// Even with a purge, if the other cache is available we may have state transfer
// on redeploy
- if (expectPurge && !fullRestart)
+ if (expectPurge)
{
- expectContent = (restartCache || !totalReplication || marshalling);
+ expectContent = !fullRestart && (!totalReplication || marshalling);
}
if (expectContent)
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionExpirationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionExpirationUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionExpirationUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -35,6 +35,7 @@
import org.jboss.test.cluster.testutil.JGroupsSystemPropertySupport;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Unit tests of session expiration
@@ -51,8 +52,8 @@
private static long testCount = System.currentTimeMillis();
private JGroupsSystemPropertySupport jgroupsSupport;
- private Set<PojoCache> caches = new HashSet<PojoCache>();
-
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
+
/**
* Create a new SessionExpirationUnitTestCase.
*
@@ -80,40 +81,26 @@
}
finally
{
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
// Restore any system properties we set in setUp
if (jgroupsSupport != null)
{
jgroupsSupport.restoreProperties();
}
- for (PojoCache cache : caches)
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- // 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"));
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
}
- caches.clear();
+ dcmFactories.clear();
}
}
@@ -128,14 +115,14 @@
++testCount;
- JBossCacheManager jbcm0= SessionTestUtil.createManager("test" + testCount, 5, false, null, true, true, null, caches);
+ JBossCacheManager jbcm0= SessionTestUtil.createManager("test" + testCount, 5, false, null, true, true, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2);
jbcm0.init("test.war", webMetaData);
jbcm0.start();
- JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 5, false, null, true, true, null, caches);
+ JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 5, false, null, true, true, null, dcmFactories);
jbcm1.init("test.war", webMetaData);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/StoppedManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/StoppedManagerUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/StoppedManagerUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -35,6 +35,7 @@
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* Tests that a stopped session manager reacts correctly to Manager API calls.
@@ -49,7 +50,7 @@
private static long testCount = System.currentTimeMillis();
- private Set<PojoCache> caches = new HashSet<PojoCache>();
+ private Set<TestDistributedCacheManagerFactory> dcmFactories = new HashSet<TestDistributedCacheManagerFactory>();
/**
* Create a new SessionCountUnitTestCase.
@@ -70,35 +71,22 @@
}
finally
{
- SessionTestUtil.clearDistributedCacheManagerFactory();
+
- for (PojoCache cache : caches)
+ for (TestDistributedCacheManagerFactory factory : dcmFactories)
{
- // 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"));
+ factory.cleanup(true);
}
catch (Exception e)
{
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
-
}
- caches.clear();
+ dcmFactories.clear();
}
}
@@ -108,7 +96,7 @@
++testCount;
- JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 30, true, null, false, false, null, caches);
+ JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 30, true, null, false, false, null, dcmFactories);
JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(100);
jbcm.init("test.war", webMetaData);
Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/TreeCacheSSOClusterManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/TreeCacheSSOClusterManagerUnitTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/TreeCacheSSOClusterManagerUnitTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -1,678 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.simpleweb.test;
-
-import java.util.Vector;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.Manager;
-import org.apache.catalina.Session;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.session.StandardManager;
-import org.apache.catalina.session.StandardSession;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.buddyreplication.NextMemberBuddyLocatorConfig;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationRegistry;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.jmx.CacheJmxWrapper;
-import org.jboss.cache.notifications.event.EventImpl;
-import org.jboss.cache.notifications.event.Event.Type;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapper;
-import org.jboss.cache.transaction.BatchModeTransactionManager;
-import org.jboss.ha.cachemanager.CacheManager;
-import org.jboss.ha.cachemanager.DependencyInjectedConfigurationRegistry;
-import org.jboss.ha.framework.server.JChannelFactory;
-import org.jboss.test.JBossTestCase;
-import org.jboss.test.cluster.testutil.DelegatingMockCache;
-import org.jboss.test.cluster.testutil.MockTransactionManagerLookup;
-import org.jboss.test.cluster.web.mocks.MockEngine;
-import org.jboss.test.cluster.web.mocks.MockHost;
-import org.jboss.util.threadpool.BasicThreadPool;
-import org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn;
-import org.jboss.web.tomcat.service.sso.jbc.JBossCacheSSOClusterManager;
-import org.jboss.web.tomcat.service.sso.spi.FullyQualifiedSessionId;
-import org.jgroups.Address;
-import org.jgroups.View;
-import org.jgroups.ViewId;
-import org.jgroups.stack.IpAddress;
-
-/**
- * Test of the JBossCacheSSOClusterManager class.
- *
- * @author Brian Stansberry
- */
-public class TreeCacheSSOClusterManagerUnitTestCase extends JBossTestCase
-{
- /**
- * Default global value for the cacheName property
- */
- public static final String CACHE_OBJECT_NAME = "jboss.cache:service=ClusteredSSOCache";
-
- private static IpAddress LOCAL_ADDRESS;
- private static IpAddress REMOTE_ADDRESS;
-
- private String bindAddress;
- private MBeanServer mbeanServer;
- private CacheManager cacheManager;
-
- public TreeCacheSSOClusterManagerUnitTestCase(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- bindAddress = System.getProperty("jgroups.bind.address");
- System.setProperty("jgroups.bind.address", "127.0.0.1");
-
- LOCAL_ADDRESS = new IpAddress("127.0.0.1", 11111);
- REMOTE_ADDRESS = new IpAddress("192.168.0.1", 11111);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- if (bindAddress == null)
- System.clearProperty("jgroups.bind.address");
- else
- System.setProperty("jgroups.bind.address", bindAddress);
-
- if (cacheManager != null)
- {
- cacheManager.stop();
- cacheManager = null;
- }
-
- if (mbeanServer != null)
- {
- MBeanServerFactory.releaseMBeanServer(mbeanServer);
- mbeanServer = null;
- }
- }
-
- public void testCacheJmxIntegration() throws Exception
- {
- log.debug("+++ testCacheJmxIntegration()");
-
- mbeanServer = MBeanServerFactory.createMBeanServer("cacheJmxTest");
- CacheJmxWrapper wrapper = null;
- try
- {
- // Register a cache
- wrapper = new CacheJmxWrapper();
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- wrapper.setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
- wrapper.setCacheMode("REPL_SYNC");
- mbeanServer.registerMBean(wrapper, new ObjectName(CACHE_OBJECT_NAME));
- wrapper.create();
- wrapper.start();
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(mbeanServer);
- localValve.setCacheConfig(CACHE_OBJECT_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
- localSSOManager.start();
-
- // Create an SSO that will have two sessions from local valve
- localSSOManager.register("1", "FORM", "Brian", "password");
-
- Manager localSessMgr1 = getSessionManager("A");
- Session sess1 = new MockSession(localSessMgr1, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
-
- Manager localSessMgr2 = getSessionManager("B");
- Session sess2 = new MockSession(localSessMgr2, "2");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
-
- // Confirm that data is cached properly
- assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
- }
- finally
- {
- try
- {
- if (wrapper != null)
- {
- wrapper.stop();
- wrapper.destroy();
- }
- }
- catch (Exception ignored)
- {
- }
- }
- }
-
- public void testPojoCacheJmxIntegration() throws Exception
- {
- log.debug("+++ testPojoCacheJmxIntegration()");
-
- mbeanServer = MBeanServerFactory.createMBeanServer("pojoCacheTest");
- PojoCacheJmxWrapper wrapper = null;
- try
- {
- // Register a cache
- wrapper = new PojoCacheJmxWrapper();
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- wrapper.setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
- wrapper.setCacheMode("REPL_SYNC");
- mbeanServer.registerMBean(wrapper, new ObjectName(CACHE_OBJECT_NAME));
- wrapper.create();
- wrapper.start();
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(mbeanServer);
- localValve.setCacheConfig(CACHE_OBJECT_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
- localSSOManager.start();
-
- // Create an SSO that will have two sessions from local valve
- localSSOManager.register("1", "FORM", "Brian", "password");
-
- Manager localSessMgr1 = getSessionManager("A");
- Session sess1 = new MockSession(localSessMgr1, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
-
- Manager localSessMgr2 = getSessionManager("B");
- Session sess2 = new MockSession(localSessMgr2, "2");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
-
- // Confirm that data is cached properly
- assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
- }
- finally
- {
- try
- {
- if (wrapper != null)
- {
- wrapper.stop();
- wrapper.destroy();
- }
- }
- catch (Exception ignored)
- {
- }
- }
- }
-
- public void testPojoCacheIntegration() throws Exception
- {
- log.debug("+++ testPojoCacheIntegration()");
-
- CacheManager cacheManager = getCacheManager();
-
- // Register a cache
- Configuration config = new Configuration();
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- config.setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
- config.setCacheMode("REPL_SYNC");
- PojoCache pc = PojoCacheFactory.createCache(config, false);
-
- cacheManager.registerPojoCache(pc, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(mbeanServer);
- localValve.setCacheConfig(ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
- localSSOManager.start();
-
- // Create an SSO that will have two sessions from local valve
- localSSOManager.register("1", "FORM", "Brian", "password");
-
- Manager localSessMgr1 = getSessionManager("A");
- Session sess1 = new MockSession(localSessMgr1, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
-
- Manager localSessMgr2 = getSessionManager("B");
- Session sess2 = new MockSession(localSessMgr2, "2");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
-
- // Confirm that data is cached properly
- assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
- }
-
- // Disabled; buddy replication is acceptable
- /*
- public void testDisallowBuddyReplication() throws Exception
- {
- log.debug("+++ testDisallowBuddyReplication()");
- buddyReplicationConfigTest(true);
-
- // Flush the cache manager
- cacheManager.stop();
- cacheManager = null;
-
- buddyReplicationConfigTest(false);
- }
-
-
- private void buddyReplicationConfigTest(boolean enabled) throws Exception
- {
- CacheManager cacheManager = getCacheManager();
-
- // Register a cache
- Cache cache = new DefaultCacheFactory().createCache(false);
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- cache.getConfiguration().setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
- cache.getConfiguration().setCacheMode("REPL_SYNC");
- // Configure buddy replication
- BuddyReplicationConfig brc = new BuddyReplicationConfig();
- brc.setEnabled(enabled);
- brc.setBuddyPoolName("clusteredsso");
- BuddyLocatorConfig blc = new NextMemberBuddyLocatorConfig();
- brc.setBuddyLocatorConfig(blc);
- cache.getConfiguration().setBuddyReplicationConfig(brc);
-
- cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(null);
- localValve.setCacheConfig(ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
-
- try
- {
- localSSOManager.start();
- if (enabled)
- {
- fail("JBossCacheSSOClusterManager should not start with buddy replication enabled");
- }
- }
- catch (LifecycleException le)
- {
- if (!enabled)
- {
- String msg = "Caught exception starting with BR disabled " + le.getLocalizedMessage();
- log.error(msg, le);
- fail(msg);
- }
- // else we shouldn't start
- }
- }
- */
-
- public void testDeadMemberCleanupWithPool() throws Exception
- {
- log.debug("+++ testDeadMemberCleanupWithPool()");
- deadMemberCleanupTest(true);
- }
-
- public void testDeadMemberCleanupWithoutPool() throws Exception
- {
- log.debug("+++ testDeadMemberCleanupWithoutPool()");
- deadMemberCleanupTest(false);
- }
-
- private void deadMemberCleanupTest(boolean usePool) throws Exception
- {
- mbeanServer = usePool ? MBeanServerFactory.createMBeanServer("deadMemberTest")
- : null;
-
- CacheManager cacheManager = getCacheManager();
- // Register a cache
- Cache<Object, Object> delegate = new DefaultCacheFactory<Object, Object>().createCache(false);
- MockTreeCache cache = new MockTreeCache(delegate);
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- cache.getConfiguration().getRuntimeConfig().setTransactionManager(new BatchModeTransactionManager());
-
- cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
-
- if (usePool)
- {
- BasicThreadPool pool = new BasicThreadPool();
- mbeanServer.registerMBean(pool, new ObjectName(JBossCacheSSOClusterManager.DEFAULT_THREAD_POOL_NAME));
- }
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(mbeanServer);
- localValve.setCacheConfig(ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
- localSSOManager.start();
-
- assertEquals("Thread pool usage as expected", usePool, localSSOManager.isUsingThreadPool());
-
- // Build up a second SSO infrastructure based on LOCAL_ADDRESS
- // It uses the same mock cache, but we change the cache address
- // so it thinks it's a different address when it starts
- cache.setOurAddress(REMOTE_ADDRESS);
-
- JBossCacheSSOClusterManager remoteSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve remoteValve = new MockSSOValve(mbeanServer);
- remoteValve.setCacheConfig(ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
- remoteValve.setClusterManager(remoteSSOManager);
- remoteSSOManager.setSSOLocalManager(localValve);
- remoteSSOManager.start();
-
-
- // Create an SSO that will have sessions from both valves
- localSSOManager.register("1", "FORM", "Brian", "password");
-
- Manager localSessMgr1 = getSessionManager("A");
- Session sess1 = new MockSession(localSessMgr1, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
-
- Manager remoteSessMgr1 = getSessionManager("B");
- Session sess2 = new MockSession(remoteSessMgr1, "2");
- remoteSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
-
-
- // Create another SSO with sessions only from remote
- remoteSSOManager.register("2", "FORM", "Brian", "password");
-
- Manager remoteSessMgr2 = getSessionManager("C");
- Session sess3 = new MockSession(remoteSessMgr2, "3");
- remoteSSOManager.addSession("2", getFullyQualifiedSessionId(sess3));
-
- Manager remoteSessMgr3 = getSessionManager("D");
- Session sess4 = new MockSession(remoteSessMgr3, "4");
- remoteSSOManager.addSession("2", getFullyQualifiedSessionId(sess4));
-
-
- // Create a third SSO that will have sessions from both valves
- // with the same session id
- localSSOManager.register("3", "FORM", "Brian", "password");
-
- Manager localSessMgr2 = getSessionManager("E");
- Session sess5 = new MockSession(localSessMgr2, "5");
- localSSOManager.addSession("3", getFullyQualifiedSessionId(sess5));
-
- Manager remoteSessMgr4 = getSessionManager("E");
- Session sess6 = new MockSession(remoteSessMgr4, "5");
- remoteSSOManager.addSession("3", getFullyQualifiedSessionId(sess6));
-
-
- // Create a fourth SSO that will have two sessions from local valve
- localSSOManager.register("4", "FORM", "Brian", "password");
-
- Manager localSessMgr3 = getSessionManager("F");
- Session sess7 = new MockSession(localSessMgr3, "7");
- localSSOManager.addSession("4", getFullyQualifiedSessionId(sess7));
-
- Manager localSessMgr4 = getSessionManager("G");
- Session sess8 = new MockSession(localSessMgr4, "8");
- localSSOManager.addSession("4", getFullyQualifiedSessionId(sess8));
-
-
- // Create a fifth SSO with sessions only from remote, same session id
- // but different managers
- remoteSSOManager.register("5", "FORM", "Brian", "password");
-
- Manager remoteSessMgr5 = getSessionManager("H");
- Session sess9 = new MockSession(remoteSessMgr5, "9");
- remoteSSOManager.addSession("5", getFullyQualifiedSessionId(sess9));
-
- Manager remoteSessMgr6 = getSessionManager("I");
- Session sess10 = new MockSession(remoteSessMgr6, "9");
- remoteSSOManager.addSession("5", getFullyQualifiedSessionId(sess10));
-
- // Confirm that data is cached properly
- assertEquals("SSO 1 has correct number of sessions", 2, localSSOManager.getSessionCount("1"));
- assertEquals("SSO 1 has correct number of sessions", 2, remoteSSOManager.getSessionCount("1"));
- assertEquals("SSO 2 has correct number of sessions", 2, localSSOManager.getSessionCount("2"));
- assertEquals("SSO 2 has correct number of sessions", 2, remoteSSOManager.getSessionCount("2"));
- assertEquals("SSO 3 has correct number of sessions", 2, localSSOManager.getSessionCount("3"));
- assertEquals("SSO 3 has correct number of sessions", 2, remoteSSOManager.getSessionCount("3"));
- assertEquals("SSO 4 has correct number of sessions", 2, localSSOManager.getSessionCount("4"));
- assertEquals("SSO 4 has correct number of sessions", 2, remoteSSOManager.getSessionCount("4"));
- assertEquals("SSO 5 has correct number of sessions", 2, localSSOManager.getSessionCount("5"));
- assertEquals("SSO 5 has correct number of sessions", 2, remoteSSOManager.getSessionCount("5"));
-
- // Put in a new view with REMOTE_ADDRESS dead
- ViewId viewId = new ViewId(LOCAL_ADDRESS, 1);
- Vector v = new Vector();
- v.add(LOCAL_ADDRESS);
- EventImpl event = new EventImpl();
- event.setNewView(new View(viewId, v));
- event.setType(Type.VIEW_CHANGED);
- event.setPre(false);
-
- localSSOManager.viewChange(event);
-
- // Give the cleanup thread time to finish
- Thread.sleep(2000);
-
- // Confirm that cached data is properly cleaned up
- assertEquals("SSO 1 has correct number of sessions", 1, localSSOManager.getSessionCount("1"));
- assertEquals("SSO 2 has correct number of sessions", 0, localSSOManager.getSessionCount("2"));
- assertEquals("SSO 3 has correct number of sessions", 1, localSSOManager.getSessionCount("3"));
- assertEquals("SSO 4 has correct number of sessions", 2, localSSOManager.getSessionCount("4"));
- assertEquals("SSO 5 has correct number of sessions", 0, localSSOManager.getSessionCount("5"));
- }
-
- /**
- * Test for JBAS-5609 -- confirm that if sessions from different managers
- * but with the same session id are registered, the removal of one leaves
- * the SSO in the proper state.
- */
- public void testSameSessionId() throws Exception
- {
- CacheManager cacheManager = getCacheManager();
- // Register a cache
- Cache<Object, Object> delegate = new DefaultCacheFactory<Object, Object>().createCache(false);
- MockTreeCache cache = new MockTreeCache(delegate);
- // JBAS-4097 -- don't use a TransactionManagerLookup that will
- // bind DummyTransactionManager into JNDI, as that will screw
- // up other tests
- cache.getConfiguration().getRuntimeConfig().setTransactionManager(new BatchModeTransactionManager());
-
- cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
-
- // Build up an SSO infrastructure based on LOCAL_ADDRESS
- JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
-
- MockSSOValve localValve = new MockSSOValve(mbeanServer);
- localValve.setCacheConfig(ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
- localValve.setClusterManager(localSSOManager);
- localSSOManager.setSSOLocalManager(localValve);
- localSSOManager.start();
-
-
- // Create an SSO that will have sessions from both valves
- localSSOManager.register("1", "FORM", "Brian", "password");
-
- Manager localSessMgr1 = getSessionManager("A");
- Session sess1 = new MockSession(localSessMgr1, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess1));
-
- Manager localSessMgr2 = getSessionManager("B");
- Session sess2 = new MockSession(localSessMgr2, "1");
- localSSOManager.addSession("1", getFullyQualifiedSessionId(sess2));
-
- assertEquals(2, localSSOManager.getSessionCount("1"));
-
- localSSOManager.removeSession("1", getFullyQualifiedSessionId(sess2));
-
- assertEquals(1, localSSOManager.getSessionCount("1"));
- }
-
- private CacheManager getCacheManager() throws Exception
- {
- if (cacheManager == null)
- {
- JChannelFactory channelFactory = new JChannelFactory();
- ConfigurationRegistry registry = new DependencyInjectedConfigurationRegistry();
- cacheManager = new CacheManager(registry, channelFactory);
- cacheManager.start();
- }
- return cacheManager;
- }
-
- private Manager getSessionManager(String contextName)
- {
- StandardManager mgr = new StandardManager();
- MockEngine engine = new MockEngine();
- MockHost host = new MockHost();
- host.setName("localhost");
- engine.addChild(host);
- StandardContext container = new StandardContext();
- container.setName(contextName);
- host.addChild(container);
- container.setManager(mgr);
-
- return mgr;
- }
-
- private FullyQualifiedSessionId getFullyQualifiedSessionId(Session session)
- {
- String id = session.getIdInternal();
- Container context = session.getManager().getContainer();
- String contextName = context.getName();
- Container host = context.getParent();
- String hostName = host.getName();
-
- return new FullyQualifiedSessionId(id, contextName, hostName);
- }
-
-
- static class MockTreeCache extends DelegatingMockCache
- {
- private IpAddress ourAddress = LOCAL_ADDRESS;
-
- public MockTreeCache(Cache delegate) throws Exception
- {
- super(delegate);
- getConfiguration().setCacheMode(CacheMode.LOCAL);
- }
-
- @Override
- public Address getLocalAddress()
- {
- return ourAddress;
- }
-
- void setOurAddress(IpAddress address)
- {
- ourAddress = address;
- }
-
- @Override
- public Vector getMembers()
- {
- Vector v = new Vector();
- v.add(LOCAL_ADDRESS);
- v.add(REMOTE_ADDRESS);
- return v;
- }
-
- }
-
- /**
- * Override ClusteredSingleSignOn to suppress the empty SSO callbacks
- */
- static class MockSSOValve extends ClusteredSingleSignOn
- {
- private final MBeanServer mbeanServer;
-
- MockSSOValve(MBeanServer server)
- {
- this.mbeanServer = server;
- }
-
- @Override
- public MBeanServer getMBeanServer()
- {
- return mbeanServer;
- }
-
- @Override
- public void notifySSOEmpty(String ssoId)
- {
- // no-op
- }
-
- @Override
- public void notifySSONotEmpty(String ssoId)
- {
- // no-op
- }
- }
-
- static class MockSession extends StandardSession
- {
- private static final long serialVersionUID = 1L;
-
- private String ourId;
-
- MockSession(Manager manager, String id)
- {
- super(manager);
- ourId = id;
- }
-
- @Override
- public String getId()
- {
- return ourId;
- }
-
- @Override
- public String getIdInternal()
- {
- return ourId;
- }
-
- }
-
-}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -233,8 +233,8 @@
{
// Make sure the cache is not stopped during redeploy due to
// no services using it. Tell CacheHelper to hold a ref.
- String cacheConfigName = System.getProperty(CacheHelper.CACHE_CONFIG_PROP, "standard-session-cache");
- String usePojoCache = System.getProperty(CacheHelper.CACHE_TYPE_PROP, "false");
+ String cacheConfigName = System.getProperty(SessionTestUtil.CACHE_CONFIG_PROP, "standard-session-cache");
+ String usePojoCache = System.getProperty(SessionTestUtil.CACHE_TYPE_PROP, "false");
SessionTestUtil.setCacheConfigName(adaptors[0], cacheConfigName, Boolean.parseBoolean(usePojoCache));
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -29,9 +29,9 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.cache.pojo.PojoCache;
import org.jboss.logging.Logger;
import org.jboss.test.JBossTestSetup;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
* @author Brian Stansberry
@@ -41,15 +41,15 @@
{
private static final Logger log = Logger.getLogger(CacheConfigTestSetup.class);
- public static Test getTestSetup(Class clazz, final PojoCache[] caches, final boolean local, final String passivationDir, final boolean totalReplication, final boolean marshalling)
+ public static Test getTestSetup(Class<?> clazz, final TestDistributedCacheManagerFactory[] dcmFactories, final boolean local, final String passivationDir, final boolean totalReplication, final boolean marshalling)
throws Exception
{
final TestSuite suite = new TestSuite();
suite.addTest(new TestSuite(clazz));
- return new CacheConfigTestSetup(suite, caches, local, passivationDir, totalReplication, marshalling);
+ return new CacheConfigTestSetup(suite, dcmFactories, local, passivationDir, totalReplication, marshalling);
}
- private PojoCache[] pojoCaches;
+ private TestDistributedCacheManagerFactory[] dcmFactories;
private String passivationDir;
private boolean local;
private boolean totalReplication;
@@ -62,10 +62,10 @@
* @param test
* @throws Exception
*/
- public CacheConfigTestSetup(Test test, PojoCache[] caches, boolean local, String passivationDir, boolean totalReplication, final boolean marshalling) throws Exception
+ public CacheConfigTestSetup(Test test, TestDistributedCacheManagerFactory[] dcmFactories, boolean local, String passivationDir, boolean totalReplication, final boolean marshalling) throws Exception
{
super(test);
- this.pojoCaches = caches;
+ this.dcmFactories = dcmFactories;
this.passivationDir = passivationDir;
this.local = local;
this.totalReplication = totalReplication;
@@ -74,7 +74,7 @@
protected void setUp() throws Exception
{
- if (pojoCaches == null) return;
+ if (dcmFactories == null) return;
JGroupsSystemPropertySupport jgSupport = new JGroupsSystemPropertySupport();
try
@@ -97,14 +97,14 @@
}
}
long now = System.currentTimeMillis();
- for (int i = 0; i < pojoCaches.length; i++)
+ for (int i = 0; i < dcmFactories.length; i++)
{
String cacheStore = (passivationDir == null ? null : new File(passivationDir, String.valueOf( now + i)).getAbsolutePath());
if (cacheStore != null)
{
cleanupPaths.add(0, cacheStore);
}
- pojoCaches[i] = SessionTestUtil.createCache(local, cacheStore, totalReplication, marshalling, null);
+ dcmFactories[i] = SessionTestUtil.createTestDistributedCacheManagerFactory(local, cacheStore, totalReplication, marshalling, true, null);
}
}
finally
@@ -123,16 +123,14 @@
{
try
{
- if (pojoCaches != null)
+ if (dcmFactories != null)
{
- for (int i = 0; i < pojoCaches.length; i++)
+ for (int i = 0; i < dcmFactories.length; i++)
{
try
{
- PojoCache pc = pojoCaches[i];
- pojoCaches[i] = null;
- pc.stop();
- pc.destroy();
+ TestDistributedCacheManagerFactory factory = dcmFactories[i];
+ factory.cleanup(true);
}
catch (Exception ex)
{
Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/DelegatingMockCache.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/DelegatingMockCache.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/DelegatingMockCache.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -1,502 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.testutil;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jgroups.Address;
-
-/**
- * Cache impl that delegates all calls to a passed in object.
- * Meant to provide a base for overriding methods.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class DelegatingMockCache<K, V> implements Cache<K, V>
-{
-
- private final Cache<K, V> delegate;
-
- public DelegatingMockCache(Cache<K, V> delegate)
- {
- super();
- this.delegate = delegate;
- }
-
- public void addInterceptor(CommandInterceptor arg0, Class arg1)
- {
- delegate.addInterceptor(arg0, arg1);
- }
-
- public void addInterceptor(CommandInterceptor arg0, int arg1)
- {
- delegate.addInterceptor(arg0, arg1);
- }
-
- public void removeInterceptor(int arg0)
- {
- delegate.removeInterceptor(arg0);
- }
-
- public void startBatch()
- {
- delegate.startBatch();
- }
-
- public void endBatch(boolean arg0)
- {
- delegate.endBatch(arg0);
- }
-
- public void removeInterceptor(Class arg0)
- {
- // TODO Auto-generated method stub
-
- }
-
-// public void addInterceptor(Interceptor arg0, int arg1)
-// {
-// delegate.addInterceptor(arg0, arg1);
-// }
-//
-// public void addInterceptor(Interceptor arg0, Class arg1)
-// {
-// delegate.addInterceptor(arg0, arg1);
-// }
-//
-// public boolean exists(Fqn arg0)
-// {
-// return delegate.exists(arg0);
-// }
-//
-// public boolean exists(String arg0)
-// {
-// return delegate.exists(arg0);
-// }
-
-// public void fetchPartialState(List arg0, Fqn arg1) throws Exception
-// {
-// delegate.fetchPartialState(arg0, arg1);
-// }
-//
-// public void fetchPartialState(List arg0, Fqn arg1, Fqn arg2) throws Exception
-// {
-// delegate.fetchPartialState(arg0, arg1, arg2);
-// }
-
-// public BuddyManager getBuddyManager()
-// {
-// return delegate.getBuddyManager();
-// }
-//
-// public CacheLoaderManager getCacheLoaderManager()
-// {
-// return delegate.getCacheLoaderManager();
-// }
-//
-// public Set getChildrenNames(Fqn arg0)
-// {
-// return delegate.getChildrenNames(arg0);
-// }
-//
-// public Set getChildrenNames(String arg0)
-// {
-// return delegate.getChildrenNames(arg0);
-// }
-//
-// public String getClusterName()
-// {
-// return delegate.getClusterName();
-// }
-//
-// public GlobalTransaction getCurrentTransaction()
-// {
-// return delegate.getCurrentTransaction();
-// }
-//
-// public GlobalTransaction getCurrentTransaction(Transaction arg0, boolean arg1)
-// {
-// return delegate.getCurrentTransaction(arg0, arg1);
-// }
-//
-// public List getInterceptorChain()
-// {
-// return delegate.getInterceptorChain();
-// }
-//
-// public Set getInternalFqns()
-// {
-// return delegate.getInternalFqns();
-// }
-
-// public Map getLockTable()
-// {
-// return delegate.getLockTable();
-// }
-
-// public Marshaller getMarshaller()
-// {
-// return delegate.getMarshaller();
-// }
-//
-// public Notifier getNotifier()
-// {
-// return delegate.getNotifier();
-// }
-//
-// public int getNumberOfAttributes()
-// {
-// return delegate.getNumberOfAttributes();
-// }
-//
-// public int getNumberOfLocksHeld()
-// {
-// return delegate.getNumberOfLocksHeld();
-// }
-//
-// public int getNumberOfNodes()
-// {
-// return delegate.getNumberOfNodes();
-// }
-//
-// public RPCManager getRPCManager()
-// {
-// return delegate.getRPCManager();
-// }
-//
-// public RegionManager getRegionManager()
-// {
-// return delegate.getRegionManager();
-// }
-//
-// public NodeSPI getRoot()
-// {
-// return delegate.getRoot();
-// }
-//
-// public StateTransferManager getStateTransferManager()
-// {
-// return delegate.getStateTransferManager();
-// }
-//
-// public TransactionManager getTransactionManager()
-// {
-// return delegate.getTransactionManager();
-// }
-//
-// public TransactionTable getTransactionTable()
-// {
-// return delegate.getTransactionTable();
-// }
-//
-// public GravitateResult gravitateData(Fqn arg0, boolean arg1)
-// {
-// return delegate.gravitateData(arg0, arg1);
-// }
-//
-// public NodeSPI peek(Fqn arg0, boolean arg1)
-// {
-// return delegate.peek(arg0, arg1);
-// }
-//
-// public NodeSPI peek(Fqn arg0, boolean arg1, boolean arg2)
-// {
-// return delegate.peek(arg0, arg1, arg2);
-// }
-//
-// public void removeInterceptor(int arg0)
-// {
-// delegate.removeInterceptor(arg0);
-// }
-//
-// public void removeInterceptor(Class arg0)
-// {
-// delegate.removeInterceptor(arg0);
-// }
-
- public Node getNode(Fqn arg0)
- {
- return delegate.getNode(arg0);
- }
-
- public Node getNode(String arg0)
- {
- return delegate.getNode(arg0);
- }
-
- public Node getRoot()
- {
- return delegate.getRoot();
- }
-
- public void addCacheListener(Object arg0)
- {
- delegate.addCacheListener(arg0);
- }
-
- public void addCacheListener(Fqn arg0, Object arg1)
- {
- //delegate.addCacheListener(arg0, arg1);
- }
-
- public void clearData(String arg0)
- {
- delegate.clearData(arg0);
- }
-
- public void clearData(Fqn arg0)
- {
- delegate.clearData(arg0);
- }
-
- public void create() throws CacheException
- {
- delegate.create();
- }
-
- public void destroy()
- {
- delegate.destroy();
- }
-
- public void evict(Fqn arg0)
- {
- delegate.evict(arg0);
- }
-
- public void evict(Fqn arg0, boolean arg1)
- {
- delegate.evict(arg0, arg1);
- }
-
- public V get(Fqn arg0, K arg1)
- {
- return delegate.get(arg0, arg1);
- }
-
- public V get(String arg0, K arg1)
- {
- return delegate.get(arg0, arg1);
- }
-
- public Set getCacheListeners()
- {
- return delegate.getCacheListeners();
- }
-
- public Set getCacheListeners(Fqn arg0)
- {
- return new HashSet<Object>();
- }
-
- public CacheStatus getCacheStatus()
- {
- return delegate.getCacheStatus();
- }
-
- public Configuration getConfiguration()
- {
- return delegate.getConfiguration();
- }
-
- public Map getData(Fqn arg0)
- {
- return delegate.getData(arg0);
- }
-
- public InvocationContext getInvocationContext()
- {
- return delegate.getInvocationContext();
- }
-
- public Set getKeys(String arg0)
- {
- return delegate.getKeys(arg0);
- }
-
- public Set getKeys(Fqn arg0)
- {
- return delegate.getKeys(arg0);
- }
-
- public Address getLocalAddress()
- {
- return delegate.getLocalAddress();
- }
-
- public List getMembers()
- {
- return delegate.getMembers();
- }
-
-// public NodeSPI getNode(Fqn arg0)
-// {
-// return delegate.getNode(arg0);
-// }
-//
-// public NodeSPI getNode(String arg0)
-// {
-// return delegate.getNode(arg0);
-// }
-
- public Region getRegion(Fqn arg0, boolean arg1)
- {
- return delegate.getRegion(arg0, arg1);
- }
-
- public String getVersion()
- {
- return delegate.getVersion();
- }
-
- public void move(Fqn arg0, Fqn arg1) throws NodeNotExistsException
- {
- delegate.move(arg0, arg1);
- }
-
- public void move(String arg0, String arg1) throws NodeNotExistsException
- {
- delegate.move(arg0, arg1);
- }
-
- public void put(Fqn arg0, Map arg1)
- {
- delegate.put(arg0, arg1);
- }
-
- public void put(String arg0, Map arg1)
- {
- delegate.put(arg0, arg1);
- }
-
- public V put(Fqn arg0, K arg1, V arg2)
- {
- return delegate.put(arg0, arg1, arg2);
- }
-
- public V put(String arg0, K arg1, V arg2)
- {
- return delegate.put(arg0, arg1, arg2);
- }
-
- public void putForExternalRead(Fqn arg0, K arg1, V arg2)
- {
- delegate.putForExternalRead(arg0, arg1, arg2);
- }
-
- public V remove(Fqn arg0, K arg1)
- {
- return delegate.remove(arg0, arg1);
- }
-
- public V remove(String arg0, K arg1)
- {
- return delegate.remove(arg0, arg1);
- }
-
- public void removeCacheListener(Object arg0)
- {
- delegate.removeCacheListener(arg0);
- }
-
- public void removeCacheListener(Fqn arg0, Object arg1)
- {
- //delegate.removeCacheListener(arg0, arg1);
- }
-
- public boolean removeNode(Fqn arg0)
- {
- return delegate.removeNode(arg0);
- }
-
- public boolean removeNode(String arg0)
- {
- return delegate.removeNode(arg0);
- }
-
- public boolean removeRegion(Fqn arg0)
- {
- return delegate.removeRegion(arg0);
- }
-
- public void setInvocationContext(InvocationContext arg0)
- {
- delegate.setInvocationContext(arg0);
- }
-
- public void start() throws CacheException
- {
- delegate.start();
- }
-
- public void stop()
- {
- delegate.stop();
- }
-
- public Set<Object> getChildrenNames(Fqn arg0)
- {
- // FIXME just delegate once we use JBC 3.1
- Node n = delegate.getRoot().getChild(arg0);
- return n == null ? Collections.emptySet() : n.getChildrenNames();
- }
-
- public Set<String> getChildrenNames(String arg0)
- {
- // FIXME just delegate once we use JBC 3.1
- Set<Object> names = getChildrenNames(Fqn.fromString(arg0));
- Set<String> result = new HashSet<String>();
- for (Object name : names)
- {
- result.add(name.toString());
- }
- return result;
- }
-
- public boolean isLeaf(Fqn arg0)
- {
- // FIXME just delegate once we use JBC 3.1
- return getChildrenNames(arg0).size() == 0;
- }
-
- public boolean isLeaf(String arg0)
- {
- // FIXME just delegate once we use JBC 3.1
- return isLeaf(Fqn.fromString(arg0));
- }
-
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/JBossCacheUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/JBossCacheUtil.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/JBossCacheUtil.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -1,175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009 Red Hat, Inc. 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.testutil;
-
-import java.util.List;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-
-/**
- * Utilities related to dealing with JBoss Cache.
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class JBossCacheUtil
-{
-
- /**
- * Loops, continually calling {@link #areCacheViewsComplete(org.jboss.cache.Cache[])}
- * until it either returns true or <code>timeout</code> ms have elapsed.
- *
- * @param caches caches which must all have consistent views
- * @param timeout max number of ms to loop
- * @throws RuntimeException if <code>timeout</code> ms have elapse without
- * all caches having the same number of members.
- */
- public static void blockUntilViewsReceived(Cache[] caches, long timeout)
- {
- long failTime = System.currentTimeMillis() + timeout;
-
- while (System.currentTimeMillis() < failTime)
- {
- sleepThread(100);
- if (areCacheViewsComplete(caches))
- {
- return;
- }
- }
-
- throw new RuntimeException("timed out before caches had complete views" + views(caches));
- }
-
- /**
- * Checks each cache to see if the number of elements in the array
- * returned by {@link CacheSPI#getMembers()} matches the size of
- * the <code>caches</code> parameter.
- *
- * @param caches caches that should form a View
- * @return <code>true</code> if all caches have
- * <code>caches.length</code> members; false otherwise
- * @throws IllegalStateException if any of the caches have MORE view
- * members than caches.length
- */
- public static boolean areCacheViewsComplete(Cache[] caches)
- {
- return areCacheViewsComplete(caches, true);
- }
-
- public static boolean areCacheViewsComplete(Cache[] caches, boolean barfIfTooManyMembers)
- {
- int memberCount = caches.length;
-
- for (int i = 0; i < memberCount; i++)
- {
- if (!isCacheViewComplete(caches[i], memberCount, barfIfTooManyMembers))
- {
- return false;
- }
- }
-
- return true;
- }
-
- public static boolean isCacheViewComplete(Cache c, int memberCount)
- {
- return isCacheViewComplete(c, memberCount, true);
- }
-
- public static boolean isCacheViewComplete(Cache cache, int memberCount, boolean barfIfTooManyMembers)
- {
- List members = cache.getMembers();
- if (members == null || memberCount > members.size())
- {
- return false;
- }
- else if (memberCount < members.size())
- {
- if (barfIfTooManyMembers)
- {
- // This is an exceptional condition
- StringBuilder sb = new StringBuilder("Cache at address ");
- sb.append(cache.getLocalAddress());
- sb.append(" had ");
- sb.append(members.size());
- sb.append(" members; expecting ");
- sb.append(memberCount);
- sb.append(". Members were (");
- for (int j = 0; j < members.size(); j++)
- {
- if (j > 0)
- {
- sb.append(", ");
- }
- sb.append(members.get(j));
- }
- sb.append(')');
-
- throw new IllegalStateException(sb.toString());
- }
- else return false;
- }
-
- return true;
- }
-
-
- /**
- * Puts the current thread to sleep for the desired number of ms, suppressing
- * any exceptions.
- *
- * @param sleeptime number of ms to sleep
- */
- public static void sleepThread(long sleeptime)
- {
- try
- {
- Thread.sleep(sleeptime);
- }
- catch (InterruptedException ie)
- {
- }
- }
-
- private static String views(Cache... caches)
- {
- StringBuilder builder = new StringBuilder("[\n");
- for (Cache c:caches)
- {
- builder.append(" ").append(c.getLocalAddress()).append("->").append(c.getMembers()).append("\n");
- }
- builder.append("]");
- return builder.toString();
- }
-
- /**
- * Prevent instantiation
- */
- private JBossCacheUtil()
- {
- // TODO Auto-generated constructor stub
- }
-
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockTransactionManagerLookup.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockTransactionManagerLookup.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockTransactionManagerLookup.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -1,44 +0,0 @@
-/*
- * 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.testutil;
-
-import javax.transaction.TransactionManager;
-
-import org.jboss.cache.transaction.BatchModeTransactionManager;
-import org.jboss.cache.transaction.TransactionManagerLookup;
-
-/**
- * Creates and returns a BatchModeTransactionManager.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class MockTransactionManagerLookup implements TransactionManagerLookup
-{
-
- public TransactionManager getTransactionManager() throws Exception
- {
- return new BatchModeTransactionManager();
- }
-
-}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -28,7 +28,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -46,16 +45,6 @@
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.loader.FileCacheLoaderConfig;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.spec.EmptyMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -73,10 +62,10 @@
import org.jboss.test.cluster.web.mocks.RequestHandler;
import org.jboss.test.cluster.web.mocks.RequestHandlerValve;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.impl.DistributedCacheManagerFactoryImpl;
import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactoryFactory;
-import org.jgroups.Address;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactoryFactory;
/**
* Utilities for session testing.
@@ -85,53 +74,42 @@
* @version $Revision$
*/
public class SessionTestUtil
-{
+{
+ public static final String CACHE_CONFIG_PROP = "jbosstest.cluster.web.cache.config";
+ public static final String CACHE_TYPE_PROP = "jbosstest.cluster.web.cache.pojo";
+
private static final Logger log = Logger.getLogger(SessionTestUtil.class);
private static final String[] STRING_ONLY_TYPES = { String.class.getName() };
private static final String[] STRING_BOOLEAN_TYPES = { String.class.getName(), boolean.class.getName() };
- private static final String CONFIG_LOCATION = "cluster/http/jboss-web-test-service.xml";
- private static DistributedCacheManagerFactoryImpl distributedManagerFactory;
- static
- {
- try
- {
- distributedManagerFactory = (DistributedCacheManagerFactoryImpl) DistributedCacheManagerFactoryFactory.getInstance().getDistributedCacheManagerFactory();
- }
- catch (ClusteringNotSupportedException e)
- {
- e.printStackTrace();
- }
- }
public static JBossCacheManager createManager(String warName, int maxInactiveInterval,
boolean local, String passivationDir,
boolean totalReplication, boolean marshalling,
- String jvmRoute, Set<PojoCache> allCaches)
+ String jvmRoute, Set<TestDistributedCacheManagerFactory> allFactories)
{
return createManager(warName, maxInactiveInterval, local, passivationDir,
- totalReplication, marshalling, false, jvmRoute, allCaches);
+ totalReplication, marshalling, false, jvmRoute, allFactories);
}
public static JBossCacheManager createManager(String warName, int maxInactiveInterval,
boolean local, String passivationDir,
boolean totalReplication, boolean marshalling,
boolean purgeCacheLoader,
- String jvmRoute, Set<PojoCache> allCaches)
+ String jvmRoute, Set<TestDistributedCacheManagerFactory> allFactories)
{
- PojoCache cache = createCache(local, passivationDir, totalReplication, marshalling, allCaches);
- return createManager(warName, maxInactiveInterval, cache, jvmRoute);
+ TestDistributedCacheManagerFactory factory = createTestDistributedCacheManagerFactory(local, passivationDir, totalReplication, marshalling, purgeCacheLoader, allFactories);
+ return createManager(warName, maxInactiveInterval, factory, jvmRoute);
}
public static JBossCacheManager createManager(String warName,
int maxInactiveInterval,
- PojoCache cache,
+ DistributedCacheManagerFactory factory,
String jvmRoute)
{
- if (distributedManagerFactory == null)
+ if (factory == null)
throw new IllegalStateException("Failed to initialize distributedManagerFactory");
- distributedManagerFactory.setPojoCache(cache);
- JBossCacheManager jbcm = new JBossCacheManager(distributedManagerFactory);
+ JBossCacheManager jbcm = new JBossCacheManager(factory);
jbcm.setSnapshotMode(SnapshotMode.INSTANT);
setupContainer(warName, jvmRoute, jbcm);
@@ -144,79 +122,24 @@
return jbcm;
}
- public static PojoCache createCache(boolean local, String passivationDir,
- boolean totalReplication, boolean marshalling, Set<PojoCache> allCaches)
+ public static TestDistributedCacheManagerFactory createTestDistributedCacheManagerFactory(boolean local, String passivationDir,
+ boolean totalReplication, boolean marshalling, boolean purgeCacheLoader, Set<TestDistributedCacheManagerFactory> allFactories)
{
- return createCache(local, passivationDir, totalReplication, marshalling, false, allCaches);
- }
-
- public static PojoCache createCache(boolean local, String passivationDir,
- boolean totalReplication, boolean marshalling, boolean purgeCacheLoader, Set<PojoCache> allCaches)
- {
- Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
- PojoCache cache = PojoCacheFactory.createCache(cfg, true);
-
- if (allCaches != null)
- allCaches.add(cache);
- return cache;
- }
-
- public static Configuration getConfiguration(boolean local, String passivationDir,
- boolean totalReplication, boolean marshalling, boolean purgeCacheLoader)
- {
- PojoCache temp = PojoCacheFactory.createCache(CONFIG_LOCATION, false);
- Configuration config = temp.getCache().getConfiguration();
- if (local)
- config.setCacheMode(CacheMode.LOCAL);
- if (passivationDir == null)
+
+ try
{
- config.setCacheLoaderConfig(null);
+ TestDistributedCacheManagerFactory factory = new TestDistributedCacheManagerFactoryFactory().getDistributedCacheManagerFactory(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
+ if (allFactories != null)
+ {
+ allFactories.add(factory);
+ }
+ return factory;
}
- else
+ catch (ClusteringNotSupportedException e)
{
- CacheLoaderConfig clc = config.getCacheLoaderConfig();
- FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
- fclc.setProperties(clc.getFirstCacheLoaderConfig().getProperties());
- fclc.setLocation(passivationDir);
- fclc.setFetchPersistentState(true);
- fclc.setPurgeOnStartup(purgeCacheLoader);
- ArrayList<IndividualCacheLoaderConfig> iclcs = new ArrayList<IndividualCacheLoaderConfig>();
- iclcs.add(fclc);
- clc.setIndividualCacheLoaderConfigs(iclcs);
+ throw new RuntimeException(e);
}
-
- BuddyReplicationConfig brc = config.getBuddyReplicationConfig();
- brc.setEnabled(!local && !totalReplication);
-
- config.setUseRegionBasedMarshalling(marshalling);
- config.setInactiveOnStartup(marshalling);
-
- // No async marshalling or notifications
- config.setSerializationExecutorPoolSize(0);
- config.setListenerAsyncPoolSize(0);
-
- // Block for commits -- no races between test driver and replication
- config.setSyncCommitPhase(true);
- config.setSyncRollbackPhase(true);
-
- return config;
- }
-
- public static PojoCache getDistributedCacheManagerFactoryPojoCache()
- {
- return distributedManagerFactory.getPojoCache();
- }
-
- @SuppressWarnings("unchecked")
- public static Cache<Object, Object> getDistributedCacheManagerFactoryPlainCache()
- {
- return distributedManagerFactory.getPlainCache();
}
-
- public static void clearDistributedCacheManagerFactory()
- {
- distributedManagerFactory.clearCaches();
- }
public static void setupContainer(String warName, String jvmRoute, Manager mgr)
{
@@ -274,7 +197,9 @@
repCfg.setReplicationTrigger(trigger);
repCfg.setReplicationFieldBatchMode(Boolean.valueOf(batchMode));
repCfg.setMaxUnreplicatedInterval(Integer.valueOf(maxUnreplicated));
+ repCfg.setSnapshotMode(SnapshotMode.INSTANT);
webMetaData.setReplicationConfig(repCfg);
+
return webMetaData;
}
@@ -416,23 +341,24 @@
return contextPath + "_" + hostname;
}
+
/**
- * Loops, continually calling {@link #areCacheViewsComplete(org.jboss.cache.Cache[])}
+ * Loops, continually calling {@link #areCacheViewsComplete(TestDistributedCacheManagerFactory[])}
* until it either returns true or <code>timeout</code> ms have elapsed.
*
- * @param caches caches which must all have consistent views
+ * @param dcmFactories caches which must all have consistent views
* @param timeout max number of ms to loop
* @throws RuntimeException if <code>timeout</code> ms have elapse without
* all caches having the same number of members.
*/
- public static void blockUntilViewsReceived(Cache<?, ?>[] caches, long timeout)
+ public static void blockUntilViewsReceived(TestDistributedCacheManagerFactory[] dcmFactories, long timeout)
{
long failTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < failTime)
{
sleepThread(100);
- if (areCacheViewsComplete(caches))
+ if (areCacheViewsComplete(dcmFactories))
{
return;
}
@@ -443,27 +369,27 @@
/**
* Checks each cache to see if the number of elements in the array
- * returned by {@link CacheSPI#getMembers()} matches the size of
- * the <code>caches</code> parameter.
+ * returned by {@link TestDistributedCacheFactory#getMembers()} matches the size of
+ * the <code>dcmFactories</code> parameter.
*
- * @param caches caches that should form a View
+ * @param dcmFactories factory whose caches should form a View
* @return <code>true</code> if all caches have
- * <code>caches.length</code> members; false otherwise
+ * <code>factories.length</code> members; false otherwise
* @throws IllegalStateException if any of the caches have MORE view
- * members than caches.length
+ * members than factories.length
*/
- public static boolean areCacheViewsComplete(Cache<?, ?>[] caches)
+ public static boolean areCacheViewsComplete(TestDistributedCacheManagerFactory[] dcmFactories)
{
- return areCacheViewsComplete(caches, true);
+ return areCacheViewsComplete(dcmFactories, true);
}
- public static boolean areCacheViewsComplete(Cache<?, ?>[] caches, boolean barfIfTooManyMembers)
+ public static boolean areCacheViewsComplete(TestDistributedCacheManagerFactory[] dcmFactories, boolean barfIfTooManyMembers)
{
- int memberCount = caches.length;
+ int memberCount = dcmFactories.length;
for (int i = 0; i < memberCount; i++)
{
- if (!isCacheViewComplete(caches[i], memberCount, barfIfTooManyMembers))
+ if (!isCacheViewComplete(dcmFactories[i], memberCount, barfIfTooManyMembers))
{
return false;
}
@@ -471,11 +397,10 @@
return true;
}
-
- public static boolean isCacheViewComplete(Cache<?, ?> c, int memberCount, boolean barfIfTooManyMembers)
+
+ public static boolean isCacheViewComplete(TestDistributedCacheManagerFactory factory, int memberCount, boolean barfIfTooManyMembers)
{
- CacheSPI<?, ?> cache = (CacheSPI<?, ?>) c;
- List<Address> members = cache.getMembers();
+ List<Object> members = factory.getMembers();
if (members == null || memberCount > members.size())
{
return false;
@@ -486,7 +411,7 @@
{
// This is an exceptional condition
StringBuffer sb = new StringBuffer("Cache at address ");
- sb.append(cache.getLocalAddress());
+ sb.append(factory.getLocalAddress());
sb.append(" had ");
sb.append(members.size());
sb.append(" members; expecting ");
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossCacheConfigTestSetupDelegate.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossCacheConfigTestSetupDelegate.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossCacheConfigTestSetupDelegate.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -9,6 +9,7 @@
import org.jboss.logging.Logger;
import org.jboss.test.JBossTestClusteredServices;
import org.jboss.test.JBossTestServices;
+import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.TestSetupDelegate;
/**
@@ -39,8 +40,8 @@
public void setUp() throws Exception
{
- cacheConfigName = System.getProperty(CacheHelper.CACHE_CONFIG_PROP);
- usePojoCache = System.getProperty(CacheHelper.CACHE_TYPE_PROP, "false");
+ cacheConfigName = System.getProperty(SessionTestUtil.CACHE_CONFIG_PROP);
+ usePojoCache = System.getProperty(SessionTestUtil.CACHE_TYPE_PROP, "false");
if (cacheConfigName != null || Boolean.parseBoolean(usePojoCache))
{
setServerSideCacheConfigProperties();
@@ -64,11 +65,11 @@
for (MBeanServerConnection adaptor : clusteredServices.getAdaptors())
{
adaptor.invoke(on, "set",
- new Object[]{CacheHelper.CACHE_CONFIG_PROP, cacheConfigName},
+ new Object[]{SessionTestUtil.CACHE_CONFIG_PROP, cacheConfigName},
new String[] {String.class.getName(), String.class.getName()});
adaptor.invoke(on, "set",
- new Object[]{CacheHelper.CACHE_TYPE_PROP, usePojoCache},
+ new Object[]{SessionTestUtil.CACHE_TYPE_PROP, usePojoCache},
new String[] {String.class.getName(), String.class.getName()});
}
}
@@ -79,11 +80,11 @@
for (MBeanServerConnection adaptor : clusteredServices.getAdaptors())
{
adaptor.invoke(on, "remove",
- new Object[]{CacheHelper.CACHE_CONFIG_PROP},
+ new Object[]{SessionTestUtil.CACHE_CONFIG_PROP},
new String[] {String.class.getName()});
adaptor.invoke(on, "remove",
- new Object[] {CacheHelper.CACHE_TYPE_PROP},
+ new Object[] {SessionTestUtil.CACHE_TYPE_PROP},
new String[] {String.class.getName()});
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java 2010-03-23 12:43:47 UTC (rev 102777)
@@ -31,6 +31,7 @@
import org.jboss.test.AbstractTestDelegate;
import org.jboss.test.JBossTestClusteredServices;
import org.jboss.test.cluster.testutil.DelegatingClusteredTestCase;
+import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.TestSetupDelegate;
/**
@@ -53,7 +54,7 @@
public String getCacheConfigName()
{
- return System.getProperty(CacheHelper.CACHE_CONFIG_PROP);
+ return System.getProperty(SessionTestUtil.CACHE_CONFIG_PROP);
}
public static Test getDeploySetup(Test test, String jarNames)
Deleted: trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml 2010-03-23 12:41:16 UTC (rev 102776)
+++ trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml 2010-03-23 12:43:47 UTC (rev 102777)
@@ -1,68 +0,0 @@
-<?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="NodeLockingScheme">PESSIMISTIC</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="SerializationExecutorPoolSize">0</attribute>
- <attribute name="ListenerAsyncPoolSize">0</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>
- <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>
More information about the jboss-cvs-commits
mailing list