From b8d92cb0ae61a1d8ac0c943ce434bcbe1da1f8f9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 19 Jul 2019 10:29:27 +0200 Subject: [PATCH] Fix @DataJdbcTest to be transactional as advertized Closes gh-17513 --- .../boot/test/autoconfigure/data/jdbc/DataJdbcTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java index 9c553647a0..b50c2ca0e3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java @@ -37,6 +37,7 @@ import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; /** * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} @@ -46,8 +47,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation will disable full auto-configuration and instead apply only * configuration relevant to Data JDBC tests. *

- * By default, tests annotated with {@code @DataJdbcTest} will use an embedded in-memory - * database (replacing any explicit or usually auto-configured DataSource). The + * By default, tests annotated with {@code @DataJdbcTest} are transactional and roll back + * at the end of each test. They also use an embedded in-memory database (replacing any + * explicit or usually auto-configured DataSource). The * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to * override these settings. *

@@ -67,6 +69,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataJdbcTypeExcludeFilter.class) +@Transactional @AutoConfigureCache @AutoConfigureDataJdbc @AutoConfigureTestDatabase