Fix DataNeo4jTestReactiveIntegrationTests

See gh-22940
pull/22948/head
Scott Frederick 4 years ago
parent b80811b898
commit 2a998a4373

@ -19,6 +19,7 @@ package org.springframework.boot.test.autoconfigure.data.neo4j;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
import org.testcontainers.containers.Neo4jContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@ -27,8 +28,13 @@ import reactor.test.StepVerifier;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate;
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager;
import org.springframework.data.neo4j.repository.config.ReactiveNeo4jRepositoryConfigurationExtension;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
@ -38,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* Integration tests for the reactive SDN/RX Neo4j test slice.
*
* @author Michael J. Simons
* @author Scott Frederick
* @since 2.4.0
*/
@DataNeo4jTest
@ -75,4 +82,20 @@ class DataNeo4jTestReactiveIntegrationTests {
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
// Providing this bean fulfills a requirement that a @Transactional test has a
// PlatformTransactionManager in the app context (enforced by
// org.springframework.test.context.transaction.TransactionalTestExecutionListener).
// Providing a ReactiveNeo4jTransactionManager would be more appropriate, but won't
// allow the test to succeed.
@TestConfiguration(proxyBeanMethods = false)
static class ReactiveTransactionManagerConfiguration {
@Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
Neo4jTransactionManager reactiveTransactionManager(Driver driver,
DatabaseSelectionProvider databaseNameProvider) {
return new Neo4jTransactionManager(driver, databaseNameProvider);
}
}
}

Loading…
Cancel
Save