Search in sources :

Example 11 with ConnectionFactoryOptions

use of io.r2dbc.spi.ConnectionFactoryOptions in project spring-boot by spring-projects.

the class ConnectionFactoryBuilderTests method optionIsMappedWhenCreatingPoolConfiguration.

@ParameterizedTest
@SuppressWarnings({ "rawtypes", "unchecked" })
@MethodSource("poolingConnectionProviderOptions")
void optionIsMappedWhenCreatingPoolConfiguration(Option option) {
    String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID();
    ExpectedOption expectedOption = ExpectedOption.get(option);
    ConnectionFactoryOptions options = ConnectionFactoryBuilder.withUrl(url).configure((builder) -> builder.option(PoolingConnectionFactoryProvider.POOL_NAME, "defaultName").option(option, expectedOption.value)).buildOptions();
    ConnectionPoolConfiguration configuration = new PoolingAwareOptionsCapableWrapper().connectionPoolConfiguration(options, mock(ConnectionFactory.class));
    assertThat(configuration).extracting(expectedOption.property).isEqualTo(expectedOption.value);
}
Also used : ConnectionFactory(io.r2dbc.spi.ConnectionFactory) PoolingAwareOptionsCapableWrapper(org.springframework.boot.r2dbc.ConnectionFactoryBuilder.PoolingAwareOptionsCapableWrapper) H2ConnectionFactoryMetadata(io.r2dbc.h2.H2ConnectionFactoryMetadata) PoolingConnectionFactoryProvider(io.r2dbc.pool.PoolingConnectionFactoryProvider) ConnectionFactoryOptions(io.r2dbc.spi.ConnectionFactoryOptions) FieldFilter(org.springframework.util.ReflectionUtils.FieldFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConnectionPoolConfiguration(io.r2dbc.pool.ConnectionPoolConfiguration) UUID(java.util.UUID) ConnectionPool(io.r2dbc.pool.ConnectionPool) Arguments(org.junit.jupiter.params.provider.Arguments) Function(java.util.function.Function) Option(io.r2dbc.spi.Option) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ReflectionUtils(org.springframework.util.ReflectionUtils) Duration(java.time.Duration) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) ResolvableType(org.springframework.core.ResolvableType) ValidationDepth(io.r2dbc.spi.ValidationDepth) MethodSource(org.junit.jupiter.params.provider.MethodSource) Mockito.mock(org.mockito.Mockito.mock) ConnectionFactory(io.r2dbc.spi.ConnectionFactory) ConnectionFactoryOptions(io.r2dbc.spi.ConnectionFactoryOptions) PoolingAwareOptionsCapableWrapper(org.springframework.boot.r2dbc.ConnectionFactoryBuilder.PoolingAwareOptionsCapableWrapper) ConnectionPoolConfiguration(io.r2dbc.pool.ConnectionPoolConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ConnectionFactoryOptions (io.r2dbc.spi.ConnectionFactoryOptions)11 Test (org.junit.jupiter.api.Test)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 ConnectionFactory (io.r2dbc.spi.ConnectionFactory)6 ConnectionPool (io.r2dbc.pool.ConnectionPool)4 ConnectionPoolConfiguration (io.r2dbc.pool.ConnectionPoolConfiguration)4 H2ConnectionFactoryMetadata (io.r2dbc.h2.H2ConnectionFactoryMetadata)3 PoolingConnectionFactoryProvider (io.r2dbc.pool.PoolingConnectionFactoryProvider)3 Option (io.r2dbc.spi.Option)3 ValidationDepth (io.r2dbc.spi.ValidationDepth)3 Duration (java.time.Duration)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 UUID (java.util.UUID)3 Function (java.util.function.Function)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)3 Arguments (org.junit.jupiter.params.provider.Arguments)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Mockito.mock (org.mockito.Mockito.mock)3