use of org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl in project hibernate-orm by hibernate.
the class ConnectionCreatorTest method testBadUrl.
@Test
@TestForIssue(jiraKey = "HHH-8621")
public void testBadUrl() throws Exception {
DriverConnectionCreator connectionCreator = new DriverConnectionCreator((Driver) Class.forName("org.h2.Driver").newInstance(), new StandardServiceRegistryImpl(true, new BootstrapServiceRegistryImpl(), Collections.<StandardServiceInitiator>emptyList(), Collections.<ProvidedService>emptyList(), Collections.emptyMap()) {
@Override
@SuppressWarnings("unchecked")
public <R extends Service> R getService(Class<R> serviceRole) {
if (JdbcServices.class.equals(serviceRole)) {
// return a new, not fully initialized JdbcServicesImpl
return (R) new JdbcServicesImpl();
}
return super.getService(serviceRole);
}
}, "jdbc:h2:mem:test-bad-urls;nosuchparam=saywhat", new Properties(), false, null);
try {
Connection conn = connectionCreator.createConnection();
conn.close();
fail("Expecting the bad Connection URL to cause an exception");
} catch (JDBCConnectionException expected) {
}
}
use of org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl in project hibernate-orm by hibernate.
the class BootstrapServiceRegistryBuilder method build.
/**
* Build the bootstrap registry.
*
* @return The built bootstrap registry
*/
public BootstrapServiceRegistry build() {
final ClassLoaderService classLoaderService;
if (providedClassLoaderService == null) {
// Use a set. As an example, in JPA, OsgiClassLoader may be in both
// the providedClassLoaders and the overridenClassLoader.
final Set<ClassLoader> classLoaders = new HashSet<ClassLoader>();
if (providedClassLoaders != null) {
classLoaders.addAll(providedClassLoaders);
}
classLoaderService = new ClassLoaderServiceImpl(classLoaders, tcclLookupPrecedence);
} else {
classLoaderService = providedClassLoaderService;
}
final IntegratorServiceImpl integratorService = new IntegratorServiceImpl(providedIntegrators, classLoaderService);
return new BootstrapServiceRegistryImpl(autoCloseRegistry, classLoaderService, strategySelectorBuilder.buildSelector(classLoaderService), integratorService);
}
Aggregations