[jboss-cvs] JBossAS SVN: r107761 - branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 24 09:48:13 EDT 2010
Author: pferraro
Date: 2010-08-24 09:48:12 -0400 (Tue, 24 Aug 2010)
New Revision: 107761
Modified:
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
Log:
Convert to infinispan.
Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2010-08-24 09:44:58 UTC (rev 107760)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2010-08-24 13:48:12 UTC (rev 107761)
@@ -29,8 +29,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.logging.Logger;
import org.jboss.test.JBossTestSetup;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
/**
@@ -39,8 +39,6 @@
*/
public class CacheConfigTestSetup extends JBossTestSetup
{
- private static final Logger log = Logger.getLogger(CacheConfigTestSetup.class);
-
public static Test getTestSetup(Class<?> clazz, final TestDistributedCacheManagerFactory[] dcmFactories, final boolean local, final String passivationDir, final boolean totalReplication, final boolean marshalling)
throws Exception
{
@@ -49,7 +47,7 @@
return new CacheConfigTestSetup(suite, dcmFactories, local, passivationDir, totalReplication, marshalling);
}
- private TestDistributedCacheManagerFactory[] dcmFactories;
+ private DistributedCacheManagerFactory[] dcmFactories;
private String passivationDir;
private boolean local;
private boolean totalReplication;
@@ -104,7 +102,7 @@
{
cleanupPaths.add(0, cacheStore);
}
- dcmFactories[i] = SessionTestUtil.createTestDistributedCacheManagerFactory(local, cacheStore, totalReplication, marshalling, true, null);
+ dcmFactories[i] = SessionTestUtil.createDistributedCacheManagerFactory(local, cacheStore, totalReplication, marshalling, true);
}
}
finally
@@ -121,31 +119,9 @@
protected void tearDown() throws Exception
{
- try
+ for (String path : cleanupPaths)
{
- if (dcmFactories != null)
- {
- for (int i = 0; i < dcmFactories.length; i++)
- {
- try
- {
- TestDistributedCacheManagerFactory factory = dcmFactories[i];
- factory.cleanup(true);
- }
- catch (Exception ex)
- {
- log.error("Failed stopping cache " + i);
- }
- }
- }
+ SessionTestUtil.cleanFilesystem(path);
}
- finally
- {
- for (String path : cleanupPaths)
- {
- SessionTestUtil.cleanFilesystem(path);
- }
- }
}
-
}
Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2010-08-24 09:44:58 UTC (rev 107760)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2010-08-24 13:48:12 UTC (rev 107761)
@@ -28,6 +28,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -45,6 +46,17 @@
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
+import org.infinispan.Cache;
+import org.infinispan.config.CacheLoaderManagerConfig;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.file.FileCacheStoreConfig;
+import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.transaction.tm.BatchModeTransactionManager;
+import org.infinispan.util.concurrent.IsolationLevel;
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.spec.EmptyMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -62,10 +74,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.spi.ClusteringNotSupportedException;
+import org.jboss.web.tomcat.service.session.distributedcache.ispn.CacheSource;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
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,19 +97,19 @@
public static JBossCacheManager createManager(String warName, int maxInactiveInterval,
boolean local, String passivationDir,
boolean totalReplication, boolean marshalling,
- String jvmRoute, Set<TestDistributedCacheManagerFactory> allFactories)
+ String jvmRoute) throws Exception
{
return createManager(warName, maxInactiveInterval, local, passivationDir,
- totalReplication, marshalling, false, jvmRoute, allFactories);
+ totalReplication, marshalling, false, jvmRoute);
}
public static JBossCacheManager createManager(String warName, int maxInactiveInterval,
boolean local, String passivationDir,
boolean totalReplication, boolean marshalling,
boolean purgeCacheLoader,
- String jvmRoute, Set<TestDistributedCacheManagerFactory> allFactories)
+ String jvmRoute) throws Exception
{
- TestDistributedCacheManagerFactory factory = createTestDistributedCacheManagerFactory(local, passivationDir, totalReplication, marshalling, purgeCacheLoader, allFactories);
+ DistributedCacheManagerFactory factory = createDistributedCacheManagerFactory(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
return createManager(warName, maxInactiveInterval, factory, jvmRoute);
}
@@ -122,23 +134,61 @@
return jbcm;
}
- public static TestDistributedCacheManagerFactory createTestDistributedCacheManagerFactory(boolean local, String passivationDir,
- boolean totalReplication, boolean marshalling, boolean purgeCacheLoader, Set<TestDistributedCacheManagerFactory> allFactories)
+ public static DistributedCacheManagerFactory createDistributedCacheManagerFactory(boolean local, String passivationDir,
+ boolean totalReplication, boolean marshalling, boolean purgeCacheLoader) throws Exception
{
-
- try
+ GlobalConfiguration globalConfig = new GlobalConfiguration();
+ globalConfig.setClusterName("Tomcat-TestCluster");
+
+ Configuration config = new Configuration();
+ config.setTransactionManagerLookupClass(BatchModeTransactionManager.class.getName());
+ config.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ config.setSyncReplTimeout(20000);
+ config.setLockAcquisitionTimeout(15000);
+ config.setCacheMode(local ? CacheMode.LOCAL : (totalReplication ? CacheMode.REPL_SYNC : CacheMode.DIST_SYNC));
+
+ // Block for commits -- no races between test driver and replication
+ config.setSyncCommitPhase(true);
+ config.setSyncRollbackPhase(true);
+
+ if (passivationDir != null)
{
- TestDistributedCacheManagerFactory factory = new TestDistributedCacheManagerFactoryFactory().getDistributedCacheManagerFactory(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
- if (allFactories != null)
- {
- allFactories.add(factory);
- }
- return factory;
+ CacheLoaderManagerConfig managerConfig = new CacheLoaderManagerConfig();
+ managerConfig.setPassivation(true);
+ managerConfig.setShared(true);
+
+ FileCacheStoreConfig fileConfig = new FileCacheStoreConfig();
+ fileConfig.setLocation(passivationDir);
+ fileConfig.setFetchPersistentState(true);
+ fileConfig.setPurgeOnStartup(purgeCacheLoader);
+ fileConfig.setIgnoreModifications(false);
+
+ managerConfig.setCacheLoaderConfigs(Collections.<CacheLoaderConfig>singletonList(fileConfig));
+
+ config.setCacheLoaderManagerConfig(managerConfig);
}
- catch (ClusteringNotSupportedException e)
+
+ if (config.getCacheMode().isDistributed())
{
- throw new RuntimeException(e);
+ config.setNumOwners(2);
}
+
+ final CacheContainer container = new DefaultCacheManager(globalConfig, config);
+
+ CacheSource source = new CacheSource()
+ {
+ @Override
+ public <K, V> Cache<K, V> getCache(LocalDistributableSessionManager manager)
+ {
+ return container.getCache();
+ }
+ };
+
+ org.jboss.web.tomcat.service.session.distributedcache.ispn.DistributedCacheManagerFactory factory = new org.jboss.web.tomcat.service.session.distributedcache.ispn.DistributedCacheManagerFactory();
+
+ factory.setCacheSource(source);
+
+ return factory;
}
public static void setupContainer(String warName, String jvmRoute, Manager mgr)
More information about the jboss-cvs-commits
mailing list