[jbosscache-commits] JBoss Cache SVN: r6686 - core/trunk/src/test/java/org/jboss/cache/statetransfer.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Sep 3 01:41:51 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-09-03 01:41:51 -0400 (Wed, 03 Sep 2008)
New Revision: 6686
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
Log:
More tweaking of tests
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-09-03 04:55:50 UTC (rev 6685)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-09-03 05:41:51 UTC (rev 6686)
@@ -17,6 +17,7 @@
import org.jboss.cache.RegionImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.marshall.InactiveRegionException;
import org.jboss.cache.util.TestingUtil;
@@ -472,15 +473,15 @@
{
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
- Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c, false);
- cache1.start();
+ additionalConfiguration(c);
+ Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c);
caches.put("evict1", cache1);
cache1.put(Fqn.fromString("/a/b/c"), "key", "value");
c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
- Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c, false);
- cache2.start();
+ additionalConfiguration(c);
+ Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c);
caches.put("evict2", cache2);
RegionImpl region = (RegionImpl) cache2.getRegion(Fqn.ROOT, false);
@@ -493,8 +494,8 @@
System.out.println(++i + ") Queue contains : " + region.getEvictionEventQueue().poll(0, TimeUnit.MILLISECONDS));
events = region.getEvictionEventQueue().size();
}
-
- assertEquals("Saw the expected number of node events", 5, nodeEventQueueSize);
+ boolean mvcc = cache2.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.MVCC;
+ assertEquals("Saw the expected number of node events", mvcc ? 5 : 3, nodeEventQueueSize);
}
/**
@@ -503,8 +504,8 @@
public void testEvictionAfterStateTransfer() throws Exception
{
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
- Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c, false);
- cache1.start();
+ additionalConfiguration(c);
+ Cache<Object, Object> cache1 = new DefaultCacheFactory<Object, Object>().createCache(c);
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
@@ -522,15 +523,15 @@
EvictionController ec1 = new EvictionController(cache1);
ec1.startEviction();
+ int childrenSize = cache1.getRoot().getChild(Fqn.fromString("/org/jboss/data")).getChildren().size();
+ assert childrenSize == 5000 : "Expected 5000, saw " + childrenSize;
- assert cache1.getRoot().getChild(Fqn.fromString("/org/jboss/data")).getChildren().size() == 5000;
-
c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
- final Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c, false);
- cache2.start();
+ additionalConfiguration(c);
+ final Cache<Object, Object> cache2 = new DefaultCacheFactory<Object, Object>().createCache(c);
caches.put("evict2", cache2);
- Node<Object, Object> parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
+ Node<Object, Object> parent;// = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/data"));
Set children = parent.getChildren();
//4999 because the root of the region will also be counted, as it is not resident
@@ -579,9 +580,10 @@
boolean sawBaseDecrease = false;
boolean sawDataDecrease = false;
long start = System.currentTimeMillis();
+ Node root = cache2.getRoot();
while ((System.currentTimeMillis() - start) < 10000)
{
- parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
+ parent = root.getChild(Fqn.fromString("/org/jboss/test/data"));
children = parent.getChildren();
if (children != null)
{
@@ -678,6 +680,7 @@
this.caches = caches;
}
+ @SuppressWarnings("unchecked")
void useCache() throws Exception
{
System.out.println("---- Cache" + name + " = " + cache.getLocalAddress() + " being used");
@@ -751,7 +754,7 @@
int i = 0;
Fqn fqn = null;
- boolean acquired = false;
+ boolean acquired;
while (!stopped)
{
if (i > 0)
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-09-03 04:55:50 UTC (rev 6685)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-09-03 05:41:51 UTC (rev 6686)
@@ -128,7 +128,6 @@
CacheMode mode = sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
- c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
if (sync)
{
@@ -169,6 +168,7 @@
protected void additionalConfiguration(Configuration c)
{
// to be overridden
+ c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
}
protected void createAndActivateRegion(CacheSPI<Object, Object> c, Fqn f)
More information about the jbosscache-commits
mailing list