use of org.springframework.boot.r2dbc.OptionsCapableConnectionFactory in project spring-boot by spring-projects.
the class R2dbcAutoConfigurationTests method configureWithPoolInvokeOptionCustomizer.
@Test
void configureWithPoolInvokeOptionCustomizer() {
this.contextRunner.withPropertyValues("spring.r2dbc.url:r2dbc:simple://host/database").withUserConfiguration(CustomizerConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class);
ConnectionFactory pool = context.getBean(ConnectionFactory.class);
ConnectionFactory connectionFactory = ((ConnectionPool) pool).unwrap();
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class)).extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> assertThat(options.getRequiredValue(Option.valueOf("customized"))).isEqualTo(Boolean.TRUE));
});
}
use of org.springframework.boot.r2dbc.OptionsCapableConnectionFactory 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 org.springframework.boot.r2dbc.OptionsCapableConnectionFactory 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 org.springframework.boot.r2dbc.OptionsCapableConnectionFactory 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));
});
}
Aggregations