Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a5b27789
Commit
a5b27789
authored
Oct 14, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document how to use DataNeo4jTest with reactive access
Closes gh-23630
parent
27af908b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
spring-boot-features.adoc
...ing-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
+3
-0
DataNeo4jTest.java
...ork/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
+3
-1
DataNeo4jTestReactiveIntegrationTests.java
...ure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java
+10
-13
No files found.
spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
View file @
a5b27789
...
...
@@ -7605,6 +7605,9 @@ If that is not what you want, you can disable transaction management for a test
}
----
NOTE: Transactional tests are not supported with reactive access.
If you are using this style, you must configure `@DataNeo4jTest` tests as described above.
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-redis-test]]
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
View file @
a5b27789
...
...
@@ -45,7 +45,9 @@ import org.springframework.transaction.annotation.Transactional;
* configuration relevant to Neo4j tests.
* <p>
* By default, tests annotated with {@code @DataNeo4jTest} are transactional with the
* usual test-related semantics (i.e. rollback by default).
* usual test-related semantics (i.e. rollback by default). This feature is not supported
* with reactive access so this should be disabled by annotating the test class with
* {@code @Transactional(propagation = Propagation.NOT_SUPPORTED)}.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java
View file @
a5b27789
...
...
@@ -31,23 +31,25 @@ 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.
Reactive
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.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager
;
import
org.springframework.test.context.DynamicPropertyRegistry
;
import
org.springframework.test.context.DynamicPropertySource
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
/**
* Integration tests for
the reactive SDN/RX Neo4j test slic
e.
* Integration tests for
{@link DataNeo4jTest @DataNeo4jTest} with reactive styl
e.
*
* @author Michael J. Simons
* @author Scott Frederick
* @since 2.4.0
*/
@DataNeo4jTest
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Testcontainers
(
disabledWithoutDocker
=
true
)
class
DataNeo4jTestReactiveIntegrationTests
{
...
...
@@ -82,18 +84,13 @@ 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
);
@Bean
Reactive
Neo4jTransactionManager
reactiveTransactionManager
(
Driver
driver
,
Reactive
DatabaseSelectionProvider
databaseNameProvider
)
{
return
new
Reactive
Neo4jTransactionManager
(
driver
,
databaseNameProvider
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment