Author: cbredesen
Date: 2009-06-17 11:12:54 -0400 (Wed, 17 Jun 2009)
New Revision: 16821
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
Removed:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java
Log:
Split tests into read-only and transactional
Copied:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java
(from rev 16796,
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java)
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java 2009-06-17
15:12:54 UTC (rev 16821)
@@ -0,0 +1,94 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+import org.hibernate.stat.Statistics;
+
+public abstract class AbstractInfinispanTestCase extends FunctionalTestCase {
+ private final String cacheConcurrencyStrategy;
+
+ public AbstractInfinispanTestCase( String string, String cacheConcurrencyStrategy ) {
+ super( string );
+ this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return cacheConcurrencyStrategy;
+ }
+
+ public void testEntityCache() {
+ Item item = new Item("chris", "Chris's Item");
+
+ Session s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.getTransaction().begin();
+ s.persist( item );
+ s.getTransaction().commit();
+ s.close();
+
+ 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();
+ }
+
+ public void testQueryCache() {
+ Item item = new Item( "chris", "Chris's Item" );
+
+ Session s = openSession();
+ s.getTransaction().begin();
+ s.persist( item );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.createQuery( "from Item" ).setCacheable( true ).list();
+ s.close();
+
+ s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.createQuery( "from Item" ).setCacheable( true ).list();
+ assertEquals( 1, stats.getQueryCacheHitCount() );
+ s.createQuery( "delete from Item" ).executeUpdate();
+ s.close();
+ }
+
+ public void testCollectionCache() {
+ Item item = new Item( "chris", "Chris's Item" );
+ Item another = new Item( "another", "Owned Item" );
+ item.addItem( another );
+
+ Session s = openSession();
+ s.getTransaction().begin();
+ s.persist( item );
+ s.persist( another );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ Item loaded = (Item) s.load( Item.class, item.getId() );
+ assertEquals( 1, loaded.getItems().size() );
+ s.close();
+
+ s = openSession();
+ SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics(
Item.class.getName() + ".items" );
+ Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
+ stats.logSummary();
+ assertEquals( item.getName(), loadedWithCachedCollection.getName() );
+ assertEquals( item.getItems().size(), loadedWithCachedCollection.getItems().size() );
+ assertEquals( 1, cStats.getHitCount() );
+ s.close();
+ }
+
+}
\ No newline at end of file
Deleted:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java 2009-06-17
13:31:32 UTC (rev 16820)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java 2009-06-17
15:12:54 UTC (rev 16821)
@@ -1,93 +0,0 @@
-package org.hibernate.test.cache.infinispan.functional;
-
-import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-
-public class BasicCacheTest extends FunctionalTestCase {
-
- public BasicCacheTest( 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("chris", "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();
- }
-
- public void testQueryCache() {
- Item item = new Item( "chris", "Chris's Item" );
-
- Session s = openSession();
- s.getTransaction().begin();
- s.persist( item );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- s.createQuery( "from Item" ).setCacheable( true ).list();
- s.close();
-
- s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- stats.clear();
- s.createQuery( "from Item" ).setCacheable( true ).list();
- assertEquals( 1, stats.getQueryCacheHitCount() );
- s.createQuery( "delete from Item" ).executeUpdate();
- s.close();
- }
-
- public void testCollectionCache() {
- Item item = new Item( "chris", "Chris's Item" );
- Item another = new Item( "another", "Owned Item" );
- item.addItem( another );
-
- Session s = openSession();
- s.getTransaction().begin();
- s.persist( another );
- s.persist( item );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- Item loaded = (Item) s.load( Item.class, item.getId() );
- assertEquals( 1, loaded.getItems().size() );
- s.close();
-
- s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- stats.clear();
- SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics(
Item.class.getName() + ".items" );
- Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
- assertEquals( 1, loadedWithCachedCollection.getItems().size() );
- assertEquals( 1, cStats.getHitCount() );
- s.close();
- }
-
-}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java 2009-06-17
15:12:54 UTC (rev 16821)
@@ -0,0 +1,9 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+public class BasicReadOnlyTestCase extends AbstractInfinispanTestCase {
+
+ public BasicReadOnlyTestCase( String string ) {
+ super( string, "read-only" );
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java 2009-06-17
15:12:54 UTC (rev 16821)
@@ -0,0 +1,9 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+public class BasicTransactionalTestCase extends AbstractInfinispanTestCase {
+
+ public BasicTransactionalTestCase( String string ) {
+ super( string, "transactional" );
+ }
+
+}
Show replies by date