Author: bstansberry(a)jboss.com
Date: 2007-12-23 09:50:54 -0500 (Sun, 23 Dec 2007)
New Revision: 14259
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
Log:
Fix putFromLoad tests
Update evict/removeAll tests to reflect JBCACHE-1251 problem
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-12-23
14:49:34 UTC (rev 14258)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-12-23
14:50:54 UTC (rev 14259)
@@ -33,6 +33,7 @@
import junit.framework.TestSuite;
import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
import org.hibernate.cache.CollectionRegion;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
@@ -289,7 +290,7 @@
long txTimestamp = System.currentTimeMillis();
BatchModeTransactionManager.getInstance().begin();
- assertNull("node1 starts clean",
remoteAccessStrategy.get(KEY, txTimestamp));
+ assertNull("node2 starts clean",
remoteAccessStrategy.get(KEY, txTimestamp));
// Let node1 write
writeLatch1.countDown();
@@ -348,22 +349,12 @@
Object expected1 = null;
Object expected2 = null;
if (isUsingInvalidation()) {
- if (isUsingOptimisticLocking()) {
- expected1 = null; // the initial VALUE2 DataVersion should prevent the
node2 put
- expected2 = VALUE2;
-
- // We know this case fails
- msg1 = msg2 = "Known issue JBCACHE-1203";
- }
- else {
- // node2 can write since there is no data version
- // We count on db locking to prevent this case
- expected1 = VALUE1;
- expected2 = null; // invalidated by node2
-
- // We know this case fails
- msg1 = msg2 = "Known issue JBCACHE-1203";
- }
+ // PFER does not generate any invalidation, so each node should
+ // succeed. We count on database locking and Hibernate removing
+ // the collection on any update to prevent the situation we have
+ // here where the caches have inconsistent data
+ expected1 = VALUE2;
+ expected2 = VALUE1;
}
else {
// the initial VALUE2 should prevent the node2 put
@@ -488,6 +479,24 @@
assertEquals(0, regionRoot.getChildrenNames().size());
assertTrue(regionRoot.isResident());
+ if (isUsingInvalidation()) {
+ // With invalidation, a node that removes the region root cannot reestablish
+ // it on remote nodes, since the only message the propagates is
"invalidate".
+ // So, we have to reestablish it ourselves
+
+ // First, do a get to help test whether a get messes up the optimistic
version
+ String msg = "Known issue JBCACHE-1251 -- problem reestablishing
invalidated region root";
+ try {
+ assertEquals(null, remoteAccessStrategy.get(KEY,
System.currentTimeMillis()));
+ }
+ catch (CacheException ce) {
+ log.error(msg, ce);
+ fail(msg + " -- cause: " + ce);
+ }
+ remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new
Integer(1));
+ assertEquals(msg, VALUE1, remoteAccessStrategy.get(KEY,
System.currentTimeMillis()));
+ }
+
regionRoot = remoteCache.getRoot().getChild(regionFqn);
assertFalse(regionRoot == null);
if (isUsingInvalidation()) {
@@ -507,7 +516,7 @@
}
private void checkNodeIsEmpty(Node node) {
- assertEquals("Known issue JBCACHE-1200. node " + node.getFqn() + "
should not have keys", 0, node.getKeys().size());
+ assertEquals(node.getFqn() + " should not have keys", 0,
node.getKeys().size());
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
checkNodeIsEmpty((Node) it.next());
}
Show replies by date