[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/statetransfer ...
Manik Surtani
msurtani at jboss.com
Thu Jul 20 04:05:18 EDT 2006
User: msurtani
Date: 06/07/20 04:05:18
Modified: tests/functional/org/jboss/cache/statetransfer
StateTransfer200Test.java
StateTransferTestBase.java VersionedTestBase.java
Log:
Fixed some broken UTs to use the new xml parsers, cache factories, etc.
Revision Changes Path
1.2 +9 -10 JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StateTransfer200Test.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- StateTransfer200Test.java 18 Jul 2006 21:19:35 -0000 1.1
+++ StateTransfer200Test.java 20 Jul 2006 08:05:18 -0000 1.2
@@ -10,7 +10,6 @@
import org.jboss.cache.DataNode;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheMBean;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Option;
import org.jboss.cache.misc.TestingUtil;
@@ -24,7 +23,7 @@
* Tests that state transfer works properly if the version is 2.0.0.GA.
*
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class StateTransfer200Test extends VersionedTestBase
{
@@ -36,9 +35,9 @@
public void testBuddyBackupExclusion() throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, false, false, false, false);
+ TreeCache cache1 = createCache("cache1", false, false, false, false, false);
- cache1.setBuddyReplicationConfig(getBuddyConfig());
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
cache1.startService();
@@ -46,10 +45,10 @@
cache1.put(backup, "name", JOE);
cache1.put("/a/b", "age", TWENTY);
- TreeCacheMBean cache2 = createCache("cache2", false, false, false);
+ TreeCache cache2 = createCache("cache2", false, false, false);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
assertNull("_buddy_backup_ not transferred", cache2.get(backup, "test"));
assertEquals("Correct age for /a/b", TWENTY, cache2.get("/a/b", "age"));
@@ -57,16 +56,16 @@
public void testBuddyIntegration() throws Exception
{
- TreeCache cache1 = (TreeCache) createCache("cache1", false, false, false, false, false);
+ TreeCache cache1 = createCache("cache1", false, false, false, false, false);
- cache1.setBuddyReplicationConfig(getBuddyConfig());
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
cache1.startService();
- TreeCache cache2 = (TreeCache) createCache("cache2", false, false, false);
+ TreeCache cache2 = createCache("cache2", false, false, false);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
Option option = new Option();
option.setCacheModeLocal(true);
1.18 +19 -20 JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StateTransferTestBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- StateTransferTestBase.java 5 May 2006 12:06:59 -0000 1.17
+++ StateTransferTestBase.java 20 Jul 2006 08:05:18 -0000 1.18
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
import org.jboss.cache.Fqn;
-import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;
@@ -59,7 +59,7 @@
protected abstract String getReplicationVersion();
- protected TreeCacheMBean createCache(String cacheID,
+ protected TreeCache createCache(String cacheID,
boolean sync,
boolean useMarshalling,
boolean useCacheLoader)
@@ -68,7 +68,7 @@
return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true);
}
- protected TreeCacheMBean createCache(String cacheID,
+ protected TreeCache createCache(String cacheID,
boolean sync,
boolean useMarshalling,
boolean useCacheLoader,
@@ -79,23 +79,25 @@
if (caches.get(cacheID) != null)
throw new IllegalStateException(cacheID + " already created");
- TreeCacheMBean tree=new TreeCache();
- PropertyConfigurator config=new PropertyConfigurator();
+ TreeCache tree=new TreeCache();
+ //PropertyConfigurator config=new PropertyConfigurator();
String configFile = sync ? "META-INF/replSync-service.xml"
: "META-INF/replAsync-service.xml";
- config.configure(tree, configFile); // read in generic replAsync xml
- tree.setClusterName("VersionedTestBase");
- tree.setReplicationVersion(getReplicationVersion());
+ //config.configure(tree, configFile); // read in generic replAsync xml
+ XmlConfigurationParser parser = new XmlConfigurationParser();
+ Configuration c = parser.parseFile(configFile);
+ c.setClusterName("VersionedTestBase");
+ c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
- tree.setInitialStateRetrievalTimeout(60000);
+ c.setInitialStateRetrievalTimeout(60000);
if (useMarshalling) {
- tree.setUseRegionBasedMarshalling(true);
- tree.setInactiveOnStartup(true);
+ c.setUseRegionBasedMarshalling(true);
+ c.setInactiveOnStartup(true);
}
if (useCacheLoader) {
- configureCacheLoader(tree, cacheID, useMarshalling, cacheLoaderAsync);
+ configureCacheLoader(c, cacheID, useMarshalling, cacheLoaderAsync);
}
-
+ tree.setConfiguration(c);
// Put the cache in the map before starting, so if it fails in
// start it can still be destroyed later
caches.put(cacheID, tree);
@@ -109,13 +111,13 @@
return tree;
}
- protected void startCache(TreeCacheMBean cache) throws Exception
+ protected void startCache(TreeCache cache) throws Exception
{
cache.createService();
cache.startService();
}
- protected void configureCacheLoader(TreeCacheMBean cache,
+ protected void configureCacheLoader(Configuration c,
String cacheID,
boolean useExtended,
boolean async)
@@ -131,10 +133,7 @@
tmp_location = escapeWindowsPath(tmp_location);
- if (useExtended)
- cache.setCacheLoaderConfiguration(getCacheLoaderConfig("org.jboss.cache.loader.FileExtendedCacheLoader", tmp_location, async));
- else
- cache.setCacheLoaderConfiguration(getCacheLoaderConfig("org.jboss.cache.loader.FileCacheLoader", tmp_location, async));
+ c.setCacheLoaderConfiguration(getCacheLoaderConfig("org.jboss.cache.loader.FileCacheLoader", tmp_location, async));
}
protected Element getCacheLoaderConfig(String cl, String loc, boolean async) throws Exception
1.7 +24 -24 JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VersionedTestBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- VersionedTestBase.java 5 May 2006 12:06:59 -0000 1.6
+++ VersionedTestBase.java 20 Jul 2006 08:05:18 -0000 1.7
@@ -11,7 +11,7 @@
import java.util.Random;
import org.jboss.cache.CacheException;
-import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.misc.TestingUtil;
@@ -33,17 +33,17 @@
public void testInitialStateTransfer() throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, false, false);
+ TreeCache cache1 = createCache("cache1", false, false, false);
cache1.put("/a/b", "name", JOE);
cache1.put("/a/b", "age", TWENTY);
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
- TreeCacheMBean cache2 = createCache("cache2", false, false, false);
+ TreeCache cache2 = createCache("cache2", false, false, false);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
@@ -63,19 +63,19 @@
private void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, false, true);
+ TreeCache cache1 = createCache("cache1", false, false, true);
cache1.put("/a/b", "name", JOE);
cache1.put("/a/b", "age", TWENTY);
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
- TreeCacheMBean cache2 = createCache("cache2", false, false, true, asyncLoader, false);
+ TreeCache cache2 = createCache("cache2", false, false, true, asyncLoader, false);
cache2.start();
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
if (asyncLoader)
TestingUtil.sleepThread((long)100);
@@ -95,7 +95,7 @@
public void testPartialStateTransfer() throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, true, false);
+ TreeCache cache1 = createCache("cache1", false, true, false);
cache1.activateRegion("/a");
@@ -104,10 +104,10 @@
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
- TreeCacheMBean cache2 = createCache("cache2", false, true, false);
+ TreeCache cache2 = createCache("cache2", false, true, false);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
assertNull("/a/b name transferred against policy", cache2.get("/a/b", "name"));
assertNull("/a/b age transferred against policy", cache2.get("/a/b", "age"));
@@ -156,7 +156,7 @@
public void testPartialStateTferWithLoader() throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, true, true);
+ TreeCache cache1 = createCache("cache1", false, true, true);
cache1.activateRegion("/a");
@@ -165,10 +165,10 @@
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
- TreeCacheMBean cache2 = createCache("cache2", false, true, true);
+ TreeCache cache2 = createCache("cache2", false, true, true);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
CacheLoader loader = cache2.getCacheLoader();
@@ -253,7 +253,7 @@
// Set the TCL to a classloader that can't see Person/Address
Thread.currentThread().setContextClassLoader(getNotFoundClassLoader());
- TreeCacheMBean cache1 = createCache("cache1",
+ TreeCache cache1 = createCache("cache1",
false, // async
true, // use marshaller
true, // use cacheloader
@@ -269,14 +269,14 @@
cache1.put("/a/b", "person", ben);
// For cache 2 we won't register loader until later
- TreeCacheMBean cache2 = createCache("cache2",
+ TreeCache cache2 = createCache("cache2",
false, // async
true, // use marshalling
true, // use cacheloader
false, true); // start
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
CacheLoader loader = cache2.getCacheLoader();
@@ -297,7 +297,7 @@
public void testLoadEntireStateAfterStart() throws Exception
{
- TreeCacheMBean cache1 = createCache("cache1", false, true, true);
+ TreeCache cache1 = createCache("cache1", false, true, true);
cache1.activateRegion("/");
@@ -306,10 +306,10 @@
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
- TreeCacheMBean cache2 = createCache("cache2", false, true, true);
+ TreeCache cache2 = createCache("cache2", false, true, true);
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
+ TestingUtil.blockUntilViewsReceived(new TreeCache[] { cache1, cache2 }, 60000);
CacheLoader loader = cache2.getCacheLoader();
@@ -386,7 +386,7 @@
}
// Create activation threads that will block on the semaphore
- TreeCacheMBean[] caches = new TreeCacheMBean[count];
+ TreeCache[] caches = new TreeCache[count];
for (int i = 0; i < count; i++) {
activators[i] = new CacheActivator(semaphore, names[i], sync);
caches[i] = activators[i].getTreeCache();
@@ -482,9 +482,9 @@
try {
// The first cache we create is inactivated.
- TreeCacheMBean cacheA = createCache("cacheA", sync, true, false);
+ TreeCache cacheA = createCache("cacheA", sync, true, false);
- TreeCacheMBean[] caches = new TreeCacheMBean[count + 1];
+ TreeCache[] caches = new TreeCache[count + 1];
caches[0] = cacheA;
// Create a semaphore and take all its tickets
@@ -713,7 +713,7 @@
private abstract class CacheUser implements Runnable
{
protected Semaphore semaphore;
- protected TreeCacheMBean cache;
+ protected TreeCache cache;
protected String name;
protected Exception exception;
protected Thread thread;
@@ -768,7 +768,7 @@
return exception;
}
- public TreeCacheMBean getTreeCache()
+ public TreeCache getTreeCache()
{
return cache;
}
More information about the jboss-cvs-commits
mailing list