Friday, 12 June
2009
Fri, 12 Jun
'09
4:22 p.m.
Author: cbredesen
Date: 2009-06-12 17:22:09 -0400 (Fri, 12 Jun 2009)
New Revision: 16778
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
Removed:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
Log:
Basic test added, read-only local entity cache works now
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java 2009-06-12
15:39:36 UTC (rev 16777)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java 2009-06-12
21:22:09 UTC (rev 16778)
@@ -8,8 +8,10 @@
import org.infinispan.Cache;
/**
- * Support for Infinispan {@link Region}s. Handles the management of a Cache
- * instance as well as basic peripheral operations.
+ * Support for Infinispan {@link Region}s. Handles common "utility" methods
for
+ * an underlying named Cache. In other words, this implementation doesn't
+ * actually read or write data. Subclasses are expected to provide core cache
+ * interaction appropriate to the semantics needed.
*
* @author Chris Bredesen
*/
Copied:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
(from rev 16771,
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java)
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java 2009-06-12
21:22:09 UTC (rev 16778)
@@ -0,0 +1,38 @@
+package org.hibernate.test.cache.infinispan;
+
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.test.cache.BaseRegionFactoryTestCase;
+
+public class InfinispanTest extends BaseRegionFactoryTestCase {
+
+ public InfinispanTest( String x ) {
+ super( x );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Class getRegionFactory() {
+ return InfinispanRegionFactory.class;
+ }
+
+ @Override
+ protected String getConfigResourceKey() {
+ return null;
+ }
+
+ @Override
+ protected String getConfigResourceLocation() {
+ return null;
+ }
+
+ @Override
+ protected boolean useTransactionManager() {
+ return false;
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "read-only";
+ }
+
+}
\ No newline at end of file
Property changes on:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java 2009-06-12
21:22:09 UTC (rev 16778)
@@ -0,0 +1,45 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.stat.Statistics;
+
+public class BasicEntityTest extends FunctionalTestCase {
+
+ public BasicEntityTest( String string ) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ public void testEntityCache() {
+ Item item = new Item();
+ item.setName( "chris" );
+ item.setDescription( "Chris's Item" );
+
+ Session s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.getTransaction().begin();
+ s.persist( item );
+ s.getTransaction().commit();
+ s.close();
+
+ stats.clear();
+ s = openSession();
+ Item found = (Item) s.load( Item.class, item.getId() );
+ System.out.println( stats );
+ assertEquals( item.getDescription(), found.getDescription() );
+ assertEquals( 0, stats.getSecondLevelCacheMissCount() );
+ assertEquals( 1, stats.getSecondLevelCacheHitCount() );
+ s.delete( found );
+ s.close();
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml 2009-06-12
21:22:09 UTC (rev 16778)
@@ -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.infinispan.functional">
+
+ <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/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java 2009-06-12
21:22:09 UTC (rev 16778)
@@ -0,0 +1,57 @@
+/*
+ * 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.infinispan.functional;
+
+/**
+ * @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/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2009-06-12
21:22:09 UTC (rev 16778)
@@ -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.infinispan.functional;
+
+/**
+ * @author Steve Ebersole
+ */
+public class VersionedItem extends Item {
+ private Long version;
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+}
Property changes on:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties 2009-06-12
15:39:36 UTC (rev 16777)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties 2009-06-12
21:22:09 UTC (rev 16778)
@@ -32,3 +32,8 @@
hibernate.format_sql true
hibernate.max_fetch_depth 5
+
+hibernate.generate_statistics true
+
+hibernate.cache.use_second_level_cache true
+hibernate.cache.region.factory_class
org.hibernate.cache.infinispan.InfinispanRegionFactory
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties 2009-06-12
15:39:36 UTC (rev 16777)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties 2009-06-12
21:22:09 UTC (rev 16778)
@@ -30,7 +30,8 @@
log4j.rootLogger=info, stdout
log4j.logger.org.hibernate.test=info
-log4j.logger.org.hibernate.cache=debug
+log4j.logger.org.hibernate.cache=trace
+log4j.logger.org.hibernate.SQL=debug
#log4j.logger.org.jgroups=info
#log4j.logger.org.jboss.cache=trace
#log4j.logger.org.jboss.cache.RegionManager=info