From c053aefa0d081ca627dc401222eeb9615c1805df Mon Sep 17 00:00:00 2001 From: Brian Stansberry Date: Mon, 24 Dec 2007 16:01:02 +0000 Subject: [PATCH] Fix the evictRemoveAll tests for the optimistic case git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14265 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- ...ollectionRegionAccessStrategyTestCase.java | 25 +++++++++--------- ...isticInvalidatedTransactionalTestCase.java | 10 ------- .../OptimisticReadOnlyTestCase.java | 10 ------- ...actEntityRegionAccessStrategyTestCase.java | 26 ++++++++++--------- ...isticInvalidatedTransactionalTestCase.java | 9 ------- .../entity/OptimisticReadOnlyTestCase.java | 10 ------- 6 files changed, 27 insertions(+), 63 deletions(-) diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java index 1be50c004b..c03d05c1f2 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java @@ -433,7 +433,7 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs Node regionRoot = localCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingOptimisticLocking()) { @@ -442,7 +442,7 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs regionRoot = remoteCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingOptimisticLocking()) { @@ -476,7 +476,7 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs regionRoot = localCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingInvalidation()) { @@ -500,26 +500,27 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs regionRoot = remoteCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); if (isUsingInvalidation()) { - // JBC seems broken: see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=121408 - // FIXME replace with the following when JBCACHE-1199 and JBCACHE-1200 are done: - //assertFalse(regionRoot.isValid()); - checkNodeIsEmpty(regionRoot); + // Region root should have 1 child -- the one we added above + assertEquals(1, getValidChildrenCount(regionRoot)); } else { // Same assertion, just different assertion msg - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); } assertTrue(regionRoot.isResident()); assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis())); + assertEquals("remote is correct", (isUsingInvalidation() ? VALUE1 : null), remoteAccessStrategy.get(KEY, System.currentTimeMillis())); } - private void checkNodeIsEmpty(Node node) { - assertEquals(node.getFqn() + " should not have keys", 0, node.getKeys().size()); + private int getValidChildrenCount(Node node) { + int result = 0; for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - checkNodeIsEmpty((Node) it.next()); + if (((Node) it.next()).isValid()) { + result++; + } } + return result; } private void rollback() { diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java index b91dcf328d..6f9516ed4c 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java @@ -55,15 +55,5 @@ public class OptimisticInvalidatedTransactionalTestCase assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); assertTrue("Synchronous mode", isSynchronous()); } - - // Known failures - - public void testEvictAllFailureExpected() { - super.testEvictAll(); - } - - public void testRemoveAllFailureExpected() { - super.testRemoveAll(); - } } diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java index 64e3f064ee..1ed2a8e682 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java @@ -54,15 +54,5 @@ public class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); assertTrue("Synchronous mode", isSynchronous()); } - - // Known failures - - public void testEvictAllFailureExpected() { - super.testEvictAll(); - } - - public void testRemoveAllFailureExpected() { - super.testRemoveAll(); - } } diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java index 00e97887e7..b3302b66c4 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java @@ -24,6 +24,7 @@ package org.hibernate.test.cache.jbc2.entity; import java.util.Iterator; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -640,7 +641,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac Node regionRoot = localCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingOptimisticLocking()) { @@ -649,7 +650,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac regionRoot = remoteCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingOptimisticLocking()) { @@ -685,7 +686,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac regionRoot = localCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); assertTrue(regionRoot.isResident()); if (isUsingInvalidation()) { @@ -709,26 +710,27 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac regionRoot = remoteCache.getRoot().getChild(regionFqn); assertFalse(regionRoot == null); if (isUsingInvalidation()) { - // JBC seems broken: see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=121408 - // FIXME replace with the following when JBCACHE-1199 and JBCACHE-1200 are done: - //assertFalse(regionRoot.isValid()); - checkNodeIsEmpty(regionRoot); + // Region root should have 1 child -- the one we added above + assertEquals(1, getValidChildrenCount(regionRoot)); } else { // Same assertion, just different assertion msg - assertEquals(0, regionRoot.getChildrenNames().size()); + assertEquals(0, getValidChildrenCount(regionRoot)); } assertTrue(regionRoot.isResident()); assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis())); + assertEquals("remote is correct", (isUsingInvalidation() ? VALUE1 : null), remoteAccessStrategy.get(KEY, System.currentTimeMillis())); } - private void checkNodeIsEmpty(Node node) { - assertEquals(node.getFqn() + " should not have keys", 0, node.getKeys().size()); + private int getValidChildrenCount(Node node) { + int result = 0; for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - checkNodeIsEmpty((Node) it.next()); + if (((Node) it.next()).isValid()) { + result++; + } } + return result; } protected void rollback() { diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java index dcaf0efbef..8988137681 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java @@ -55,13 +55,4 @@ public class OptimisticInvalidatedTransactionalTestCase extends AbstractTransact assertTrue("Synchronous mode", isSynchronous()); } - // Known failures - - public void testEvictAllFailureExpected() { - super.testEvictAll(); - } - - public void testRemoveAllFailureExpected() { - super.testRemoveAll(); - } } diff --git a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java index a60f88ac13..74651cde48 100644 --- a/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java +++ b/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java @@ -54,15 +54,5 @@ public class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); assertTrue("Synchronous mode", isSynchronous()); } - - // Known failures - - public void testEvictAllFailureExpected() { - super.testEvictAll(); - } - - public void testRemoveAllFailureExpected() { - super.testRemoveAll(); - } }