Adding 'serviceRegistryHolder' instance variable due to changes commited on master for Configuration class

This commit is contained in:
Hernán Chanfreau 2011-01-03 20:32:05 -02:00 committed by adamw
parent 83b1f22ea9
commit 0541cbf966
1 changed files with 14 additions and 2 deletions

View File

@ -8,8 +8,10 @@ import org.hibernate.MappingException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.AuditReaderFactory;
import org.hibernate.test.common.ServiceRegistryHolder;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
@ -27,6 +29,7 @@ public abstract class AbstractOneSessionTest {
protected Configuration config; protected Configuration config;
private ServiceRegistryHolder serviceRegistryHolder;
private SessionFactory sessionFactory; private SessionFactory sessionFactory;
private Session session ; private Session session ;
private AuditReader auditReader; private AuditReader auditReader;
@ -45,7 +48,8 @@ public abstract class AbstractOneSessionTest {
this.initMappings(); this.initMappings();
sessionFactory = config.buildSessionFactory(); serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
sessionFactory = config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
} }
protected abstract void initMappings() throws MappingException, URISyntaxException ; protected abstract void initMappings() throws MappingException, URISyntaxException ;
@ -61,7 +65,15 @@ public abstract class AbstractOneSessionTest {
@AfterClass @AfterClass
public void closeSessionFactory() { public void closeSessionFactory() {
sessionFactory.close(); try {
sessionFactory.close();
}
finally {
if ( serviceRegistryHolder != null ) {
serviceRegistryHolder.destroy();
serviceRegistryHolder = null;
}
}
} }
/** /**