use of io.r2dbc.spi.ConnectionFactoryMetadata in project spring-framework by spring-projects.
the class SingleConnectionFactoryUnitTests method releaseConnectionShouldNotCloseConnection.
@Test
void releaseConnectionShouldNotCloseConnection() {
Connection connectionMock = mock(Connection.class);
ConnectionFactoryMetadata metadata = mock(ConnectionFactoryMetadata.class);
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, true);
Connection connection = factory.create().block();
ConnectionFactoryUtils.releaseConnection(connection, factory).as(StepVerifier::create).verifyComplete();
verify(connectionMock, never()).close();
}
use of io.r2dbc.spi.ConnectionFactoryMetadata in project spring-framework by spring-projects.
the class SingleConnectionFactoryUnitTests method releaseConnectionShouldCloseUnrelatedConnection.
@Test
void releaseConnectionShouldCloseUnrelatedConnection() {
Connection connectionMock = mock(Connection.class);
Connection otherConnection = mock(Connection.class);
ConnectionFactoryMetadata metadata = mock(ConnectionFactoryMetadata.class);
when(otherConnection.close()).thenReturn(Mono.empty());
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, false);
factory.create().as(StepVerifier::create).expectNextCount(1).verifyComplete();
ConnectionFactoryUtils.releaseConnection(otherConnection, factory).as(StepVerifier::create).verifyComplete();
verify(otherConnection).close();
}
Aggregations