|
19 | 19 | import java.time.Duration;
|
20 | 20 |
|
21 | 21 | import org.junit.jupiter.api.Test;
|
| 22 | +import org.neo4j.driver.Driver; |
22 | 23 | import org.testcontainers.containers.Neo4jContainer;
|
23 | 24 | import org.testcontainers.junit.jupiter.Container;
|
24 | 25 | import org.testcontainers.junit.jupiter.Testcontainers;
|
|
27 | 28 |
|
28 | 29 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
29 | 30 | import org.springframework.beans.factory.annotation.Autowired;
|
| 31 | +import org.springframework.boot.test.context.TestConfiguration; |
30 | 32 | import org.springframework.context.ApplicationContext;
|
| 33 | +import org.springframework.context.annotation.Bean; |
| 34 | +import org.springframework.data.neo4j.core.DatabaseSelectionProvider; |
31 | 35 | import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate;
|
| 36 | +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; |
| 37 | +import org.springframework.data.neo4j.repository.config.ReactiveNeo4jRepositoryConfigurationExtension; |
32 | 38 | import org.springframework.test.context.DynamicPropertyRegistry;
|
33 | 39 | import org.springframework.test.context.DynamicPropertySource;
|
34 | 40 |
|
|
38 | 44 | * Integration tests for the reactive SDN/RX Neo4j test slice.
|
39 | 45 | *
|
40 | 46 | * @author Michael J. Simons
|
| 47 | + * @author Scott Frederick |
41 | 48 | * @since 2.4.0
|
42 | 49 | */
|
43 | 50 | @DataNeo4jTest
|
@@ -75,4 +82,20 @@ void didNotInjectExampleService() {
|
75 | 82 | .isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
|
76 | 83 | }
|
77 | 84 |
|
| 85 | + // Providing this bean fulfills a requirement that a @Transactional test has a |
| 86 | + // PlatformTransactionManager in the app context (enforced by |
| 87 | + // org.springframework.test.context.transaction.TransactionalTestExecutionListener). |
| 88 | + // Providing a ReactiveNeo4jTransactionManager would be more appropriate, but won't |
| 89 | + // allow the test to succeed. |
| 90 | + @TestConfiguration(proxyBeanMethods = false) |
| 91 | + static class ReactiveTransactionManagerConfiguration { |
| 92 | + |
| 93 | + @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME) |
| 94 | + Neo4jTransactionManager reactiveTransactionManager(Driver driver, |
| 95 | + DatabaseSelectionProvider databaseNameProvider) { |
| 96 | + return new Neo4jTransactionManager(driver, databaseNameProvider); |
| 97 | + } |
| 98 | + |
| 99 | + } |
| 100 | + |
78 | 101 | }
|
0 commit comments