HHH-15973 hibernate-envers tests must rely on SharedDriverManagerConnectionProviderImpl instead of DriverManagerConnectionProviderImpl
This commit is contained in:
parent
80a27ebcbe
commit
fc57bd6a17
|
@ -13,16 +13,18 @@ import java.net.URL;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
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.envers.configuration.EnversSettings;
|
import org.hibernate.envers.configuration.EnversSettings;
|
||||||
import org.hibernate.internal.util.PropertiesHelper;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +59,13 @@ public abstract class AbstractOneSessionTest extends AbstractEnversTest {
|
||||||
|
|
||||||
this.initMappings();
|
this.initMappings();
|
||||||
|
|
||||||
|
if ( !Environment.getProperties().containsKey( Environment.CONNECTION_PROVIDER ) ) {
|
||||||
|
config.getProperties().put(
|
||||||
|
AvailableSettings.CONNECTION_PROVIDER,
|
||||||
|
SharedDriverManagerConnectionProviderImpl.getInstance()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() );
|
||||||
sessionFactory = config.buildSessionFactory( serviceRegistry );
|
sessionFactory = config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.orm.test.envers.AbstractEnversTest;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -29,6 +30,7 @@ public class BasicModelingTest extends AbstractEnversTest {
|
||||||
public void testMetamodelBuilding() {
|
public void testMetamodelBuilding() {
|
||||||
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" )
|
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" )
|
||||||
|
.applySetting( AvailableSettings.CONNECTION_PROVIDER, SharedDriverManagerConnectionProviderImpl.getInstance() )
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
Metadata metadata = new MetadataSources( ssr )
|
Metadata metadata = new MetadataSources( ssr )
|
||||||
|
|
|
@ -13,6 +13,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.envers.boot.internal.EnversService;
|
import org.hibernate.envers.boot.internal.EnversService;
|
||||||
import org.hibernate.envers.configuration.Configuration;
|
import org.hibernate.envers.configuration.Configuration;
|
||||||
import org.hibernate.envers.configuration.EnversSettings;
|
import org.hibernate.envers.configuration.EnversSettings;
|
||||||
|
@ -20,6 +22,7 @@ import org.hibernate.envers.strategy.AuditStrategy;
|
||||||
import org.hibernate.envers.strategy.DefaultAuditStrategy;
|
import org.hibernate.envers.strategy.DefaultAuditStrategy;
|
||||||
import org.hibernate.envers.strategy.ValidityAuditStrategy;
|
import org.hibernate.envers.strategy.ValidityAuditStrategy;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
@ -73,6 +76,8 @@ public class AuditStraegySelectorTest {
|
||||||
properties.put( EnversSettings.AUDIT_STRATEGY, propertyValue );
|
properties.put( EnversSettings.AUDIT_STRATEGY, propertyValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
properties.put(AvailableSettings.CONNECTION_PROVIDER, SharedDriverManagerConnectionProviderImpl.getInstance() );
|
||||||
|
|
||||||
final ServiceRegistry sr = ServiceRegistryBuilder.buildServiceRegistry( properties );
|
final ServiceRegistry sr = ServiceRegistryBuilder.buildServiceRegistry( properties );
|
||||||
try {
|
try {
|
||||||
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( sr ).buildMetadata();
|
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( sr ).buildMetadata();
|
||||||
|
|
|
@ -9,9 +9,12 @@ package org.hibernate.orm.test.envers.integrator;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +28,12 @@ public class BasicIntegratorTest {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-9675" )
|
@TestForIssue( jiraKey = "HHH-9675" )
|
||||||
public void testNoAudited() {
|
public void testNoAudited() {
|
||||||
new Configuration().buildSessionFactory().close();
|
new Configuration().buildSessionFactory(new StandardServiceRegistryBuilder()
|
||||||
new Configuration().addAnnotatedClass( SimpleNonAuditedEntity.class ).buildSessionFactory().close();
|
.applySetting(AvailableSettings.CONNECTION_PROVIDER, SharedDriverManagerConnectionProviderImpl.getInstance())
|
||||||
|
.build()).close();
|
||||||
|
new Configuration().addAnnotatedClass( SimpleNonAuditedEntity.class ).buildSessionFactory(new StandardServiceRegistryBuilder()
|
||||||
|
.applySetting(AvailableSettings.CONNECTION_PROVIDER, SharedDriverManagerConnectionProviderImpl.getInstance())
|
||||||
|
.build()).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -18,11 +18,13 @@ import org.hibernate.boot.model.relational.QualifiedNameImpl;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
import org.hibernate.id.enhanced.SequenceStructure;
|
import org.hibernate.id.enhanced.SequenceStructure;
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -34,7 +36,9 @@ public class ExportIdentifierTest extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-12935" )
|
@TestForIssue( jiraKey = "HHH-12935" )
|
||||||
public void testUniqueExportableIdentifier() {
|
public void testUniqueExportableIdentifier() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
|
.applySetting(AvailableSettings.CONNECTION_PROVIDER, SharedDriverManagerConnectionProviderImpl.getInstance())
|
||||||
|
.build();
|
||||||
final MetadataBuilderImpl.MetadataBuildingOptionsImpl options = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( ssr );
|
final MetadataBuilderImpl.MetadataBuildingOptionsImpl options = new MetadataBuilderImpl.MetadataBuildingOptionsImpl( ssr );
|
||||||
options.setBootstrapContext( new BootstrapContextImpl( ssr, options ) );
|
options.setBootstrapContext( new BootstrapContextImpl( ssr, options ) );
|
||||||
final Database database = new Database( options );
|
final Database database = new Database( options );
|
||||||
|
|
Loading…
Reference in New Issue