[jbosscache-commits] JBoss Cache SVN: r7499 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Sun Jan 18 12:09:46 EST 2009
Author: mircea.markus
Date: 2009-01-18 12:09:45 -0500 (Sun, 18 Jan 2009)
New Revision: 7499
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
Log:
more strict eviction controll
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2009-01-18 16:31:42 UTC (rev 7498)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2009-01-18 17:09:45 UTC (rev 7499)
@@ -97,7 +97,7 @@
}
if (stop)
{
- c.stop();
+ TestingUtil.killCaches(c);
}
else
{
@@ -228,7 +228,7 @@
// allow some time for the cachePool to start up and discover each other
TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
- TestingUtil.sleepThread(getSleepTimeout());
+ waitForSingleBuddy(caches);
return caches;
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2009-01-18 16:31:42 UTC (rev 7498)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2009-01-18 17:09:45 UTC (rev 7499)
@@ -12,13 +12,9 @@
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.util.TestingUtil;
import static org.jboss.cache.util.TestingUtil.dumpCacheContents;
-import org.jboss.cache.util.internals.EvictionController;
import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
@@ -26,7 +22,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
/**
* Tests use of the data gravitator alongside other cache loaders as well as data gravitator options such as removeOnFind.
@@ -250,7 +245,6 @@
{
CacheSPI<Object, Object> cache1 = createCacheWithCacheLoader(true, true, passivation, true, false);
Configuration cfg1 = cache1.getConfiguration();
- configureEviction(cfg1);
Configuration cfg0 = cfg1.clone();
CacheSPI<Object, Object> cache0 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cfg0, false, getClass());
@@ -275,8 +269,8 @@
assert cache1.exists(backupFoo) : "Buddy should have data";
// Sleep long enough for eviction to run twice plus a bit
- new EvictionController(cache0).startEviction();
- new EvictionController(cache1).startEviction();
+ cache0.evict(foo);
+ cache1.evict(backupFoo);
// test that the data we're looking for has been evicted in both the data owner and the buddy.
assert !cache0.exists(foo) : "Data should have evicted in data owner";
@@ -300,7 +294,6 @@
{
CacheSPI<Object, Object> cache0 = createCacheWithCacheLoader(true, true, passivation, true, false);
Configuration cfg0 = cache0.getConfiguration();
- configureEviction(cfg0);
Configuration cfg1 = cfg0.clone();
CacheSPI<Object, Object> cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cfg1, false, getClass());
Configuration cfg2 = cfg0.clone();
@@ -331,9 +324,8 @@
assert cache0.exists(foo) : "Data should exist in data owner";
assert cache1.exists(backupFoo) : "Buddy should have data";
- // Kick eviction off!
- new EvictionController(cache0).startEviction();
- new EvictionController(cache1).startEviction();
+ cache0.evict(foo);
+ cache1.evict(backupFoo);
// test that the data we're looking for has been evicted in both the data owner and the buddy.
assert !cache0.exists(foo) : "Data should have evicted in data owner";
@@ -346,19 +338,4 @@
// doing a get on cache2 will guarantee a remote data gravitation.
assertEquals("Passivated value available from buddy", "value", cache2.get(foo, "key"));
}
-
- private void configureEviction(Configuration cfg)
- {
- EvictionConfig ec = new EvictionConfig();
- ec.setWakeupInterval(5000);
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setRegionFqn(Fqn.ROOT);
- LRUAlgorithmConfig lruAlgorithmConfig = new LRUAlgorithmConfig();
- lruAlgorithmConfig.setMaxAge(0);
- lruAlgorithmConfig.setTimeToLive(0);
- lruAlgorithmConfig.setMaxNodes(1);
- erc.setEvictionAlgorithmConfig(lruAlgorithmConfig);
- ec.setDefaultEvictionRegionConfig(erc);
- cfg.setEvictionConfig(ec);
- }
}
More information about the jbosscache-commits
mailing list