use of org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration in project hibernate-reactive by hibernate.
the class JdbcUrlParserTest method assertOptions.
/**
* Create the default {@link SqlConnectOptions} with the given extra properties
* and assert that's correct.
*/
private void assertOptions(String url, String expectedDbName, Map<String, String> parameters) {
URI uri = DefaultSqlClientPool.parse(url);
SqlConnectOptions options = new DefaultSqlClientPoolConfiguration().connectOptions(uri);
// These keys won't be mapped as properties
String username = parameters.remove("user");
String password = parameters.remove("password");
parameters.remove("database");
assertThat(options).as("URL: " + url).isNotNull();
assertThat(options.getUser()).as("URL: " + url).isEqualTo(username);
assertThat(options.getPassword()).as("URL: " + url).isEqualTo(password);
assertThat(options.getDatabase()).as("URL: " + url).isEqualTo(expectedDbName);
assertThat(options.getHost()).as("URL: " + url).isEqualTo("localhost");
assertThat(options.getPort()).as("URL: " + url).isEqualTo(dbType().getDefaultPort());
// Check extra properties
assertThat(options.getProperties()).as("URL: " + url).containsExactlyInAnyOrderEntriesOf(parameters);
}
use of org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration in project hibernate-reactive by hibernate.
the class JdbcUrlParserTest method missingUser.
@Test
public void missingUser() {
final HibernateError error = assertThrows(HibernateError.class, () -> {
String url = createJdbcUrl("localhost", dbType().getDefaultPort(), DEFAULT_DB, Map.of());
URI uri = DefaultSqlClientPool.parse(url);
new DefaultSqlClientPoolConfiguration().connectOptions(uri);
});
assertThat(error.getMessage()).contains("database username not specified");
}
use of org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration in project hibernate-reactive by hibernate.
the class ReactiveConnectionPoolTest method configureAndStartPool.
private ReactiveConnectionPool configureAndStartPool(Map<String, Object> config) {
DefaultSqlClientPoolConfiguration poolConfig = new DefaultSqlClientPoolConfiguration();
poolConfig.configure(config);
registryRule.addService(SqlClientPoolConfiguration.class, poolConfig);
registryRule.addService(JdbcServices.class, new JdbcServicesImpl() {
@Override
public SqlStatementLogger getSqlStatementLogger() {
return new SqlStatementLogger();
}
});
DefaultSqlClientPool reactivePool = new DefaultSqlClientPool();
reactivePool.injectServices(registryRule.getServiceRegistry());
reactivePool.configure(config);
reactivePool.start();
return reactivePool;
}
use of org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration in project hibernate-reactive by hibernate.
the class DefaultPortTest method testUnrecognizedSchemeException.
@Test
public void testUnrecognizedSchemeException() throws URISyntaxException {
Assert.assertThrows(IllegalArgumentException.class, () -> {
URI uri = new URI("bogusScheme://localhost/database");
new DefaultSqlClientPoolConfiguration().connectOptions(uri);
});
}
use of org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration in project hibernate-reactive by hibernate.
the class DefaultPortTest method testDefaultPortIsSet.
@Test
public void testDefaultPortIsSet() throws URISyntaxException {
DefaultSqlClientPoolConfiguration configuration = new DefaultSqlClientPoolConfiguration();
configuration.configure(requiredProperties());
SqlConnectOptions sqlConnectOptions = configuration.connectOptions(new URI(scheme() + "://localhost/database"));
Assertions.assertThat(sqlConnectOptions.getPort()).as("Default port not defined for " + dbType()).isEqualTo(dbType().getDefaultPort());
}
Aggregations