use of io.r2dbc.spi.ConnectionFactory in project spring-boot by spring-projects.
the class R2dbcAutoConfigurationTests method configureWithoutPoolShouldApplyAdditionalProperties.
@Test
void configureWithoutPoolShouldApplyAdditionalProperties() {
this.contextRunner.withPropertyValues("spring.r2dbc.pool.enabled=false", "spring.r2dbc.url:r2dbc:simple://foo", "spring.r2dbc.properties.test=value", "spring.r2dbc.properties.another=2").run((context) -> {
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class)).extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> {
assertThat(options.getRequiredValue(Option.<String>valueOf("test"))).isEqualTo("value");
assertThat(options.getRequiredValue(Option.<String>valueOf("another"))).isEqualTo("2");
});
});
}
use of io.r2dbc.spi.ConnectionFactory in project spring-boot by spring-projects.
the class R2dbcAutoConfigurationTests method configureWithPoolShouldApplyAdditionalProperties.
@Test
void configureWithPoolShouldApplyAdditionalProperties() {
this.contextRunner.withPropertyValues("spring.r2dbc.url:r2dbc:simple://foo", "spring.r2dbc.properties.test=value", "spring.r2dbc.properties.another=2").run((context) -> {
assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class);
ConnectionFactory connectionFactory = context.getBean(ConnectionPool.class).unwrap();
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class)).extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> {
assertThat(options.getRequiredValue(Option.<String>valueOf("test"))).isEqualTo("value");
assertThat(options.getRequiredValue(Option.<String>valueOf("another"))).isEqualTo("2");
});
});
}
use of io.r2dbc.spi.ConnectionFactory in project spring-boot by spring-projects.
the class R2dbcAutoConfigurationTests method configureWithoutPoolInvokeOptionCustomizer.
@Test
void configureWithoutPoolInvokeOptionCustomizer() {
this.contextRunner.withPropertyValues("spring.r2dbc.pool.enabled=false", "spring.r2dbc.url:r2dbc:simple://host/database").withUserConfiguration(CustomizerConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(ConnectionFactory.class).doesNotHaveBean(ConnectionPool.class);
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class)).extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> assertThat(options.getRequiredValue(Option.valueOf("customized"))).isEqualTo(Boolean.TRUE));
});
}
use of io.r2dbc.spi.ConnectionFactory in project jOOQ by jOOQ.
the class DefaultCloseableDSLContext method close.
// -------------------------------------------------------------------------
// XXX AutoCloseable
// -------------------------------------------------------------------------
@Override
public void close() {
ConnectionProvider cp = configuration().connectionProvider();
ConnectionFactory cf = configuration().connectionFactory();
if (cp instanceof DefaultCloseableConnectionProvider) {
DefaultCloseableConnectionProvider dcp = (DefaultCloseableConnectionProvider) cp;
JDBCUtils.safeClose(dcp.connection);
dcp.connection = null;
}
if (cf instanceof DefaultConnectionFactory) {
DefaultConnectionFactory dcf = (DefaultConnectionFactory) cf;
if (dcf.finalize) {
R2DBC.block(dcf.connection.close());
dcf.connection = null;
}
}
}
use of io.r2dbc.spi.ConnectionFactory in project spring-framework by spring-projects.
the class AbstractRoutingConnectionFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
Assert.notNull(this.targetConnectionFactories, "Property 'targetConnectionFactories' must not be null");
this.resolvedConnectionFactories = CollectionUtils.newHashMap(this.targetConnectionFactories.size());
this.targetConnectionFactories.forEach((key, value) -> {
Object lookupKey = resolveSpecifiedLookupKey(key);
ConnectionFactory connectionFactory = resolveSpecifiedConnectionFactory(value);
this.resolvedConnectionFactories.put(lookupKey, connectionFactory);
});
if (this.defaultTargetConnectionFactory != null) {
this.resolvedDefaultConnectionFactory = resolveSpecifiedConnectionFactory(this.defaultTargetConnectionFactory);
}
}
Aggregations