Author: steve.ebersole(a)jboss.com
Date: 2007-12-06 15:28:10 -0500 (Thu, 06 Dec 2007)
New Revision: 14216
Added:
core/trunk/cache-ehcache/src/test/
core/trunk/cache-ehcache/src/test/java/
core/trunk/cache-ehcache/src/test/java/org/
core/trunk/cache-ehcache/src/test/java/org/hibernate/
core/trunk/cache-ehcache/src/test/java/org/hibernate/cache/
core/trunk/cache-ehcache/src/test/java/org/hibernate/cache/EhCacheTest.java
core/trunk/cache-ehcache/src/test/resources/
core/trunk/cache-ehcache/src/test/resources/ehcache.xml
core/trunk/cache-ehcache/src/test/resources/hibernate.properties
core/trunk/cache-ehcache/src/test/resources/log4j.properties
core/trunk/cache-jbosscache/src/test/
core/trunk/cache-jbosscache/src/test/java/
core/trunk/cache-jbosscache/src/test/java/org/
core/trunk/cache-jbosscache/src/test/java/org/hibernate/
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/OptimisticTreeCacheTest.java
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/PessimisticTreeCacheTest.java
core/trunk/cache-jbosscache/src/test/resources/
core/trunk/cache-jbosscache/src/test/resources/hibernate.properties
core/trunk/cache-jbosscache/src/test/resources/log4j.properties
core/trunk/cache-jbosscache/src/test/resources/treecache-optimistic.xml
core/trunk/cache-jbosscache/src/test/resources/treecache-pessimistic.xml
core/trunk/testing/src/main/java/org/hibernate/test/cache/
core/trunk/testing/src/main/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java
core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.hbm.xml
core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.java
core/trunk/testing/src/main/java/org/hibernate/test/cache/VersionedItem.java
Removed:
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/
Modified:
core/trunk/cache-ehcache/pom.xml
core/trunk/cache-jbosscache/pom.xml
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/JndiBoundTreeCacheProvider.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCacheProvider.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCacheProvider.java
core/trunk/core/pom.xml
core/trunk/testing/pom.xml
core/trunk/testsuite/pom.xml
Log:
HHH-2863 : isolate cache integration testing
Modified: core/trunk/cache-ehcache/pom.xml
===================================================================
--- core/trunk/cache-ehcache/pom.xml 2007-12-06 20:26:39 UTC (rev 14215)
+++ core/trunk/cache-ehcache/pom.xml 2007-12-06 20:28:10 UTC (rev 14216)
@@ -29,6 +29,69 @@
<artifactId>ehcache</artifactId>
<version>1.2.3</version>
</dependency>
+
+ <!-- testing deps -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Copied: core/trunk/cache-ehcache/src/test/java/org/hibernate/cache/EhCacheTest.java (from
rev 12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/ehcache/EhCacheTest.java)
===================================================================
--- core/trunk/cache-ehcache/src/test/java/org/hibernate/cache/EhCacheTest.java
(rev 0)
+++ core/trunk/cache-ehcache/src/test/java/org/hibernate/cache/EhCacheTest.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache;
+
+import junit.framework.Test;
+
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class EhCacheTest extends BaseCacheProviderTestCase {
+ public EhCacheTest(String x) {
+ super( x );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( EhCacheTest.class );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "read-write";
+ }
+
+ protected Class getCacheProvider() {
+ return EhCacheProvider.class;
+ }
+
+ protected String getConfigResourceKey() {
+ return Environment.CACHE_PROVIDER_CONFIG;
+ }
+
+ protected String getConfigResourceLocation() {
+ return "ehcache.xml";
+ }
+
+ protected boolean useTransactionManager() {
+ return false;
+ }
+
+}
Copied: core/trunk/cache-ehcache/src/test/resources/ehcache.xml (from rev 12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/ehcache/ehcache.xml)
===================================================================
--- core/trunk/cache-ehcache/src/test/resources/ehcache.xml (rev
0)
+++ core/trunk/cache-ehcache/src/test/resources/ehcache.xml 2007-12-06 20:28:10 UTC (rev
14216)
@@ -0,0 +1,111 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<ehcache>
+
+ <!-- Sets the path to the directory where cache .data files are created.
+
+ If the path is a Java System Property it is replaced by
+ its value in the running VM.
+
+ The following properties are translated:
+ user.home - User's home directory
+ user.dir - User's current working directory
+ java.io.tmpdir - Default temp file path -->
+ <diskStore path="java.io.tmpdir"/>
+
+
+ <!--Default Cache configuration. These will applied to caches programmatically
created through
+ the CacheManager.
+
+ The following attributes are required for defaultCache:
+
+ maxInMemory - Sets the maximum number of objects that will be created in
memory
+ eternal - Sets whether elements are eternal. If eternal, timeouts are
ignored and the element
+ is never expired.
+ timeToIdleSeconds - Sets the time to idle for an element before it expires. Is
only used
+ if the element is not eternal. Idle time is now - last
accessed time
+ timeToLiveSeconds - Sets the time to live for an element before it expires. Is
only used
+ if the element is not eternal. TTL is now - creation time
+ overflowToDisk - Sets whether elements can overflow to disk when the in-memory
cache
+ has reached the maxInMemory limit.
+
+ -->
+ <defaultCache
+ maxElementsInMemory="10000"
+ eternal="false"
+ timeToIdleSeconds="120"
+ timeToLiveSeconds="120"
+ overflowToDisk="true"
+ />
+
+ <!--Predefined caches. Add your cache configuration settings here.
+ If you do not have a configuration for your cache a WARNING will be issued when
the
+ CacheManager starts
+
+ The following attributes are required for defaultCache:
+
+ name - Sets the name of the cache. This is used to identify the
cache. It must be unique.
+ maxInMemory - Sets the maximum number of objects that will be created in
memory
+ eternal - Sets whether elements are eternal. If eternal, timeouts are
ignored and the element
+ is never expired.
+ timeToIdleSeconds - Sets the time to idle for an element before it expires. Is
only used
+ if the element is not eternal. Idle time is now - last
accessed time
+ timeToLiveSeconds - Sets the time to live for an element before it expires. Is
only used
+ if the element is not eternal. TTL is now - creation time
+ overflowToDisk - Sets whether elements can overflow to disk when the in-memory
cache
+ has reached the maxInMemory limit.
+
+ -->
+
+ <!-- Sample cache named sampleCache1
+ This cache contains a maximum in memory of 10000 elements, and will expire
+ an element if it is idle for more than 5 minutes and lives for more than
+ 10 minutes.
+
+ If there are more than 10000 elements it will overflow to the
+ disk cache, which in this configuration will go to wherever java.io.tmp is
+ defined on your system. On a standard Linux system this will be /tmp"
+ -->
+ <cache name="sampleCache1"
+ maxElementsInMemory="10000"
+ eternal="false"
+ timeToIdleSeconds="300"
+ timeToLiveSeconds="600"
+ overflowToDisk="true"
+ />
+
+ <!-- Sample cache named sampleCache2
+ This cache contains 1000 elements. Elements will always be held in memory.
+ They are not expired. -->
+ <cache name="sampleCache2"
+ maxElementsInMemory="1000"
+ eternal="true"
+ timeToIdleSeconds="0"
+ timeToLiveSeconds="0"
+ overflowToDisk="false"
+ /> -->
+
+ <!-- Place configuration for your caches following -->
+
+</ehcache>
Copied: core/trunk/cache-ehcache/src/test/resources/hibernate.properties (from rev 12891,
core/trunk/testsuite/src/test/resources/hibernate.properties)
===================================================================
--- core/trunk/cache-ehcache/src/test/resources/hibernate.properties
(rev 0)
+++ core/trunk/cache-ehcache/src/test/resources/hibernate.properties 2007-12-06 20:28:10
UTC (rev 14216)
@@ -0,0 +1,32 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# 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, as published by the Free Software Foundation. #
+# #
+# This program 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 distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:/test
+hibernate.connection.username sa
+hibernate.connection.password
+
+hibernate.connection.pool_size 5
+
+hibernate.cache.region_prefix hibernate.test
Copied: core/trunk/cache-ehcache/src/test/resources/log4j.properties (from rev 14053,
core/trunk/testsuite/src/test/resources/log4j.properties)
===================================================================
--- core/trunk/cache-ehcache/src/test/resources/log4j.properties
(rev 0)
+++ core/trunk/cache-ehcache/src/test/resources/log4j.properties 2007-12-06 20:28:10 UTC
(rev 14216)
@@ -0,0 +1,32 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# 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, as published by the Free Software Foundation. #
+# #
+# This program 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 distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+
+log4j.rootLogger=info, stdout
+
+log4j.logger.org.hibernate.test=info
\ No newline at end of file
Modified: core/trunk/cache-jbosscache/pom.xml
===================================================================
--- core/trunk/cache-jbosscache/pom.xml 2007-12-06 20:26:39 UTC (rev 14215)
+++ core/trunk/cache-jbosscache/pom.xml 2007-12-06 20:28:10 UTC (rev 14216)
@@ -60,6 +60,69 @@
<artifactId>jgroups-all</artifactId>
<version>2.2.7</version>
</dependency>
+
+ <!-- testing deps -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/JndiBoundTreeCacheProvider.java
===================================================================
---
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/JndiBoundTreeCacheProvider.java 2007-12-06
20:26:39 UTC (rev 14215)
+++
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/JndiBoundTreeCacheProvider.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -1,4 +1,26 @@
-// $Id: JndiBoundTreeCacheProvider.java 6079 2005-03-16 06:01:18Z oneovthafew $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.util.Properties;
Modified:
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java
===================================================================
---
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java 2007-12-06
20:26:39 UTC (rev 14215)
+++
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -1,4 +1,26 @@
-//$Id: OptimisticTreeCache.java 10118 2006-07-13 21:38:41Z steve.ebersole(a)jboss.com $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.util.HashMap;
Modified:
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCacheProvider.java
===================================================================
---
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCacheProvider.java 2007-12-06
20:26:39 UTC (rev 14215)
+++
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCacheProvider.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -1,4 +1,26 @@
-//$Id: OptimisticTreeCacheProvider.java 9895 2006-05-05 19:27:17Z epbernard $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.util.Properties;
@@ -26,10 +48,10 @@
public class OptimisticTreeCacheProvider implements CacheProvider {
/**
- * @deprecated use {@link Environment.CACHE_PROVIDER_CONFIG}
+ * @deprecated use {@link Environment#CACHE_PROVIDER_CONFIG}
*/
public static final String CONFIG_RESOURCE =
"hibernate.cache.opt_tree_cache.config";
- public static final String DEFAULT_CONFIG = "treecache.xml";
+ public static final String DEFAULT_CONFIG = "treecache-optimistic.xml";
private static final String NODE_LOCKING_SCHEME = "OPTIMISTIC";
private static final Logger log = LoggerFactory.getLogger(
OptimisticTreeCacheProvider.class );
Modified: core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java
===================================================================
---
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java 2007-12-06
20:26:39 UTC (rev 14215)
+++
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -1,4 +1,26 @@
-//$Id: TreeCache.java 9965 2006-05-30 18:00:28Z steve.ebersole(a)jboss.com $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.util.HashMap;
Modified:
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCacheProvider.java
===================================================================
---
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCacheProvider.java 2007-12-06
20:26:39 UTC (rev 14215)
+++
core/trunk/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCacheProvider.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -1,4 +1,26 @@
-//$Id: TreeCacheProvider.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.util.Properties;
@@ -23,7 +45,7 @@
* @deprecated use {@link org.hibernate.cfg.Environment#CACHE_PROVIDER_CONFIG}
*/
public static final String CONFIG_RESOURCE =
"hibernate.cache.tree_cache.config";
- public static final String DEFAULT_CONFIG = "treecache.xml";
+ public static final String DEFAULT_CONFIG = "treecache-optimistic.xml";
private static final Logger log = LoggerFactory.getLogger( TreeCacheProvider.class );
Copied:
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/OptimisticTreeCacheTest.java
(from rev 14213,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/treecache/optimistic/OptimisticTreeCacheTest.java)
===================================================================
---
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/OptimisticTreeCacheTest.java
(rev 0)
+++
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/OptimisticTreeCacheTest.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,131 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache;
+
+import junit.framework.Test;
+import junit.framework.Assert;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.optimistic.DataVersion;
+
+import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
+import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl;
+
+/**
+ * @author Steve Ebersole
+ */
+public class OptimisticTreeCacheTest extends BaseCacheProviderTestCase {
+ public OptimisticTreeCacheTest(String x) {
+ super( x );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( OptimisticTreeCacheTest.class );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ protected Class getCacheProvider() {
+ return OptimisticTreeCacheProvider.class;
+ }
+
+ protected String getConfigResourceKey() {
+ return Environment.CACHE_PROVIDER_CONFIG;
+ }
+
+ protected String getConfigResourceLocation() {
+ return "treecache-optimistic.xml";
+ }
+
+ protected boolean useTransactionManager() {
+ return true;
+ }
+
+ public void testCacheLevelStaleWritesFail() throws Throwable {
+ Fqn fqn = new Fqn( "whatever" );
+ TreeCache treeCache = ( ( OptimisticTreeCacheProvider ) ( (
RegionFactoryCacheProviderBridge ) sfi().getSettings().getRegionFactory()
).getCacheProvider() ).getUnderlyingCache();
+
+ Long long1 = new Long(1);
+ Long long2 = new Long(2);
+
+ try {
+ System.out.println(
"****************************************************************" );
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ treeCache.put( fqn, "ITEM", long1, ManualDataVersion.gen( 1 ) );
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+
+ System.out.println(
"****************************************************************" );
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ treeCache.put( fqn, "ITEM", long2, ManualDataVersion.gen( 2 ) );
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+
+ try {
+ System.out.println(
"****************************************************************" );
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ treeCache.put( fqn, "ITEM", long1, ManualDataVersion.gen( 1 ) );
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ Assert.fail( "stale write allowed" );
+ }
+ catch( Throwable ignore ) {
+ // expected behavior
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ }
+
+ Long current = ( Long ) treeCache.get( fqn, "ITEM" );
+ Assert.assertEquals( "unexpected current value", 2, current.longValue() );
+ }
+ finally {
+ try {
+ treeCache.remove( fqn, "ITEM" );
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+
+ private static class ManualDataVersion implements DataVersion {
+ private final int version;
+
+ public ManualDataVersion(int version) {
+ this.version = version;
+ }
+
+ public boolean newerThan(DataVersion dataVersion) {
+ return this.version > ( ( ManualDataVersion ) dataVersion ).version;
+ }
+
+ public static Option gen(int version) {
+ ManualDataVersion mdv = new ManualDataVersion( version );
+ Option option = new Option();
+ option.setDataVersion( mdv );
+ return option;
+ }
+ }
+}
Copied:
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/PessimisticTreeCacheTest.java
(from rev 12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/treecache/pessimistic/TreeCacheTest.java)
===================================================================
---
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/PessimisticTreeCacheTest.java
(rev 0)
+++
core/trunk/cache-jbosscache/src/test/java/org/hibernate/cache/PessimisticTreeCacheTest.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache;
+
+import junit.framework.Test;
+
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.cache.BaseCacheProviderTestCase;
+
+/**
+ * @author Steve Ebersole
+ */
+public class PessimisticTreeCacheTest extends BaseCacheProviderTestCase {
+ public PessimisticTreeCacheTest(String x) {
+ super( x );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( PessimisticTreeCacheTest.class );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ protected Class getCacheProvider() {
+ return TreeCacheProvider.class;
+ }
+
+ protected String getConfigResourceKey() {
+ return Environment.CACHE_PROVIDER_CONFIG;
+ }
+
+ protected String getConfigResourceLocation() {
+ return "treecache-pessimistic.xml";
+ }
+
+ protected boolean useTransactionManager() {
+ return true;
+ }
+
+}
Added: core/trunk/cache-jbosscache/src/test/resources/hibernate.properties
===================================================================
--- core/trunk/cache-jbosscache/src/test/resources/hibernate.properties
(rev 0)
+++ core/trunk/cache-jbosscache/src/test/resources/hibernate.properties 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,32 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# 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, as published by the Free Software Foundation. #
+# #
+# This program 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 distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:/test
+hibernate.connection.username sa
+hibernate.connection.password
+
+hibernate.connection.pool_size 5
+
+hibernate.cache.region_prefix hibernate.test
Added: core/trunk/cache-jbosscache/src/test/resources/log4j.properties
===================================================================
--- core/trunk/cache-jbosscache/src/test/resources/log4j.properties
(rev 0)
+++ core/trunk/cache-jbosscache/src/test/resources/log4j.properties 2007-12-06 20:28:10
UTC (rev 14216)
@@ -0,0 +1,32 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# 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, as published by the Free Software Foundation. #
+# #
+# This program 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 distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+
+log4j.rootLogger=info, stdout
+
+log4j.logger.org.hibernate.test=info
\ No newline at end of file
Copied: core/trunk/cache-jbosscache/src/test/resources/treecache-optimistic.xml (from rev
12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/treecache/optimistic/treecache.xml)
===================================================================
--- core/trunk/cache-jbosscache/src/test/resources/treecache-optimistic.xml
(rev 0)
+++ core/trunk/cache-jbosscache/src/test/resources/treecache-optimistic.xml 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- Recommended for use as Hibernate's 2nd Level Cache -->
+<!-- For use with JBossCache >= 1.3.0 ONLY!!! -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar,
jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.TreeCache"
+ name="jboss.cache:service=TreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager : no matter since Hibernate will plug in
+ an "adapter" to its own TransactionManagerLookup strategy here
+ -->
+ <attribute
name="TransactionManagerLookupClass">org.jboss.cache.GenericTransactionManagerLookup</attribute>
+
+
+ <!--
+ Node locking scheme:
+ OPTIMISTIC
+ PESSIMISTIC (default)
+ -->
+ <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
+
+ <!--
+ Note that this attribute is IGNORED if your NodeLockingScheme above is
OPTIMISTIC.
+
+ Isolation level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute
name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+
+ INVALIDATION_ASYNC is highly recommended as the mode for use
+ with clustered second-level caches.
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!--
+ Just used for async repl: use a replication queue
+ -->
+ <attribute name="UseReplQueue">false</attribute>
+
+ <!--
+ Replication interval for replication queue (in ms)
+ -->
+ <attribute name="ReplQueueInterval">0</attribute>
+
+ <!--
+ Max number of elements which trigger replication
+ -->
+ <attribute name="ReplQueueMaxElements">0</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all clusters, in order
+ to find each other
+ -->
+ <attribute
name="ClusterName">TreeCache-Cluster</attribute>
+
+ <!-- JGroups protocol stack properties. Can also be a URL,
+ e.g. file:/home/bela/default.xml
+ <attribute name="ClusterProperties"></attribute>
+ -->
+
+ <attribute name="ClusterConfig">
+ <config>
+ <!-- UDP: if you have a multihomed machine,
+ set the bind_addr attribute to the appropriate NIC IP address -->
+ <!-- UDP: On Windows machines, because of the media sense feature
+ being broken with multicast (even after disabling media sense)
+ set the loopback attribute to true -->
+ <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+ ip_ttl="64" ip_mcast="true"
+ mcast_send_buf_size="150000"
mcast_recv_buf_size="80000"
+ ucast_send_buf_size="150000"
ucast_recv_buf_size="80000"
+ loopback="false"/>
+ <PING timeout="2000" num_initial_members="3"
+ up_thread="false" down_thread="false"/>
+ <MERGE2 min_interval="10000"
max_interval="20000"/>
+ <!-- <FD shun="true" up_thread="true"
down_thread="true" />-->
+ <FD_SOCK/>
+ <VERIFY_SUSPECT timeout="1500"
+ up_thread="false" down_thread="false"/>
+ <pbcast.NAKACK gc_lag="50"
retransmit_timeout="600,1200,2400,4800"
+ max_xmit_size="8192" up_thread="false"
down_thread="false"/>
+ <UNICAST timeout="600,1200,2400" window_size="100"
min_threshold="10"
+ down_thread="false"/>
+ <pbcast.STABLE desired_avg_gossip="20000"
+ up_thread="false" down_thread="false"/>
+ <FRAG frag_size="8192"
+ down_thread="false" up_thread="false"/>
+ <pbcast.GMS join_timeout="5000"
join_retry_timeout="2000"
+ shun="true" print_local_addr="true"/>
+ <pbcast.STATE_TRANSFER up_thread="true"
down_thread="true"/>
+ </config>
+ </attribute>
+
+ <!--
+ Whether or not to fetch state on joining a cluster
+ NOTE this used to be called FetchStateOnStartup and has been renamed to be more
descriptive.
+ -->
+ <attribute name="FetchInMemoryState">false</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">20000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+
+ <!-- Name of the eviction policy class. -->
+ <attribute name="EvictionPolicyClass"></attribute>
+
+ <!--
+ Indicate whether to use marshalling or not. Set this to true if you are running
under a scoped
+ class loader, e.g., inside an application server. Default is
"false".
+ -->
+ <attribute name="UseMarshalling">false</attribute>
+
+ </mbean>
+</server>
Copied: core/trunk/cache-jbosscache/src/test/resources/treecache-pessimistic.xml (from rev
12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/treecache/pessimistic/treecache.xml)
===================================================================
--- core/trunk/cache-jbosscache/src/test/resources/treecache-pessimistic.xml
(rev 0)
+++ core/trunk/cache-jbosscache/src/test/resources/treecache-pessimistic.xml 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar,
jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.TreeCache"
+ name="jboss.cache:service=TreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ TransactionManager configuration not required for Hibernate!
+ -->
+
+
+ <!--
+ Node isolation level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute
name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all clusters, in order
+ to find each other
+ -->
+ <attribute
name="ClusterName">TreeCache-Cluster</attribute>
+
+ <!-- JGroups protocol stack properties. Can also be a URL,
+ e.g. file:/home/bela/default.xml
+ <attribute name="ClusterProperties"></attribute>
+ -->
+
+ <attribute name="ClusterConfig">
+ <config>
+ <!-- UDP: if you have a multihomed machine,
+ set the bind_addr attribute to the appropriate NIC IP address -->
+ <!-- UDP: On Windows machines, because of the media sense feature
+ being broken with multicast (even after disabling media sense)
+ set the loopback attribute to true -->
+ <UDP mcast_addr="228.1.2.3" mcast_port="45566"
+ ip_ttl="64" ip_mcast="true"
+ mcast_send_buf_size="150000"
mcast_recv_buf_size="80000"
+ ucast_send_buf_size="150000"
ucast_recv_buf_size="80000"
+ loopback="false"/>
+ <PING timeout="2000" num_initial_members="3"
+ up_thread="false" down_thread="false"/>
+ <MERGE2 min_interval="10000"
max_interval="20000"/>
+ <FD shun="true" up_thread="true"
down_thread="true"/>
+ <VERIFY_SUSPECT timeout="1500"
+ up_thread="false" down_thread="false"/>
+ <pbcast.NAKACK gc_lag="50"
retransmit_timeout="600,1200,2400,4800"
+ up_thread="false" down_thread="false"/>
+ <pbcast.STABLE desired_avg_gossip="20000"
+ up_thread="false" down_thread="false"/>
+ <UNICAST timeout="600,1200,2400" window_size="100"
min_threshold="10"
+ down_thread="false"/>
+ <FRAG frag_size="8192"
+ down_thread="false" up_thread="false"/>
+ <pbcast.GMS join_timeout="5000"
join_retry_timeout="2000"
+ shun="true" print_local_addr="true"/>
+ <pbcast.STATE_TRANSFER up_thread="false"
down_thread="false"/>
+ </config>
+ </attribute>
+
+ <!--
+ Max number of entries in the cache. If this is exceeded, the
+ eviction policy will kick some entries out in order to make
+ more room
+ -->
+ <attribute name="MaxCapacity">20000</attribute>
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ initial state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute
name="InitialStateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">10000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds we hold a lock (not currently
+ implemented) -->
+ <attribute name="LockLeaseTimeout">60000</attribute>
+
+ <!-- Name of the eviction policy class. Not supported now. -->
+ <attribute name="EvictionPolicyClass"></attribute>
+ </mbean>
+
+
+</server>
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2007-12-06 20:26:39 UTC (rev 14215)
+++ core/trunk/core/pom.xml 2007-12-06 20:28:10 UTC (rev 14216)
@@ -22,18 +22,16 @@
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
- <version>${antlrVersion}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- <version>3.1</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
- <version>1.6.1</version>
</dependency>
+
<dependency>
<!-- YUCK, YUCK, YUCK!!!! -->
<groupId>javax.transaction</groupId>
@@ -86,13 +84,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>${antlrPluginVersion}</version>
- <dependencies>
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>${antlrVersion}</version>
- </dependency>
- </dependencies>
<configuration>
<grammars>hql.g,hql-sql.g,sql-gen.g</grammars>
</configuration>
@@ -150,8 +141,7 @@
</reporting>
<properties>
- <antlrVersion>2.7.6</antlrVersion>
- <antlrPluginVersion>2.0.0-SNAPSHOT</antlrPluginVersion>
+ <antlrPluginVersion>2.0-SNAPSHOT</antlrPluginVersion>
</properties>
</project>
Modified: core/trunk/testing/pom.xml
===================================================================
--- core/trunk/testing/pom.xml 2007-12-06 20:26:39 UTC (rev 14215)
+++ core/trunk/testing/pom.xml 2007-12-06 20:28:10 UTC (rev 14216)
@@ -32,4 +32,5 @@
<scope>compile</scope>
</dependency>
</dependencies>
+
</project>
Copied:
core/trunk/testing/src/main/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java
(from rev 14213,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java)
===================================================================
---
core/trunk/testing/src/main/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java
(rev 0)
+++
core/trunk/testing/src/main/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,238 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache;
+
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cache.ReadWriteCache;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+import org.hibernate.stat.Statistics;
+import org.hibernate.test.tm.ConnectionProviderImpl;
+import org.hibernate.test.tm.TransactionManagerLookupImpl;
+import org.hibernate.transaction.JDBCTransactionFactory;
+
+/**
+ * Common requirement testing for each {@link org.hibernate.cache.CacheProvider} impl.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class BaseCacheProviderTestCase extends FunctionalTestCase {
+
+ // note that a lot of the fucntionality here is intended to be used
+ // in creating specific tests for each CacheProvider that would extend
+ // from a base test case (this) for common requirement testing...
+
+ public BaseCacheProviderTestCase(String x) {
+ super( x );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/Item.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
+ cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
+ cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ cfg.setProperty( Environment.USE_STRUCTURED_CACHE, "true" );
+ cfg.setProperty( Environment.CACHE_PROVIDER, getCacheProvider().getName() );
+
+ if ( getConfigResourceKey() != null ) {
+ cfg.setProperty( getConfigResourceKey(), getConfigResourceLocation() );
+ }
+
+ if ( useTransactionManager() ) {
+ cfg.setProperty( Environment.CONNECTION_PROVIDER,
ConnectionProviderImpl.class.getName() );
+ cfg.setProperty( Environment.TRANSACTION_MANAGER_STRATEGY,
TransactionManagerLookupImpl.class.getName() );
+ }
+ else {
+ cfg.setProperty( Environment.TRANSACTION_STRATEGY,
JDBCTransactionFactory.class.getName() );
+ }
+ }
+
+ /**
+ * The cache provider to be tested.
+ *
+ * @return The cache provider.
+ */
+ protected abstract Class getCacheProvider();
+
+ /**
+ * For provider-specific configuration, the name of the property key the
+ * provider expects.
+ *
+ * @return The provider-specific config key.
+ */
+ protected abstract String getConfigResourceKey();
+
+ /**
+ * For provider-specific configuration, the resource location of that
+ * config resource.
+ *
+ * @return The config resource location.
+ */
+ protected abstract String getConfigResourceLocation();
+
+ /**
+ * Should we use a transaction manager for transaction management.
+ *
+ * @return True if we should use a RM; false otherwise.
+ */
+ protected abstract boolean useTransactionManager();
+
+
+ public void testQueryCacheInvalidation() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Item i = new Item();
+ i.setName("widget");
+ i.setDescription("A really top-quality, full-featured widget.");
+ s.persist(i);
+ t.commit();
+ s.close();
+
+ SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics()
+ .getSecondLevelCacheStatistics( Item.class.getName() );
+
+ assertEquals( slcs.getPutCount(), 1 );
+ assertEquals( slcs.getElementCountInMemory(), 1 );
+ assertEquals( slcs.getEntries().size(), 1 );
+
+ s = openSession();
+ t = s.beginTransaction();
+ i = (Item) s.get( Item.class, i.getId() );
+
+ assertEquals( slcs.getHitCount(), 1 );
+ assertEquals( slcs.getMissCount(), 0 );
+
+ i.setDescription("A bog standard item");
+
+ t.commit();
+ s.close();
+
+ assertEquals( slcs.getPutCount(), 2 );
+
+ Object entry = slcs.getEntries().get( i.getId() );
+ Map map;
+ if ( entry instanceof ReadWriteCache.Item ) {
+ map = (Map) ( (ReadWriteCache.Item) entry ).getValue();
+ }
+ else {
+ map = (Map) entry;
+ }
+ assertTrue( map.get("description").equals("A bog standard item")
);
+ assertTrue( map.get("name").equals("widget") );
+
+ // cleanup
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( i );
+ t.commit();
+ s.close();
+ }
+
+ public void testEmptySecondLevelCacheEntry() throws Exception {
+ getSessions().evictEntity( Item.class.getName() );
+ Statistics stats = getSessions().getStatistics();
+ stats.clear();
+ SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(
Item.class.getName() );
+ Map cacheEntries = statistics.getEntries();
+ assertEquals( 0, cacheEntries.size() );
+ }
+
+ public void testStaleWritesLeaveCacheConsistent() {
+ Session s = openSession();
+ Transaction txn = s.beginTransaction();
+ VersionedItem item = new VersionedItem();
+ item.setName( "steve" );
+ item.setDescription( "steve's item" );
+ s.save( item );
+ txn.commit();
+ s.close();
+
+ Long initialVersion = item.getVersion();
+
+ // manually revert the version property
+ item.setVersion( new Long( item.getVersion().longValue() - 1 ) );
+
+ try {
+ s = openSession();
+ txn = s.beginTransaction();
+ s.update( item );
+ txn.commit();
+ s.close();
+ fail( "expected stale write to fail" );
+ }
+ catch( Throwable expected ) {
+ // expected behavior here
+ if ( txn != null ) {
+ try {
+ txn.rollback();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+ finally {
+ if ( s != null && s.isOpen() ) {
+ try {
+ s.close();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+
+ // check the version value in the cache...
+ SecondLevelCacheStatistics slcs = sfi().getStatistics()
+ .getSecondLevelCacheStatistics( VersionedItem.class.getName() );
+
+ Object entry = slcs.getEntries().get( item.getId() );
+ Long cachedVersionValue;
+ if ( entry instanceof ReadWriteCache.Lock ) {
+ //FIXME don't know what to test here
+ cachedVersionValue = new Long( ( (ReadWriteCache.Lock) entry).getUnlockTimestamp() );
+ }
+ else {
+ cachedVersionValue = ( Long ) ( (Map) entry ).get( "_version" );
+ assertEquals( initialVersion.longValue(), cachedVersionValue.longValue() );
+ }
+
+
+ // cleanup
+ s = openSession();
+ txn = s.beginTransaction();
+ item = ( VersionedItem ) s.load( VersionedItem.class, item.getId() );
+ s.delete( item );
+ txn.commit();
+ s.close();
+
+ }
+}
Copied: core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.hbm.xml (from rev
12891, core/trunk/testsuite/src/test/java/org/hibernate/test/cache/Item.hbm.xml)
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.hbm.xml
(rev 0)
+++ core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.hbm.xml 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ 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, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache">
+
+ <class name="Item" table="Items">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+ <class name="VersionedItem" table="VersionedItems">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <version name="version" type="long"/>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Property changes on:
core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Copied: core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.java (from rev
12891, core/trunk/testsuite/src/test/java/org/hibernate/test/cache/Item.java)
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.java
(rev 0)
+++ core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,53 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.cache;
+
+/**
+ * @author Gavin King
+ */
+public class Item {
+ private Long id;
+ private String name;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Property changes on: core/trunk/testing/src/main/java/org/hibernate/test/cache/Item.java
___________________________________________________________________
Name: svn:executable
+ *
Copied: core/trunk/testing/src/main/java/org/hibernate/test/cache/VersionedItem.java (from
rev 12891,
core/trunk/testsuite/src/test/java/org/hibernate/test/cache/VersionedItem.java)
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/test/cache/VersionedItem.java
(rev 0)
+++
core/trunk/testing/src/main/java/org/hibernate/test/cache/VersionedItem.java 2007-12-06
20:28:10 UTC (rev 14216)
@@ -0,0 +1,39 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * 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, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache;
+
+/**
+ * @author Steve Ebersole
+ */
+public class VersionedItem extends Item {
+ private Long version;
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+}
Modified: core/trunk/testsuite/pom.xml
===================================================================
--- core/trunk/testsuite/pom.xml 2007-12-06 20:26:39 UTC (rev 14215)
+++ core/trunk/testsuite/pom.xml 2007-12-06 20:28:10 UTC (rev 14216)
@@ -29,26 +29,6 @@
<artifactId>hibernate-testing</artifactId>
<version>${version}</version>
</dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-ehcache</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-jbosscache</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-oscache</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-swarmcache</artifactId>
- <version>${version}</version>
- </dependency>
<!-- these are optional on core... :( -->
<dependency>
<groupId>javassist</groupId>