Author: manik.surtani(a)jboss.com
Date: 2008-09-01 01:30:11 -0400 (Mon, 01 Sep 2008)
New Revision: 6650
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher.java
Log:
Better timing control between eviction tests
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java 2008-09-01
05:15:40 UTC (rev 6649)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java 2008-09-01
05:30:11 UTC (rev 6650)
@@ -13,7 +13,6 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.internals.EvictionController;
import org.jboss.cache.util.internals.EvictionWatcher;
import java.util.concurrent.TimeUnit;
@@ -49,10 +48,6 @@
*/
public boolean waitForEviction(Cache cache, long timeToWait, TimeUnit unit, Fqn...
fqnsToEvict) throws InterruptedException
{
- EvictionController ec = new EvictionController(cache);
- EvictionController.Signaller signaller = ec.getEvictionThreadSignaller();
- boolean evicted = new EvictionWatcher(cache,
fqnsToEvict).waitForEviction(timeToWait, unit);
- signaller.waitForEvictionThreadCompletion(timeToWait, unit);
- return evicted;
+ return new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeToWait, unit);
}
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-09-01
05:15:40 UTC (rev 6649)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUPolicyTest.java 2008-09-01
05:30:11 UTC (rev 6650)
@@ -156,7 +156,7 @@
{
String str = rootStr + Integer.toString(i);
Fqn fqn = Fqn.fromString(str);
- assertNull(cache.get(fqn, str));
+ assertNull("Fqn " + fqn + " should be null",
cache.get(fqn, str));
}
for (int i = 5; i < 10; i++)
{
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher.java 2008-09-01
05:15:40 UTC (rev 6649)
+++
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionWatcher.java 2008-09-01
05:30:11 UTC (rev 6650)
@@ -24,6 +24,7 @@
Cache<?, ?> cache;
List<Fqn> fqnsToWaitFor;
CountDownLatch latch;
+ EvictionController.Signaller signaller;
public EvictionWatcher(Cache<?, ?> cache, Fqn... fqnsToWaitFor)
{
@@ -35,6 +36,8 @@
this.cache = cache;
this.fqnsToWaitFor = new ArrayList<Fqn>(fqnsToWaitFor);
latch = new CountDownLatch(fqnsToWaitFor.size());
+ EvictionController ec = new EvictionController(cache);
+ signaller = ec.getEvictionThreadSignaller();
cache.addCacheListener(this);
}
@@ -61,7 +64,12 @@
{
try
{
- return latch.await(timeout, unit);
+ boolean evicted = latch.await(timeout, unit);
+
+ // now make sure the eviction thread has completed.
+ signaller.waitForEvictionThreadCompletion(timeout, unit);
+ return evicted;
+
}
finally
{
Show replies by date