diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/JndiRegionFactoryTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/JndiRegionFactoryTestCase.java index a084fcf85d..16e62ec8a4 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/JndiRegionFactoryTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/JndiRegionFactoryTestCase.java @@ -50,7 +50,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.Mappings; import org.hibernate.dialect.Dialect; -import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.metamodel.spi.source.MetadataImplementor; import org.hibernate.stat.Statistics; import static org.junit.Assert.assertEquals; @@ -83,7 +83,10 @@ public class JndiRegionFactoryTestCase extends SingleNodeTestCase { protected Class getCacheRegionFactory() { return JndiInfinispanRegionFactory.class; } - + @Override + protected void afterConstructAndConfigureMetadata(MetadataImplementor metadataImplementor) { + afterConfigurationBuilt( null, null ); + } @Override public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) { if ( bindToJndi ) { @@ -118,22 +121,22 @@ public class JndiRegionFactoryTestCase extends SingleNodeTestCase { @Test public void testRedeployment() throws Exception { - addEntityCheckCache( sessionFactory() ); + addEntityCheckCache( ); sessionFactory().close(); bindToJndi = false; - SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) configuration().buildSessionFactory( serviceRegistry() ); - addEntityCheckCache( sessionFactory ); - JndiInfinispanRegionFactory regionFactory = (JndiInfinispanRegionFactory) sessionFactory.getSettings().getRegionFactory(); + rebuildSessionFactory(); + addEntityCheckCache( ); + JndiInfinispanRegionFactory regionFactory = (JndiInfinispanRegionFactory) sessionFactory().getSettings().getRegionFactory(); Cache cache = regionFactory.getCacheManager().getCache( "org.hibernate.test.cache.infinispan.functional.Item" ); assertEquals( ComponentStatus.RUNNING, cache.getStatus() ); } - private void addEntityCheckCache(SessionFactoryImplementor sessionFactory) throws Exception { + private void addEntityCheckCache() throws Exception { Item item = new Item( "chris", "Chris's Item" ); beginTx(); try { - Session s = sessionFactory.openSession(); + Session s = sessionFactory().openSession(); s.getTransaction().begin(); s.persist( item ); s.getTransaction().commit(); @@ -148,9 +151,9 @@ public class JndiRegionFactoryTestCase extends SingleNodeTestCase { beginTx(); try { - Session s = sessionFactory.openSession(); + Session s = sessionFactory().openSession(); Item found = (Item) s.load( Item.class, item.getId() ); - Statistics stats = sessionFactory.getStatistics(); + Statistics stats = sessionFactory().getStatistics(); log.info( stats.toString() ); assertEquals( item.getDescription(), found.getDescription() ); assertEquals( 0, stats.getSecondLevelCacheMissCount() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java index a270cd252f..e2b9d14e25 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java @@ -50,8 +50,8 @@ public abstract class SingleNodeTestCase extends BaseCoreFunctionalTestCase { private static final Log log = LogFactory.getLog( SingleNodeTestCase.class ); protected TransactionManager tm; - @Before - public void prepare() { + @Override + protected void prepareTest() throws Exception { tm = getTransactionManager(); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index a10ceddd88..acfd154077 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -450,7 +450,10 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { serviceRegistry = buildServiceRegistry( configuration ); if ( isMetadataUsed ) { // need to rebuild metadata because serviceRegistry was recreated - sessionFactory = ( SessionFactoryImplementor ) buildMetadata( serviceRegistry ).buildSessionFactory(); + MetadataImplementor metadataImplementor = buildMetadata( serviceRegistry ); + afterConstructAndConfigureMetadata( metadataImplementor ); + applyCacheSettings(metadataImplementor); + sessionFactory = ( SessionFactoryImplementor ) metadataImplementor.buildSessionFactory(); } else { sessionFactory = ( SessionFactoryImplementor ) configuration.buildSessionFactory( serviceRegistry );