Author: manik.surtani(a)jboss.com
Date: 2008-07-30 08:03:28 -0400 (Wed, 30 Jul 2008)
New Revision: 6437
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
Log:
proper cleanup
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-30
11:37:41 UTC (rev 6436)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java 2008-07-30
12:03:28 UTC (rev 6437)
@@ -21,26 +21,26 @@
@Test(groups = {"functional"})
public class ReplicatedLRUPolicyTest
{
- CacheSPI<Object, Object> cache_, cache1_, cache2_;
+ CacheSPI<Object, Object> cache1, cache2, cache3;
long wakeupIntervalMillis = 0;
EvictionListener listener_ = new EvictionListener();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache_ = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().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<Object,
Object>().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<Object,
Object>().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<Object,
Object>().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().getWakeupInterval();
+ wakeupIntervalMillis =
cache1.getConfiguration().getEvictionConfig().getWakeupInterval();
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);
}