Author: mircea.markus
Date: 2009-01-22 03:28:30 -0500 (Thu, 22 Jan 2009)
New Revision: 7566
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
Log:
more strict eviction controll
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2009-01-21
16:45:43 UTC (rev 7565)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2009-01-22
08:28:30 UTC (rev 7566)
@@ -22,11 +22,10 @@
/**
* @author Ben Wang, Feb 11, 2004
*/
-@Test(groups = {"functional"}, sequential = true, testName =
"eviction.ReplicatedLRUPolicyTest")
+@Test(groups = {"functional"}, testName =
"eviction.ReplicatedLRUPolicyTest")
public class ReplicatedLRUPolicyTest extends EvictionTestsBase
{
- CacheSPI<Object, Object> cache1, cache2, cache3;
- long wakeupIntervalMillis = 500;
+ CacheSPI<Object, Object> cache1, cache2;
EvictionListener listener = new EvictionListener();
@BeforeMethod(alwaysRun = true)
@@ -35,26 +34,25 @@
cache1 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC,
true), false, getClass());
cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache1.getConfiguration().setUseRegionBasedMarshalling(true);
-
cache1.getConfiguration().getEvictionConfig().setWakeupInterval(wakeupIntervalMillis);
+ cache1.getConfiguration().getEvictionConfig().setWakeupInterval(0);
cache1.start();
cache1.getNotifier().addCacheListener(listener);
listener.resetCounter();
- cache3 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(cache1.getConfiguration().clone(), false, getClass());
-
cache3.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache3.getConfiguration().setUseRegionBasedMarshalling(true);
-
cache3.getConfiguration().getEvictionConfig().setWakeupInterval(wakeupIntervalMillis);
- cache3.start();
+ cache2 = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object,
Object>().createCache(cache1.getConfiguration().clone(), false, getClass());
+
cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache2.getConfiguration().setUseRegionBasedMarshalling(true);
+ cache2.getConfiguration().getEvictionConfig().setWakeupInterval(0);
+ cache2.start();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- TestingUtil.killCaches(cache1, cache2, cache3);
+ TestingUtil.killCaches(cache1, cache2);
cache1 = null;
cache2 = null;
- cache3 = null;
}
/**
@@ -67,7 +65,7 @@
cfg.setMaxAge(0);
cfg.setTimeToLive(0);
- cfg = (LRUAlgorithmConfig)
cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
+ cfg = (LRUAlgorithmConfig)
cache2.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
cfg.setMaxAge(-1, TimeUnit.SECONDS);
cfg.setTimeToLive(-1, TimeUnit.SECONDS);
cfg.setMaxNodes(200);
@@ -75,12 +73,12 @@
String str = rootStr + "0";
Fqn fqn = Fqn.fromString(str);
cache1.put(str, str, str);
-// assert waitForEviction(cache1, 30, TimeUnit.SECONDS, fqn) : "Eviction event
not received!";
+
new EvictionController(cache1).startEviction();
Object node = cache1.peek(fqn, false);
assertNull("Node should be evicted already ", node);
assertEquals("Eviction counter ", 1, listener.getCounter());
- String val = (String) cache3.get(str, str);
+ String val = (String) cache2.get(str, str);
assertNotNull("DataNode should not be evicted here ", val);
assertEquals("Eviction counter ", 1, listener.getCounter());
}
@@ -88,11 +86,10 @@
public void testEviction() throws Exception
{
String rootStr = "/org/jboss/test/data/";
- LRUAlgorithmConfig cfg = (LRUAlgorithmConfig)
cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
+ LRUAlgorithmConfig cfg = (LRUAlgorithmConfig)
cache2.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
cfg.setMaxAge(60, TimeUnit.SECONDS);
cfg.setTimeToLive(360, TimeUnit.SECONDS);
cfg.setMaxNodes(200);
- EvictionWatcher ew = new EvictionWatcher(cache1, Fqn.fromString(rootStr + 3));
for (int i = 0; i < 10; i++)
{
String str = rootStr + i;
@@ -100,21 +97,20 @@
cache1.put(fqn, str, str);
}
- assert ew.waitForEviction(30, TimeUnit.SECONDS);
+ new EvictionController(cache1).startEviction();
String val = (String) cache1.get(rootStr + "3", rootStr +
"3");
assertNull("DataNode should be evicted already ", val);
- val = (String) cache3.get(rootStr + "3", rootStr + "3");
+ val = (String) cache2.get(rootStr + "3", rootStr + "3");
assertNotNull("DataNode should not be evicted here ", val);
}
public void testEvictionReplication() throws Exception
{
String rootStr = "/org/jboss/test/data/";
- LRUAlgorithmConfig cfg = (LRUAlgorithmConfig)
cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
+ LRUAlgorithmConfig cfg = (LRUAlgorithmConfig)
cache2.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
cfg.setMaxAge(60, TimeUnit.SECONDS);
cfg.setTimeToLive(360, TimeUnit.SECONDS);
- EvictionWatcher ew = new EvictionWatcher(cache1, Fqn.fromString(rootStr + 3));
for (int i = 0; i < 10; i++)
{
@@ -127,11 +123,11 @@
Fqn fqn = Fqn.fromString(str);
cache1.get(fqn, str);
- assert ew.waitForEviction(30, TimeUnit.SECONDS);
+ new EvictionController(cache1).startEviction();
String val = (String) cache1.get(rootStr + "3", rootStr +
"3");
assertNull("DataNode should be empty ", val);
- val = (String) cache3.get(rootStr + "7", rootStr + "7");
+ val = (String) cache2.get(rootStr + "7", rootStr + "7");
assertNotNull("DataNode should not be null", val);
}