Commit b8d92cb0 authored by Stephane Nicoll's avatar Stephane Nicoll

Fix @DataJdbcTest to be transactional as advertized

Closes gh-17513
parent 5903e9a5
...@@ -37,6 +37,7 @@ import org.springframework.core.annotation.AliasFor; ...@@ -37,6 +37,7 @@ import org.springframework.core.annotation.AliasFor;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit.jupiter.SpringExtension; 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)} * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
...@@ -46,8 +47,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; ...@@ -46,8 +47,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
* Using this annotation will disable full auto-configuration and instead apply only * Using this annotation will disable full auto-configuration and instead apply only
* configuration relevant to Data JDBC tests. * configuration relevant to Data JDBC tests.
* <p> * <p>
* By default, tests annotated with {@code @DataJdbcTest} will use an embedded in-memory * By default, tests annotated with {@code @DataJdbcTest} are transactional and roll back
* database (replacing any explicit or usually auto-configured DataSource). The * 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 * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to
* override these settings. * override these settings.
* <p> * <p>
...@@ -67,6 +69,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; ...@@ -67,6 +69,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@OverrideAutoConfiguration(enabled = false) @OverrideAutoConfiguration(enabled = false)
@TypeExcludeFilters(DataJdbcTypeExcludeFilter.class) @TypeExcludeFilters(DataJdbcTypeExcludeFilter.class)
@Transactional
@AutoConfigureCache @AutoConfigureCache
@AutoConfigureDataJdbc @AutoConfigureDataJdbc
@AutoConfigureTestDatabase @AutoConfigureTestDatabase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment