mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-7311 - Fix and test
This commit is contained in:
parent
1f78c9685e
commit
41bac11115
@ -34,6 +34,7 @@
|
||||
import org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl;
|
||||
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
|
||||
import org.hibernate.service.spi.BasicServiceInitiator;
|
||||
import org.hibernate.service.spi.ServiceException;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
|
||||
/**
|
||||
@ -84,7 +85,7 @@ public MultiTenantConnectionProvider initiateService(Map configurationValues, Se
|
||||
}
|
||||
catch (ClassLoadingException cle) {
|
||||
log.warn( "Unable to locate specified class [" + className + "]", cle );
|
||||
return null;
|
||||
throw new ServiceException( "Unable to locate specified multi-tenant connection provider [" + className + "]" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ public MultiTenantConnectionProvider initiateService(Map configurationValues, Se
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn( "Unable to instantiate specified class [" + implClass.getName() + "]", e );
|
||||
return null;
|
||||
throw new ServiceException( "Unable to instantiate specified multi-tenant connection provider [" + implClass.getName() + "]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.hibernate.test.multitenancy;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
import org.hibernate.service.spi.ServiceException;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
/**
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-7311")
|
||||
public class ConfigurationValidationTest extends BaseUnitTestCase {
|
||||
@Test(expected = ServiceException.class)
|
||||
public void testInvalidConnectionProvider() {
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.getProperties().put( Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA );
|
||||
cfg.setProperty( Environment.MULTI_TENANT_CONNECTION_PROVIDER, "class.not.present.in.classpath" );
|
||||
cfg.buildMappings();
|
||||
ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder()
|
||||
.applySettings( cfg.getProperties() ).buildServiceRegistry();
|
||||
cfg.buildSessionFactory( serviceRegistry );
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user