From 61a8416463431aef08dbc07c7b45ad22b66735dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarre=C3=B1o?= Date: Thu, 24 May 2012 21:11:11 +0200 Subject: [PATCH] ISPN-7350 Read only entities can be inserted and deleted --- .../collection/CollectionRegionImpl.java | 7 +- .../infinispan/collection/ReadOnlyAccess.java | 42 --------- .../infinispan/entity/ReadOnlyAccess.java | 28 +----- .../CollectionRegionImplTestCase.java | 6 -- .../collection/ReadOnlyExtraAPITestCase.java | 63 ------------- .../AbstractReadOnlyAccessTestCase.java | 92 +++++++++---------- .../entity/EntityRegionImplTestCase.java | 11 +-- .../entity/ReadOnlyExtraAPITestCase.java | 27 +----- .../AbstractFunctionalTestCase.java | 75 +++++++++++++++ .../functional/BasicReadOnlyTestCase.java | 26 +----- .../BasicTransactionalTestCase.java | 54 +---------- 11 files changed, 138 insertions(+), 293 deletions(-) delete mode 100644 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java delete mode 100644 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/ReadOnlyExtraAPITestCase.java create mode 100644 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java index c0be4dc9d5..36c308a200 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java @@ -25,11 +25,10 @@ public class CollectionRegionImpl extends BaseTransactionalDataRegion implements } public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { - if (AccessType.READ_ONLY.equals(accessType)) { - return new ReadOnlyAccess(this); - } else if (AccessType.TRANSACTIONAL.equals(accessType)) { + if (AccessType.READ_ONLY.equals(accessType) + || AccessType.TRANSACTIONAL.equals(accessType)) return new TransactionalAccess(this); - } + throw new CacheException("Unsupported access type [" + accessType.getExternalName() + "]"); } diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java deleted file mode 100644 index 77b05fdb0b..0000000000 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hibernate.cache.infinispan.collection; - -import org.infinispan.util.logging.Log; -import org.infinispan.util.logging.LogFactory; - -import org.hibernate.cache.CacheException; -import org.hibernate.cache.spi.access.SoftLock; - -/** - * This defines the strategy for transactional access to collection data in a - * Infinispan instance. - *

- * The read-only access to a Infinispan really is still transactional, just with - * the extra semantic or guarantee that we will not update data. - * - * @author Chris Bredesen - * @author Galder Zamarreño - * @since 3.5 - */ -class ReadOnlyAccess extends TransactionalAccess { - private static final Log log = LogFactory.getLog(ReadOnlyAccess.class); - - ReadOnlyAccess(CollectionRegionImpl region) { - super(region); - } - public SoftLock lockItem(Object key, Object version) throws CacheException { - throw new UnsupportedOperationException("Illegal attempt to edit read only item"); - } - - public SoftLock lockRegion() throws CacheException { - throw new UnsupportedOperationException("Illegal attempt to edit read only region"); - } - - public void unlockItem(Object key, SoftLock lock) throws CacheException { - log.error("Illegal attempt to edit read only item"); - } - - public void unlockRegion(SoftLock lock) throws CacheException { - log.error("Illegal attempt to edit read only item"); - } - -} diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java index 8062a7406a..c2b539f669 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java @@ -1,8 +1,5 @@ package org.hibernate.cache.infinispan.entity; -import org.infinispan.util.logging.Log; -import org.infinispan.util.logging.LogFactory; - import org.hibernate.cache.CacheException; import org.hibernate.cache.spi.access.SoftLock; @@ -15,36 +12,21 @@ import org.hibernate.cache.spi.access.SoftLock; * @since 3.5 */ class ReadOnlyAccess extends TransactionalAccess { - private static final Log log = LogFactory.getLog(ReadOnlyAccess.class); ReadOnlyAccess(EntityRegionImpl region) { super(region); } - public SoftLock lockItem(Object key, Object version) throws CacheException { - throw new UnsupportedOperationException("Illegal attempt to edit read only item"); - } - - public SoftLock lockRegion() throws CacheException { - throw new UnsupportedOperationException("Illegal attempt to edit read only item"); - } - - public void unlockItem(Object key, SoftLock lock) throws CacheException { - log.error("Illegal attempt to edit read only item"); - } - - public void unlockRegion(SoftLock lock) throws CacheException { - log.error("Illegal attempt to edit read only item"); - } - @Override - public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException { + public boolean update(Object key, Object value, Object currentVersion, + Object previousVersion) throws CacheException { throw new UnsupportedOperationException("Illegal attempt to edit read only item"); } @Override - public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) - throws CacheException { + public boolean afterUpdate(Object key, Object value, Object currentVersion, + Object previousVersion, SoftLock lock) throws CacheException { throw new UnsupportedOperationException("Illegal attempt to edit read only item"); } + } \ No newline at end of file diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/CollectionRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/CollectionRegionImplTestCase.java index b47691d2ae..8e75ab8b9a 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/CollectionRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/CollectionRegionImplTestCase.java @@ -51,12 +51,6 @@ public class CollectionRegionImplTestCase extends AbstractEntityCollectionRegion CollectionRegion region = regionFactory.buildCollectionRegion("test", properties, null); assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL) .lockRegion()); - try { - region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion(); - fail("Did not get READ_ONLY"); - } catch (UnsupportedOperationException good) { - } - try { region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE); fail("Incorrectly got NONSTRICT_READ_WRITE"); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/ReadOnlyExtraAPITestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/ReadOnlyExtraAPITestCase.java deleted file mode 100644 index cf7d75b04f..0000000000 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/collection/ReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2009, Red Hat, Inc. and/or it's affiliates, and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.hibernate.test.cache.infinispan.collection; - -import org.junit.Test; - -import org.hibernate.cache.spi.access.AccessType; - -import static org.junit.Assert.fail; -/** - * ReadOnlyExtraAPITestCase. - * - * @author Galder Zamarreño - * @since 3.5 - */ -public class ReadOnlyExtraAPITestCase extends TransactionalExtraAPITestCase { - @Override - protected AccessType getAccessType() { - return AccessType.READ_ONLY; - } - - @Test - @Override - public void testLockItem() { - try { - getCollectionAccessStrategy().lockItem( KEY, new Integer( 1 ) ); - fail( "Call to lockItem did not throw exception" ); - } - catch (UnsupportedOperationException expected) { - } - } - - @Test - @Override - public void testLockRegion() { - try { - getCollectionAccessStrategy().lockRegion(); - fail( "Call to lockRegion did not throw exception" ); - } - catch (UnsupportedOperationException expected) { - } - } - -} diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractReadOnlyAccessTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractReadOnlyAccessTestCase.java index 25690bda4c..6bc926eb7b 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractReadOnlyAccessTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/AbstractReadOnlyAccessTestCase.java @@ -30,64 +30,58 @@ import org.hibernate.cache.spi.access.AccessType; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; /** * Base class for tests of TRANSACTIONAL access. - * + * * @author Galder Zamarreño * @since 3.5 */ public abstract class AbstractReadOnlyAccessTestCase extends AbstractEntityRegionAccessStrategyTestCase { - @Override - protected AccessType getAccessType() { - return AccessType.READ_ONLY; - } - @Test - @Override - public void testPutFromLoad() throws Exception { - putFromLoadTest(false); - } + @Override + protected AccessType getAccessType() { + return AccessType.READ_ONLY; + } - @Test - @Override - public void testPutFromLoadMinimal() throws Exception { - putFromLoadTest(true); - } - - private void putFromLoadTest(boolean minimal) throws Exception { - - final String KEY = KEY_BASE + testCount++; - - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); - if (minimal) - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1), true); - else - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1)); - - sleep(250); - Object expected = isUsingInvalidation() ? null : VALUE1; - assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - BatchModeTransactionManager.getInstance().commit(); - assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - } + @Test + @Override + public void testPutFromLoad() throws Exception { + putFromLoadTest(false); + } - @Test - @Override - public void testUpdate() throws Exception { - - final String KEY = KEY_BASE + testCount++; - - try { - localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1)); - fail("Call to update did not throw exception"); - } - catch (UnsupportedOperationException good) {} - } + @Test + @Override + public void testPutFromLoadMinimal() throws Exception { + putFromLoadTest(true); + } + + private void putFromLoadTest(boolean minimal) throws Exception { + + final String KEY = KEY_BASE + testCount++; + + long txTimestamp = System.currentTimeMillis(); + BatchModeTransactionManager.getInstance().begin(); + assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); + if (minimal) + localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, 1, true); + else + localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, 1); + + sleep(250); + Object expected = isUsingInvalidation() ? null : VALUE1; + assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); + + BatchModeTransactionManager.getInstance().commit(); + assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis())); + assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); + } + + @Test(expected = UnsupportedOperationException.class) + @Override + public void testUpdate() throws Exception { + localAccessStrategy.update(KEY_BASE + testCount++, + VALUE2, 2, 1); + } } diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java index 6df486c3de..6de2107709 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java @@ -50,13 +50,8 @@ public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTest @Override protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) { EntityRegion region = regionFactory.buildEntityRegion("test", properties, null); - assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL) - .lockRegion()); - try { - region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion(); - fail("Did not get READ_ONLY"); - } catch (UnsupportedOperationException good) { - } + assertNull("Got TRANSACTIONAL", + region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion()); try { region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE); @@ -73,7 +68,7 @@ public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTest @Override protected void putInRegion(Region region, Object key, Object value) { - ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).insert(key, value, new Integer(1)); + ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).insert(key, value, 1); } @Override diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java index 2b18376cd4..5353cd721b 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java @@ -40,36 +40,11 @@ public class ReadOnlyExtraAPITestCase extends TransactionalExtraAPITestCase { return AccessType.READ_ONLY; } - @Override - public void testLockItem() { - try { - getEntityAccessStrategy().lockItem( KEY, Integer.valueOf( 1 ) ); - fail( "Call to lockItem did not throw exception" ); - } - catch (UnsupportedOperationException expected) { - } - } - - @Override - public void testLockRegion() { - try { - getEntityAccessStrategy().lockRegion(); - fail( "Call to lockRegion did not throw exception" ); - } - catch (UnsupportedOperationException expected) { - } - } - @Override public void testAfterUpdate() { try { getEntityAccessStrategy().afterUpdate( - KEY, - VALUE2, - Integer.valueOf( 1 ), - Integer.valueOf( 2 ), - new MockSoftLock() - ); + KEY, VALUE2, 1, 2, new MockSoftLock()); fail( "Call to afterUpdate did not throw exception" ); } catch (UnsupportedOperationException expected) { diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java new file mode 100644 index 0000000000..3aa316b5fc --- /dev/null +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java @@ -0,0 +1,75 @@ +package org.hibernate.test.cache.infinispan.functional; + +import org.hibernate.Session; +import org.hibernate.stat.SecondLevelCacheStatistics; +import org.hibernate.stat.Statistics; +import org.infinispan.util.logging.Log; +import org.infinispan.util.logging.LogFactory; +import org.junit.Test; + +import java.util.Map; +import java.util.concurrent.Callable; + +import static org.infinispan.test.TestingUtil.withTx; +import static org.junit.Assert.assertEquals; + +/** + * Parent tests for both transactional and + * read-only tests are defined in this class. + * + * @author Galder Zamarreño + * @since 4.1 + */ +public abstract class AbstractFunctionalTestCase extends SingleNodeTestCase { + + static final Log log = LogFactory.getLog(AbstractFunctionalTestCase.class); + + @Test + public void testEmptySecondLevelCacheEntry() throws Exception { + sessionFactory().getCache().evictCollectionRegion( Item.class.getName() + ".items" ); + Statistics stats = sessionFactory().getStatistics(); + stats.clear(); + SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" ); + Map cacheEntries = statistics.getEntries(); + assertEquals( 0, cacheEntries.size() ); + } + + @Test + public void testInsertDeleteEntity() throws Exception { + final Statistics stats = sessionFactory().getStatistics(); + stats.clear(); + + final Item item = new Item( "chris", "Chris's Item" ); + withTx(tm, new Callable() { + @Override + public Void call() throws Exception { + Session s = openSession(); + s.getTransaction().begin(); + s.persist(item); + s.getTransaction().commit(); + s.close(); + return null; + } + }); + + log.info("Entry persisted, let's load and delete it."); + + withTx(tm, new Callable() { + @Override + public Void call() throws Exception { + Session s = openSession(); + s.getTransaction().begin(); + Item found = (Item) s.load(Item.class, item.getId()); + log.info(stats.toString()); + assertEquals(item.getDescription(), found.getDescription()); + assertEquals(0, stats.getSecondLevelCacheMissCount()); + assertEquals(1, stats.getSecondLevelCacheHitCount()); + s.delete(found); + s.getTransaction().commit(); + s.close(); + return null; + } + }); + } + +} diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java index fc48442163..e183a06c57 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java @@ -23,33 +23,17 @@ */ package org.hibernate.test.cache.infinispan.functional; -import java.util.Map; - -import org.junit.Test; - -import org.hibernate.stat.SecondLevelCacheStatistics; -import org.hibernate.stat.Statistics; - -import static org.junit.Assert.assertEquals; - /** + * Functional entity read-only tests. + * * @author Galder Zamarreño * @since 3.5 */ -public class BasicReadOnlyTestCase extends SingleNodeTestCase { - @Override +public class BasicReadOnlyTestCase extends AbstractFunctionalTestCase { + + @Override public String getCacheConcurrencyStrategy() { return "read-only"; } - @Test - public void testEmptySecondLevelCacheEntry() throws Exception { - sessionFactory().getCache().evictEntityRegion( Item.class.getName() ); - Statistics stats = sessionFactory().getStatistics(); - stats.clear(); - SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" ); - Map cacheEntries = statistics.getEntries(); - assertEquals( 0, cacheEntries.size() ); - } - } \ No newline at end of file diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java index 071f003099..a0e2ea1db1 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java @@ -33,8 +33,6 @@ import org.hibernate.Criteria; import org.hibernate.NaturalIdLoadAccess; import org.hibernate.cache.infinispan.access.PutFromLoadValidator; import org.hibernate.criterion.Restrictions; -import org.infinispan.util.logging.Log; -import org.infinispan.util.logging.LogFactory; import org.junit.After; import org.junit.Test; @@ -51,13 +49,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - /** + * Functional entity transactional tests. + * * @author Galder Zamarreño * @since 3.5 */ -public class BasicTransactionalTestCase extends SingleNodeTestCase { - private static final Log log = LogFactory.getLog( BasicTransactionalTestCase.class ); +public class BasicTransactionalTestCase extends AbstractFunctionalTestCase { @Override public void configure(Configuration cfg) { @@ -90,42 +88,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase { }); } - @Test - public void testEntityCache() throws Exception { - final Statistics stats = sessionFactory().getStatistics(); - stats.clear(); - - final Item item = new Item( "chris", "Chris's Item" ); - withTx(tm, new Callable() { - @Override - public Void call() throws Exception { - Session s = openSession(); - s.getTransaction().begin(); - s.persist( item ); - s.getTransaction().commit(); - s.close(); - return null; - } - }); - - log.info("Entry persisted, let's load and delete it."); - - withTx(tm, new Callable() { - @Override - public Void call() throws Exception { - Session s = openSession(); - Item found = (Item) s.load(Item.class, item.getId()); - log.info(stats.toString()); - assertEquals(item.getDescription(), found.getDescription()); - assertEquals(0, stats.getSecondLevelCacheMissCount()); - assertEquals(1, stats.getSecondLevelCacheHitCount()); - s.delete(found); - s.close(); - return null; - } - }); - } - @Test public void testCollectionCache() throws Exception { final Statistics stats = sessionFactory().getStatistics(); @@ -452,16 +414,6 @@ public class BasicTransactionalTestCase extends SingleNodeTestCase { } } - @Test - public void testEmptySecondLevelCacheEntry() throws Exception { - sessionFactory().getCache().evictCollectionRegion( Item.class.getName() + ".items" ); - Statistics stats = sessionFactory().getStatistics(); - stats.clear(); - SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" ); - Map cacheEntries = statistics.getEntries(); - assertEquals( 0, cacheEntries.size() ); - } - @Test public void testNaturalIdCached() throws Exception { saveSomeCitizens();