use of reactor.test.StepVerifier 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();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class TransactionalOperatorTests method monoSubscriptionNotCancelled.
@Test
public void monoSubscriptionNotCancelled() {
AtomicBoolean cancelled = new AtomicBoolean();
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
Mono.just(true).doOnCancel(() -> cancelled.set(true)).as(operator::transactional).as(StepVerifier::create).expectNext(true).verifyComplete();
assertThat(tm.commit).isTrue();
assertThat(tm.rollback).isFalse();
assertThat(cancelled).isFalse();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class TransactionalOperatorTests method commitWithMono.
@Test
public void commitWithMono() {
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
Mono.just(true).as(operator::transactional).as(StepVerifier::create).expectNext(true).verifyComplete();
assertThat(tm.commit).isTrue();
assertThat(tm.rollback).isFalse();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class TransactionalOperatorTests method cancellationPropagatedToFlux.
@Test
public void cancellationPropagatedToFlux() {
AtomicBoolean cancelled = new AtomicBoolean();
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
Flux.create(sink -> sink.onCancel(() -> cancelled.set(true))).as(operator::transactional).as(StepVerifier::create).thenAwait().thenCancel().verify();
assertThat(tm.commit).isFalse();
assertThat(tm.rollback).isTrue();
assertThat(cancelled).isTrue();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class TransactionalOperatorTests method cancellationPropagatedToMono.
@Test
public void cancellationPropagatedToMono() {
AtomicBoolean cancelled = new AtomicBoolean();
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
Mono.create(sink -> sink.onCancel(() -> cancelled.set(true))).as(operator::transactional).as(StepVerifier::create).thenAwait().thenCancel().verify();
assertThat(tm.commit).isFalse();
assertThat(tm.rollback).isTrue();
assertThat(cancelled).isTrue();
}
Aggregations