[jbosscache-commits] JBoss Cache SVN: r6438 - core/branches/2.2.X/src/test/java/org/jboss/cache/eviction.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Jul 30 08:05:50 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-07-30 08:05:49 -0400 (Wed, 30 Jul 2008)
New Revision: 6438
Modified:
core/branches/2.2.X/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
Log:
Better cleanup
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-30 12:03:28 UTC (rev 6437)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-30 12:05:49 UTC (rev 6438)
@@ -3,13 +3,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeEvicted;
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -21,26 +21,26 @@
@Test(groups = {"functional"})
public class ReplicatedLRUPolicyTest
{
- CacheSPI<Object, Object> cache_, cache1_, cache2_;
+ CacheSPI<Object, Object> cache1, cache2, cache3;
int wakeupIntervalMillis_ = 0;
EvictionListener listener_ = new EvictionListener();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache_ = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true), false);
- cache_.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache_.getConfiguration().setUseRegionBasedMarshalling(true);
- cache_.start();
- cache_.getNotifier().addCacheListener(listener_);
+ cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true), false);
+ cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache1.getConfiguration().setUseRegionBasedMarshalling(true);
+ cache1.start();
+ cache1.getNotifier().addCacheListener(listener_);
listener_.resetCounter();
- cache2_ = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
- cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2_.getConfiguration().setUseRegionBasedMarshalling(true);
- cache2_.start();
+ cache3 = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ cache3.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache3.getConfiguration().setUseRegionBasedMarshalling(true);
+ cache3.start();
- wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
+ wakeupIntervalMillis_ = cache1.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
log("wakeupInterval is " + wakeupIntervalMillis_);
if (wakeupIntervalMillis_ <= 0)
{
@@ -51,8 +51,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- cache_.stop();
- cache2_.stop();
+ TestingUtil.killCaches(cache1, cache2, cache3);
}
/**
@@ -62,13 +61,13 @@
{
String rootStr = "/org/jboss/test/data/";
String str = rootStr + "0";
- cache_.put(str, str, str);
+ cache1.put(str, str, str);
TestingUtil.sleepThread(30000);
- Object node = cache_.peek(Fqn.fromString(str), false);
+ Object node = cache1.peek(Fqn.fromString(str), false);
assertNull("DataNode should be evicted already ", node);
assertEquals("Eviction counter ", 1, listener_.getCounter());
- String val = (String) cache2_.get(str, str);
+ String val = (String) cache3.get(str, str);
assertNotNull("DataNode should not be evicted here ", val);
assertEquals("Eviction counter ", 1, listener_.getCounter());
}
@@ -80,13 +79,13 @@
{
String str = rootStr + i;
Fqn fqn = Fqn.fromString(str);
- cache_.put(fqn, str, str);
+ cache1.put(fqn, str, str);
}
TestingUtil.sleepThread(2 * wakeupIntervalMillis_);
- String val = (String) cache_.get(rootStr + "3", rootStr + "3");
+ String val = (String) cache1.get(rootStr + "3", rootStr + "3");
assertNull("DataNode should be evicted already ", val);
- val = (String) cache2_.get(rootStr + "3", rootStr + "3");
+ val = (String) cache3.get(rootStr + "3", rootStr + "3");
assertNotNull("DataNode should not be evicted here ", val);
}
@@ -97,18 +96,18 @@
{
String str = rootStr + i;
Fqn fqn = Fqn.fromString(str);
- cache_.put(fqn, str, str);
+ cache1.put(fqn, str, str);
}
TestingUtil.sleepThread(wakeupIntervalMillis_ - 1000);
String str = rootStr + "7";
Fqn fqn = Fqn.fromString(str);
- cache_.get(fqn, str);
+ cache1.get(fqn, str);
TestingUtil.sleepThread(wakeupIntervalMillis_);
- String val = (String) cache_.get(rootStr + "3", rootStr + "3");
+ String val = (String) cache1.get(rootStr + "3", rootStr + "3");
assertNull("DataNode should be empty ", val);
- val = (String) cache2_.get(rootStr + "7", rootStr + "7");
+ val = (String) cache3.get(rootStr + "7", rootStr + "7");
assertNotNull("DataNode should not be null", val);
}
More information about the jbosscache-commits
mailing list