Polish "Add @JooqTest"

Closes gh-9343
This commit is contained in:
Stephane Nicoll
2017-05-31 15:07:26 +02:00
parent 00a643f9d8
commit d096dcad1d
6 changed files with 95 additions and 33 deletions

View File

@@ -5834,9 +5834,13 @@ A list of the auto-configuration that is enabled by `@JdbcTest` can be
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-jooq-test]]
==== Auto-configured jOOQ tests
`@JooqTest` is similar to `@JdbcTest` but for jOOQ related tests. By default it
will configure an in-memory embedded database and a `DSLContext`. Regular
`@Component` beans will not be loaded into the `ApplicationContext`:
`@JooqTest` can be used in a similar fashion as `@JdbcTest` but for jOOQ related tests. As
jOOQ relies heavily on a Java-based schema that corresponds with the database schema, the
existing `DataSource` will be used. If you want to replace it by an in-memory database you
can use `@AutoconfigureTestDatabase` to override those settings.
`@JooqTest` will configure a `DSLContext`. Regular `@Component` beans will not be loaded
into the `ApplicationContext`:
[source,java,indent=0]
----
@@ -5848,19 +5852,17 @@ will configure an in-memory embedded database and a `DSLContext`. Regular
@RunWith(SpringRunner.class)
@JooqTest
public class ExampleNonTransactionalTests {
public class ExampleJooqTests {
@Autowired
DSLContext create;
private DSLContext dslContext;
}
----
JOOQ tests are also transactional and rollback at the end of each test by default.
If that's not what you want, you can disable transaction management for a test or for
the whole as shown with
<<boot-features-testing-spring-boot-applications-testing-autoconfigured-jdbc-test,`@JdbcTest`>>
If you prefer your test to run against a real database, you can use the
`@AutoConfigureTestDatabase` annotation the same way as for `JdbcTest` or `DataJpaTest`.
JOOQ tests are transactional and rollback at the end of each test by default. If that's
not what you want, you can disable transaction management for a test or for the whole test
class as <<boot-features-testing-spring-boot-applications-testing-autoconfigured-jdbc-test,shown
in the example above>>.
A list of the auto-configuration that is enabled by `@JooqTest` can be
<<appendix-test-auto-configuration#test-auto-configuration,found in the appendix>>.