use of org.hibernate.reactive.pool.ReactiveConnectionPool in project hibernate-reactive by hibernate.
the class ReactiveConnectionPoolTest method configureWithCredentials.
@Test
public void configureWithCredentials(TestContext context) {
// Set up URL with invalid credentials so we can ensure that
// explicit USER and PASS settings take precedence over credentials in the URL
String url = DatabaseConfiguration.getJdbcUrl();
url = url.replace("user=" + DatabaseConfiguration.USERNAME, "user=bogus");
url = url.replace("password=" + DatabaseConfiguration.PASSWORD, "password=bogus");
// Correct user/password are supplied explicitly in the config map and
// should override the credentials in the URL
Map<String, Object> config = new HashMap<>();
config.put(Settings.URL, url);
config.put(Settings.USER, DatabaseConfiguration.USERNAME);
config.put(Settings.PASS, DatabaseConfiguration.PASSWORD);
ReactiveConnectionPool reactivePool = configureAndStartPool(config);
test(context, verifyConnectivity(context, reactivePool));
}
use of org.hibernate.reactive.pool.ReactiveConnectionPool in project hibernate-reactive by hibernate.
the class ReactiveConnectionPoolTest method configureWithWrongCredentials.
@Test
public void configureWithWrongCredentials(TestContext context) {
String url = DatabaseConfiguration.getJdbcUrl();
Map<String, Object> config = new HashMap<>();
config.put(Settings.URL, url);
config.put(Settings.USER, "bogus");
config.put(Settings.PASS, "bogus");
ReactiveConnectionPool reactivePool = configureAndStartPool(config);
test(context, assertThrown(PgException.class, verifyConnectivity(context, reactivePool)).thenAccept(e -> assertThat(e.getMessage()).contains("bogus")));
}
use of org.hibernate.reactive.pool.ReactiveConnectionPool in project hibernate-reactive by hibernate.
the class ReactiveConnectionPoolTest method configureWithJdbcUrl.
@Test
public void configureWithJdbcUrl(TestContext context) {
String url = DatabaseConfiguration.getJdbcUrl();
Map<String, Object> config = new HashMap<>();
config.put(Settings.URL, url);
ReactiveConnectionPool reactivePool = configureAndStartPool(config);
test(context, verifyConnectivity(context, reactivePool));
}
use of org.hibernate.reactive.pool.ReactiveConnectionPool in project hibernate-reactive by hibernate.
the class ReactiveConnectionPoolInitiator method initiateService.
@Override
public ReactiveConnectionPool initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
Object configValue = configurationValues.get(Settings.SQL_CLIENT_POOL);
if (configValue == null) {
return new DefaultSqlClientPool();
}
if (configValue instanceof ReactiveConnectionPool) {
return (ReactiveConnectionPool) configValue;
} else {
final Class<ReactiveConnectionPool> implClass;
if (configValue instanceof Class) {
implClass = (Class) configValue;
} else {
final String className = configValue.toString();
final ClassLoaderService classLoaderService = registry.getService(ClassLoaderService.class);
try {
implClass = classLoaderService.classForName(className);
} catch (ClassLoadingException cle) {
throw new ServiceException("Unable to locate specified reactive connection pool [" + className + "]");
}
}
try {
LOG.instantiatingReactivePool(implClass);
return implClass.newInstance();
} catch (Exception e) {
throw new ServiceException("Unable to instantiate specified reactive connection pool [" + implClass.getName() + "]");
}
}
}
Aggregations