Skip to content

Commit 2a998a4

Browse files
Fix DataNeo4jTestReactiveIntegrationTests
See gh-22940
1 parent b80811b commit 2a998a4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.time.Duration;
2020

2121
import org.junit.jupiter.api.Test;
22+
import org.neo4j.driver.Driver;
2223
import org.testcontainers.containers.Neo4jContainer;
2324
import org.testcontainers.junit.jupiter.Container;
2425
import org.testcontainers.junit.jupiter.Testcontainers;
@@ -27,8 +28,13 @@
2728

2829
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2930
import org.springframework.beans.factory.annotation.Autowired;
31+
import org.springframework.boot.test.context.TestConfiguration;
3032
import org.springframework.context.ApplicationContext;
33+
import org.springframework.context.annotation.Bean;
34+
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
3135
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;
3238
import org.springframework.test.context.DynamicPropertyRegistry;
3339
import org.springframework.test.context.DynamicPropertySource;
3440

@@ -38,6 +44,7 @@
3844
* Integration tests for the reactive SDN/RX Neo4j test slice.
3945
*
4046
* @author Michael J. Simons
47+
* @author Scott Frederick
4148
* @since 2.4.0
4249
*/
4350
@DataNeo4jTest
@@ -75,4 +82,20 @@ void didNotInjectExampleService() {
7582
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
7683
}
7784

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+
78101
}

0 commit comments

Comments
 (0)