Skip to content

Commit

Permalink
OGM-966 Add method to get the service registry in JpaTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD authored and gunnarmorling committed Jan 22, 2016
1 parent d6416ed commit a2cda1a
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -27,8 +27,10 @@
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.jpa.HibernateEntityManagerFactory;
import org.hibernate.ogm.jpa.HibernateOgmPersistence;
import org.hibernate.ogm.jpa.impl.OgmEntityManagerFactory;
import org.hibernate.ogm.utils.SkippableTestRunner;
import org.hibernate.ogm.utils.TestHelper;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -104,6 +106,13 @@ private static TransactionManager extractJBossTransactionManager(EntityManagerFa
return sessionFactory.getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
}

protected ServiceRegistryImplementor getServiceRegistry() {
OgmEntityManagerFactory emFactory = ( (OgmEntityManagerFactory) getFactory() );
SessionFactoryImplementor sessionFactory = emFactory.getSessionFactory();
ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
return serviceRegistry;
}

@After
public void closeFactory() throws Exception {
if ( transactionManager != null && transactionManager.getStatus() == Status.STATUS_ACTIVE ) {
Expand Down

0 comments on commit a2cda1a

Please sign in to comment.