[hibernate-commits] Hibernate SVN: r14957 - in core/trunk/cache-jbosscache2/src: test/java/org/hibernate/test/cache/jbc2 and 3 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Jul 18 13:10:47 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-07-18 13:10:47 -0400 (Fri, 18 Jul 2008)
New Revision: 14957
Added:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/Jbc2ConfigsXmlValidityTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheManagerTestSetup.java
Modified:
core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jbc2-configs.xml
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java
core/trunk/cache-jbosscache2/src/test/resources/treecache.xml
Log:
[HHH-3390] Use READ_COMMITTED for JBC 2 cache
Modified: core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jbc2-configs.xml
===================================================================
(Binary files differ)
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/Jbc2ConfigsXmlValidityTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/Jbc2ConfigsXmlValidityTestCase.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/Jbc2ConfigsXmlValidityTestCase.java 2008-07-18 17:10:47 UTC (rev 14957)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Brian Stansberry
+ */
+
+package org.hibernate.test.cache.jbc2;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.util.CacheManagerTestSetup;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheManager;
+
+/**
+ * Tests the validity of the JBC configs in jbc2-configs.xml.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class Jbc2ConfigsXmlValidityTestCase extends AbstractJBossCacheTestCase
+{
+ private static final AtomicReference<CacheManager> cacheManagerRef = new AtomicReference<CacheManager>();
+
+ private static final Set<String> stdConfigs = new HashSet<String>();
+
+ static
+ {
+ stdConfigs.add("optimistic-entity");
+ stdConfigs.add("pessimistic-entity");
+ stdConfigs.add("pessimistic-entity-repeatable");
+ stdConfigs.add("optimistic-shared");
+ stdConfigs.add("pessimistic-shared");
+ stdConfigs.add("pessimistic-shared-repeatable");
+ stdConfigs.add("local-query");
+ stdConfigs.add("replicated-query");
+ stdConfigs.add("timestamps-cache");
+ }
+
+ private CacheManager mgr;
+ private String cacheName;
+ private Cache cache;
+
+ /**
+ * Create a new Jbc2ConfigsXmlValidityTestCase.
+ *
+ * @param name
+ */
+ public Jbc2ConfigsXmlValidityTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception {
+ TestSuite suite = new TestSuite(Jbc2ConfigsXmlValidityTestCase.class);
+ return new CacheManagerTestSetup(suite, cacheManagerRef);
+ }
+
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ this.mgr = cacheManagerRef.get();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (cache != null)
+ {
+ try
+ {
+ mgr.releaseCache(this.cacheName);
+ }
+ catch (Exception ignored) {}
+
+ cache = null;
+ }
+
+ mgr = null;
+ }
+
+ public void testOptimisticEntity() throws Exception
+ {
+ stdConfigTest("optimistic-entity");
+ }
+
+ public void testPessimisticEntity() throws Exception
+ {
+ stdConfigTest("pessimistic-entity");
+ }
+
+ public void testPessimisticEntityRepeatable() throws Exception
+ {
+ stdConfigTest("pessimistic-entity-repeatable");
+ }
+
+ public void testOptimisticShared() throws Exception
+ {
+ stdConfigTest("optimistic-shared");
+ }
+
+ public void testPessimisticShared() throws Exception
+ {
+ stdConfigTest("pessimistic-shared");
+ }
+
+ public void testPessimisticSharedRepeatable() throws Exception
+ {
+ stdConfigTest("pessimistic-shared-repeatable");
+ }
+
+ public void testLocalQuery() throws Exception
+ {
+ stdConfigTest("local-query");
+ }
+
+ public void testReplicatedQuery() throws Exception
+ {
+ stdConfigTest("replicated-query");
+ }
+
+ public void testTimestampsCache() throws Exception
+ {
+ stdConfigTest("timestamps-cache");
+ }
+
+ public void testAdditionalConfigs() throws Exception
+ {
+ Set<String> names = new HashSet<String>(this.mgr.getConfigurationNames());
+ names.removeAll(stdConfigs);
+ for (String name : names)
+ {
+ configTest(name);
+ }
+ }
+
+ private void stdConfigTest(String configName) throws Exception
+ {
+ assertTrue(this.mgr.getConfigurationNames().contains(configName));
+ configTest(configName);
+ }
+
+ private void configTest(String configName) throws Exception
+ {
+ this.cacheName = configName;
+ this.cache = mgr.getCache(configName, true);
+ this.cache.start();
+ this.mgr.releaseCache(this.cacheName);
+ this.cache = null;
+ }
+}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java 2008-07-18 12:08:43 UTC (rev 14956)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java 2008-07-18 17:10:47 UTC (rev 14957)
@@ -265,7 +265,8 @@
blockerLatch.countDown();
unblocked = true;
- if ("PESSIMISTIC".equals(jbc.getConfiguration().getNodeLockingSchemeString())) {
+ if ("PESSIMISTIC".equals(jbc.getConfiguration().getNodeLockingSchemeString())
+ && "REPEATABLE_READ".equals(jbc.getConfiguration().getIsolationLevelString())) {
assertEquals(VALUE1, region.get(KEY));
}
else {
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheManagerTestSetup.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheManagerTestSetup.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheManagerTestSetup.java 2008-07-18 17:10:47 UTC (rev 14957)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Brian Stansberry
+ */
+
+package org.hibernate.test.util;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.jboss.cache.CacheManager;
+import org.jboss.cache.CacheManagerImpl;
+import org.jgroups.ChannelFactory;
+import org.jgroups.JChannelFactory;
+
+/**
+ * A TestSetup that starts a CacheManager in setUp() and stops it in tearDown().
+ * AtomicReference passed to the constructor can be used by the test to
+ * access the CacheManager.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class CacheManagerTestSetup extends TestSetup
+{
+ public static final String DEF_CACHE_FACTORY_RESOURCE = "org/hibernate/cache/jbc2/builder/jbc2-configs.xml";
+ public static final String DEF_JGROUPS_RESOURCE = "org/hibernate/cache/jbc2/builder/jgroups-stacks.xml";
+
+ private final String jbcConfig;
+ private final String jgConfig;
+ private final AtomicReference<CacheManager> cacheManagerRef;
+ private ChannelFactory channelFactory;
+
+ public CacheManagerTestSetup(Test test, AtomicReference<CacheManager> cacheManagerRef)
+ {
+ this(test, DEF_CACHE_FACTORY_RESOURCE, DEF_JGROUPS_RESOURCE, cacheManagerRef);
+ }
+
+ public CacheManagerTestSetup(Test test, String jbcConfig, String jgConfig, AtomicReference<CacheManager> cacheManagerRef)
+ {
+ super(test);
+ this.jbcConfig = jbcConfig;
+ this.jgConfig = jgConfig;
+ this.cacheManagerRef = cacheManagerRef;
+ }
+
+ public CacheManagerTestSetup(Test test, String jbcConfig, ChannelFactory channelFactory, AtomicReference<CacheManager> cacheManagerRef)
+ {
+ super(test);
+ this.jbcConfig = jbcConfig;
+ this.jgConfig = null;
+ this.cacheManagerRef = cacheManagerRef;
+ this.channelFactory = channelFactory;
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ if (this.channelFactory == null)
+ {
+ this.channelFactory = new JChannelFactory();
+ this.channelFactory.setMultiplexerConfig(this.jgConfig);
+ }
+
+ CacheManagerImpl jbcFactory = new CacheManagerImpl(this.jbcConfig, this.channelFactory);
+ this.cacheManagerRef.set(jbcFactory);
+ jbcFactory.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ this.channelFactory = null;
+
+ CacheManager jbcFactory = this.cacheManagerRef.get();
+ this.cacheManagerRef.set(null);
+ ((CacheManagerImpl) jbcFactory).stop();
+ }
+
+}
\ No newline at end of file
Modified: core/trunk/cache-jbosscache2/src/test/resources/treecache.xml
===================================================================
--- core/trunk/cache-jbosscache2/src/test/resources/treecache.xml 2008-07-18 12:08:43 UTC (rev 14956)
+++ core/trunk/cache-jbosscache2/src/test/resources/treecache.xml 2008-07-18 17:10:47 UTC (rev 14957)
@@ -56,13 +56,9 @@
<attribute name="NodeLockingScheme">PESSIMISTIC</attribute>
<!--
- Isolation level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
+ READ_COMMITTED is as strong as necessary for most 2nd Level Cache usage.
-->
- <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+ <attribute name="IsolationLevel">READ_COMMITTED</attribute>
<!-- Valid modes are LOCAL
REPL_ASYNC
More information about the hibernate-commits
mailing list