use of org.hibernate.engine.jdbc.spi.JdbcServices in project hibernate-orm by hibernate.
the class C3P0ConnectionProviderTest method testC3P0isDefaultWhenThereIsC3P0Properties.
@Test
public void testC3P0isDefaultWhenThereIsC3P0Properties() {
JdbcServices jdbcServices = serviceRegistry().getService(JdbcServices.class);
ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(ConnectionProviderJdbcConnectionAccess.class, jdbcServices.getBootstrapJdbcConnectionAccess());
assertTrue(connectionAccess.getConnectionProvider() instanceof C3P0ConnectionProvider);
}
use of org.hibernate.engine.jdbc.spi.JdbcServices in project hibernate-orm by hibernate.
the class ServiceBootstrappingTest method testBuildWithServiceOverride.
@Test
public void testBuildWithServiceOverride() {
StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings(ConnectionProviderBuilder.getConnectionProviderProperties()).build();
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
props.setProperty(Environment.DIALECT, H2Dialect.class.getName());
try {
JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(ConnectionProviderJdbcConnectionAccess.class, jdbcServices.getBootstrapJdbcConnectionAccess());
assertTrue(connectionAccess.getConnectionProvider().isUnwrappableAs(DriverManagerConnectionProviderImpl.class));
} finally {
serviceRegistry.destroy();
}
try {
serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings(props).addService(ConnectionProvider.class, new UserSuppliedConnectionProviderImpl()).build();
JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(ConnectionProviderJdbcConnectionAccess.class, jdbcServices.getBootstrapJdbcConnectionAccess());
assertTrue(connectionAccess.getConnectionProvider().isUnwrappableAs(UserSuppliedConnectionProviderImpl.class));
} finally {
serviceRegistry.destroy();
}
}
Aggregations