Search in sources :

Example 11 with Connection

use of io.r2dbc.spi.Connection in project spring-framework by spring-projects.

the class SingleConnectionFactoryUnitTests method shouldSuppressClose.

@Test
@SuppressWarnings("rawtypes")
void shouldSuppressClose() {
    SingleConnectionFactory factory = new SingleConnectionFactory("r2dbc:h2:mem:///foo", true);
    Connection connection = factory.create().block();
    StepVerifier.create(connection.close()).verifyComplete();
    assertThat(connection).isInstanceOf(Wrapped.class);
    assertThat(((Wrapped) connection).unwrap()).isInstanceOf(H2Connection.class);
    StepVerifier.create(connection.setTransactionIsolationLevel(IsolationLevel.READ_COMMITTED)).verifyComplete();
    factory.destroy();
}
Also used : Wrapped(io.r2dbc.spi.Wrapped) Connection(io.r2dbc.spi.Connection) H2Connection(io.r2dbc.h2.H2Connection) Test(org.junit.jupiter.api.Test)

Aggregations

Connection (io.r2dbc.spi.Connection)11 Test (org.junit.jupiter.api.Test)10 Mono (reactor.core.publisher.Mono)6 StepVerifier (reactor.test.StepVerifier)6 H2Connection (io.r2dbc.h2.H2Connection)5 ConnectionFactory (io.r2dbc.spi.ConnectionFactory)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 BDDMockito.mock (org.mockito.BDDMockito.mock)4 BDDMockito.verify (org.mockito.BDDMockito.verify)4 BDDMockito.when (org.mockito.BDDMockito.when)4 IsolationLevel (io.r2dbc.spi.IsolationLevel)3 R2dbcBadGrammarException (io.r2dbc.spi.R2dbcBadGrammarException)3 Statement (io.r2dbc.spi.Statement)3 Assertions.fail (org.assertj.core.api.Assertions.fail)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 ArgumentMatchers.anyBoolean (org.mockito.ArgumentMatchers.anyBoolean)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 BDDMockito.never (org.mockito.BDDMockito.never)3