Search in sources :

Example 1 with PoolMetrics

use of io.r2dbc.pool.PoolMetrics 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)1 PoolMetrics (io.r2dbc.pool.PoolMetrics)1 Test (org.junit.jupiter.api.Test)1