HHH-14529 Stop using two separate BootstrapServiceRegistries for the same SessionFactory in BaseCoreFunctionalTestCase

This commit is contained in:
Yoann Rodière 2021-03-31 16:51:42 +02:00
parent ebb30aa178
commit fcc63d9ab0
10 changed files with 30 additions and 42 deletions

View File

@ -51,12 +51,11 @@ public class BasicTypeCollectionTest extends BaseCoreFunctionalTestCase {
}
@Override
protected Configuration constructAndConfigureConfiguration() {
Configuration configuration = super.constructAndConfigureConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.registerTypeContributor( (typeContributions, serviceRegistry) -> {
typeContributions.contributeType( new CommaDelimitedStringsType() );
} );
return configuration;
}
//tag::collections-comma-delimited-collection-example[]

View File

@ -32,14 +32,13 @@ public class BitSetTypeTest extends BaseCoreFunctionalTestCase {
}
@Override
protected Configuration constructAndConfigureConfiguration() {
Configuration configuration = super.constructAndConfigureConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
//tag::basic-custom-type-register-BasicType-example[]
configuration.registerTypeContributor( (typeContributions, serviceRegistry) -> {
typeContributions.contributeType( BitSetType.INSTANCE );
} );
//end::basic-custom-type-register-BasicType-example[]
return configuration;
}
@Test

View File

@ -36,14 +36,13 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
}
@Override
protected Configuration constructAndConfigureConfiguration() {
Configuration configuration = super.constructAndConfigureConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
//tag::basic-custom-type-register-UserType-example[]
configuration.registerTypeContributor( (typeContributions, serviceRegistry) -> {
typeContributions.contributeType( BitSetUserType.INSTANCE, "bitset");
} );
//end::basic-custom-type-register-UserType-example[]
return configuration;
}
@Test

View File

@ -33,13 +33,12 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
}
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
Class<? extends MultiTableBulkIdStrategy> strategyClass = getMultiTableBulkIdStrategyClass();
if ( strategyClass != null ) {
configuration.setProperty( AvailableSettings.HQL_BULK_ID_STRATEGY, strategyClass.getName() );
}
return configuration;
}
protected abstract Class<? extends MultiTableBulkIdStrategy> getMultiTableBulkIdStrategyClass();

View File

@ -32,10 +32,9 @@ public abstract class AbstractBulkIdTest extends BaseCoreFunctionalTestCase {
}
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setProperty( AvailableSettings.HQL_BULK_ID_STRATEGY, getMultiTableBulkIdStrategyClass().getName() );
return configuration;
}
protected abstract Class<? extends MultiTableBulkIdStrategy> getMultiTableBulkIdStrategyClass();

View File

@ -47,15 +47,16 @@ import static org.junit.Assert.fail;
public class SQLServerDialectCollationTest extends BaseCoreFunctionalTestCase {
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setProperty( AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, Boolean.TRUE.toString() );
return configuration;
}
@Override
protected void buildSessionFactory() {
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
StandardServiceRegistryImpl _serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
StandardServiceRegistryImpl _serviceRegistry =
buildServiceRegistry( bootRegistry, constructAndConfigureConfiguration( bootRegistry ) );
try {
try {

View File

@ -43,10 +43,9 @@ public class SQLServerDialectTempTableCollationTest extends BaseCoreFunctionalTe
private boolean collationChanged;
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setProperty( AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, Boolean.TRUE.toString() );
return configuration;
}
@Override
@ -56,7 +55,7 @@ public class SQLServerDialectTempTableCollationTest extends BaseCoreFunctionalTe
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry(
bootRegistry,
constructConfiguration()
constructAndConfigureConfiguration( bootRegistry )
);
try {
TransactionUtil.doWithJDBC(
@ -92,7 +91,8 @@ public class SQLServerDialectTempTableCollationTest extends BaseCoreFunctionalTe
@Override
protected void buildSessionFactory() {
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
StandardServiceRegistryImpl serviceRegistry =
buildServiceRegistry( bootRegistry, constructAndConfigureConfiguration( bootRegistry ) );
try {
try {

View File

@ -44,10 +44,9 @@ import static org.junit.Assert.assertTrue;
public class SQLServerDialectTest extends BaseCoreFunctionalTestCase {
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setProperty( AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, Boolean.TRUE.toString() );
return configuration;
}
@Test

View File

@ -24,10 +24,9 @@ public class TenantResolverConfigurationTest extends BaseCoreFunctionalTestCase
private TestCurrentTenantIdentifierResolver currentTenantResolver = new TestCurrentTenantIdentifierResolver();
@Override
protected Configuration constructAndConfigureConfiguration() {
Configuration configuration = super.constructAndConfigureConfiguration();
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setCurrentTenantIdentifierResolver( currentTenantResolver );
return configuration;
}
@Test

View File

@ -112,11 +112,11 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
protected void buildSessionFactory(Consumer<Configuration> configurationAdapter) {
// for now, build the configuration to get all the property settings
configuration = constructAndConfigureConfiguration();
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
configuration = constructAndConfigureConfiguration( bootRegistry );
if ( configurationAdapter != null ) {
configurationAdapter.accept(configuration);
}
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
serviceRegistry = buildServiceRegistry( bootRegistry, configuration );
// this is done here because Configuration does not currently support 4.0 xsd
afterConstructAndConfigureConfiguration( configuration );
@ -145,14 +145,8 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
buildSessionFactory( configurationAdapter );
}
protected Configuration buildConfiguration() {
Configuration cfg = constructAndConfigureConfiguration();
afterConstructAndConfigureConfiguration( cfg );
return cfg;
}
protected Configuration constructAndConfigureConfiguration() {
Configuration cfg = constructConfiguration();
protected Configuration constructAndConfigureConfiguration(BootstrapServiceRegistry bootstrapServiceRegistry) {
Configuration cfg = constructConfiguration( bootstrapServiceRegistry );
configure( cfg );
return cfg;
}
@ -163,8 +157,8 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
afterConfigurationBuilt( cfg );
}
protected Configuration constructConfiguration() {
Configuration configuration = new Configuration();
protected Configuration constructConfiguration(BootstrapServiceRegistry bootstrapServiceRegistry) {
Configuration configuration = new Configuration( bootstrapServiceRegistry );
configuration.setProperty( AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
configuration.setProperty( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
if ( createSchema() ) {