Search in sources :

Example 6 with ConnectionPool

use of io.r2dbc.pool.ConnectionPool in project spring-boot by spring-projects.

the class R2dbcAutoConfigurationTests method configureWithUrlAndPoolPropertiesApplyProperties.

@Test
void configureWithUrlAndPoolPropertiesApplyProperties() {
    this.contextRunner.withPropertyValues("spring.r2dbc.url:r2dbc:h2:mem:///" + randomDatabaseName(), "spring.r2dbc.pool.max-size=15", "spring.r2dbc.pool.max-acquire-time=3m").run((context) -> {
        assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class).hasSingleBean(R2dbcProperties.class);
        ConnectionPool connectionPool = context.getBean(ConnectionPool.class);
        PoolMetrics poolMetrics = connectionPool.getMetrics().get();
        assertThat(poolMetrics.getMaxAllocatedSize()).isEqualTo(15);
        assertThat(connectionPool).hasFieldOrPropertyWithValue("maxAcquireTime", Duration.ofMinutes(3));
    });
}
Also used : ConnectionPool(io.r2dbc.pool.ConnectionPool) PoolMetrics(io.r2dbc.pool.PoolMetrics) Test(org.junit.jupiter.api.Test)

Aggregations

ConnectionPool (io.r2dbc.pool.ConnectionPool)6 Test (org.junit.jupiter.api.Test)6 ConnectionFactory (io.r2dbc.spi.ConnectionFactory)3 H2ConnectionFactory (io.r2dbc.h2.H2ConnectionFactory)2 SimpleTestConnectionFactory (org.springframework.boot.autoconfigure.r2dbc.SimpleConnectionFactoryProvider.SimpleTestConnectionFactory)2 OptionsCapableConnectionFactory (org.springframework.boot.r2dbc.OptionsCapableConnectionFactory)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 ConnectionPoolConfiguration (io.r2dbc.pool.ConnectionPoolConfiguration)1 PoolMetrics (io.r2dbc.pool.PoolMetrics)1 ConnectionFactoryOptions (io.r2dbc.spi.ConnectionFactoryOptions)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 StepVerifier (reactor.test.StepVerifier)1