Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreI am pleased to announce that Spring Batch 5.0.0-M5
is now available from our milestone repository. The main theme of this milestone is improving testing support in Spring Batch. This post walks through the major changes in this area as well as other changes introduced in this milestone release. For the complete list of changes, see the release notes.
Up to version 4.3, the JobLauncherTestUtils
used to autowire the job under test with the goal of facilitating the test setup. But what if multiple jobs are defined in the test context? And what if no Job
beans are defined at all? So while this autowiring was convenient for most cases, it turned out to cause several issues in the aforementioned situations. In this release, and based on community feedback, we have decided to remove the autowiring of any job in JobLauncherTestUtils
.
Similarly, the JobRepositoryTestUtils
used to autowire a DataSource
from the application context. Again, what if no data source or multiple data sources are defined in the test context? In this version, the JobRepositoryTestUtils
was updated to work against the JobRepository
interface, without having to deal with any implementation details of the repository (such as a data source, for example).
If you define those utility beans manually in your test context or import them through @SpringBatchTest
, you would manually set the job under test or the test data source when multiple beans of those types are defined in your test context.
In this milestone release, the entire test suite of Spring Batch was migrated to JUnit 5. While this does not impact end users directly, it helps the Batch team as well as community contributors to use the next generation of JUnit to write better tests.
In this milestone release, the documentation was updated to use the Spring Asciidoctor Backend. This backend ensures that all projects from the portfolio follow the same documentation style. For consistency with other projects, the reference documentation of Spring Batch was updated to use this backend in this release. You can check the new version of the reference documentation here.
This release includes a number of deprecations and API changes.
This milestone release introduces the following deprecations:
org.springframework.batch.test.AssertFile
utility class was deprecated in favor of similar utilities provided by modern test libraries.In this release, we introduced a breaking change in the ItemWriter
interface:
public interface ItemWriter<T> {
-- void write(List<? extends T> items) throws Exception;
++ void write(Chunk<? extends T> items) throws Exception;
}
While this change seems small, we believe it has a huge added value in terms of better encapsulation and consistency in using a coherent language across different areas and APIs of the framework. The ItemWriteListener
API was changed to use the Chunk
API as well.
As the Chunk
API implements java.lang.Iterable
, this change does not impact any client code that iterates over the list of items. Moreover, this change does not impact any example that uses a lambda expression to define an ItemWriter
, as the type of the items is inferred. See the migration guide for all details about the changed APIs.
Major dependencies have been upgraded to the following versions:
We would like to thank all contributors who had a role in this release! As we continue our work on Spring Batch 5, we look forward to your feedback on Github, Twitter and StackOverflow.