Update documentation with expected configuration to use @SpringBatchTest

Resolves #3699
This commit is contained in:
Mahmoud Ben Hassine
2020-10-02 23:49:21 +02:00
parent a785c0792a
commit 15d24b370f
2 changed files with 23 additions and 0 deletions

View File

@@ -34,6 +34,16 @@ Starting from v4.1, it is also possible to inject Spring Batch test utilities
like the `JobLauncherTestUtils` and `JobRepositoryTestUtils` in the test context
using the `@SpringBatchTest` annotation.
[NOTE]
====
It should be noted that `JobLauncherTestUtils` requires a `Job` bean and that
`JobRepositoryTestUtils` requires a `DataSource` bean. Since `@SpringBatchTest`
registers a `JobLauncherTestUtils` and a `JobRepositoryTestUtils` in the test
context, it is expected that the test context contains a single autowire candidate
for a `Job` and a `DataSource` (either a single bean definition or one that is
annotated with `org.springframework.context.annotation.Primary`).
====
[role="javaContent"]
The following Java example shows the annotations in use:

View File

@@ -116,6 +116,19 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
*
* }
* </pre>
*
* <p><strong>
* It should be noted that {@link JobLauncherTestUtils} requires a
* {@link org.springframework.batch.core.Job} bean and that
* {@link JobRepositoryTestUtils} requires a {@link javax.sql.DataSource} bean.
* Since this annotation registers a {@link JobLauncherTestUtils} and a
* {@link JobRepositoryTestUtils} in the test context, it is expected that the
* test context contains a single autowire candidate for a
* {@link org.springframework.batch.core.Job} and a {@link javax.sql.DataSource}
* (either a single bean definition or one that is
* annotated with {@link org.springframework.context.annotation.Primary}).
* </strong></p>
*
* @author Mahmoud Ben Hassine
* @since 4.1
* @see JobLauncherTestUtils