From eddd368c7359042bff53a025b202bbb19d3fd256 Mon Sep 17 00:00:00 2001 From: Jeff Butler Date: Sun, 30 Nov 2025 13:57:40 -0500 Subject: [PATCH 1/2] Add JSpecify Configuration --- .../springbatch/bulkinsert/package-info.java | 19 +++++++++++++++++++ .../springbatch/common/package-info.java | 19 +++++++++++++++++++ .../springbatch/cursor/package-info.java | 19 +++++++++++++++++++ .../springbatch/paging/package-info.java | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 src/test/java/examples/springbatch/bulkinsert/package-info.java create mode 100644 src/test/java/examples/springbatch/common/package-info.java create mode 100644 src/test/java/examples/springbatch/cursor/package-info.java create mode 100644 src/test/java/examples/springbatch/paging/package-info.java diff --git a/src/test/java/examples/springbatch/bulkinsert/package-info.java b/src/test/java/examples/springbatch/bulkinsert/package-info.java new file mode 100644 index 000000000..da485b2da --- /dev/null +++ b/src/test/java/examples/springbatch/bulkinsert/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2016-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package examples.springbatch.bulkinsert; + +import org.jspecify.annotations.NullMarked; diff --git a/src/test/java/examples/springbatch/common/package-info.java b/src/test/java/examples/springbatch/common/package-info.java new file mode 100644 index 000000000..cc439710d --- /dev/null +++ b/src/test/java/examples/springbatch/common/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2016-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package examples.springbatch.common; + +import org.jspecify.annotations.NullMarked; diff --git a/src/test/java/examples/springbatch/cursor/package-info.java b/src/test/java/examples/springbatch/cursor/package-info.java new file mode 100644 index 000000000..e6a1089c4 --- /dev/null +++ b/src/test/java/examples/springbatch/cursor/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2016-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package examples.springbatch.cursor; + +import org.jspecify.annotations.NullMarked; diff --git a/src/test/java/examples/springbatch/paging/package-info.java b/src/test/java/examples/springbatch/paging/package-info.java new file mode 100644 index 000000000..4450729a1 --- /dev/null +++ b/src/test/java/examples/springbatch/paging/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2016-2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package examples.springbatch.paging; + +import org.jspecify.annotations.NullMarked; From 8be91b25e2081e1ca650cc01f826e7a19ea3f0fe Mon Sep 17 00:00:00 2001 From: Jeff Butler Date: Sun, 30 Nov 2025 16:01:48 -0500 Subject: [PATCH 2/2] Updates for SpringBatch v6 --- pom.xml | 4 +- .../bulkinsert/BulkInsertConfiguration.java | 26 ++++++------- .../bulkinsert/SpringBatchBulkInsertTest.java | 15 ++++--- .../bulkinsert/TestRecordGenerator.java | 18 ++++----- .../springbatch/common/PersonProcessor.java | 16 +++----- .../springbatch/common/PersonRecord.java | 39 +------------------ .../common/UpdateStatementConvertor.java | 8 ++-- .../CursorReaderBatchConfiguration.java | 26 ++++++------- .../cursor/SpringBatchCursorTest.java | 15 ++++--- .../springbatch/mapper/PersonMapper.java | 11 +++--- .../PagingReaderBatchConfiguration.java | 21 +++++----- .../paging/SpringBatchPagingTest.java | 15 ++++--- 12 files changed, 84 insertions(+), 130 deletions(-) diff --git a/pom.xml b/pom.xml index 5bd19e966..317cfc5dc 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ 17 17 6.0.1 - 5.2.4 + 6.0.0 checkstyle-override.xml @@ -142,7 +142,7 @@ org.mybatis mybatis-spring - 3.0.5 + 4.0.0 test diff --git a/src/test/java/examples/springbatch/bulkinsert/BulkInsertConfiguration.java b/src/test/java/examples/springbatch/bulkinsert/BulkInsertConfiguration.java index 60278b02e..81282386a 100644 --- a/src/test/java/examples/springbatch/bulkinsert/BulkInsertConfiguration.java +++ b/src/test/java/examples/springbatch/bulkinsert/BulkInsertConfiguration.java @@ -21,21 +21,26 @@ import javax.sql.DataSource; +import java.util.Objects; + +import examples.springbatch.common.PersonRecord; +import examples.springbatch.mapper.PersonDynamicSqlSupport; +import examples.springbatch.mapper.PersonMapper; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.dynamic.sql.insert.InsertDSL; import org.mybatis.dynamic.sql.render.RenderingStrategies; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.batch.MyBatisBatchItemWriter; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.Step; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -45,10 +50,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.PlatformTransactionManager; -import examples.springbatch.common.PersonRecord; -import examples.springbatch.mapper.PersonDynamicSqlSupport; -import examples.springbatch.mapper.PersonMapper; - @EnableBatchProcessing @Configuration @ComponentScan("examples.springbatch.bulkinsert") @@ -59,9 +60,6 @@ public class BulkInsertConfiguration { @Autowired private JobRepository jobRepository; - @Autowired - private PlatformTransactionManager transactionManager; - @Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() @@ -76,7 +74,7 @@ public DataSource dataSource() { public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); - return sessionFactory.getObject(); + return Objects.requireNonNull(sessionFactory.getObject()); } @Bean @@ -104,7 +102,7 @@ public MyBatisBatchItemWriter writer(SqlSessionFactory sqlSessionF @Bean public Step step1(ItemProcessor processor, ItemWriter writer) { return new StepBuilder("step1", jobRepository) - .chunk(10, transactionManager) + .chunk(10) .reader(new TestRecordGenerator()) .processor(processor) .writer(writer) diff --git a/src/test/java/examples/springbatch/bulkinsert/SpringBatchBulkInsertTest.java b/src/test/java/examples/springbatch/bulkinsert/SpringBatchBulkInsertTest.java index a5cf3e2e3..b8d080edf 100644 --- a/src/test/java/examples/springbatch/bulkinsert/SpringBatchBulkInsertTest.java +++ b/src/test/java/examples/springbatch/bulkinsert/SpringBatchBulkInsertTest.java @@ -18,6 +18,7 @@ import static examples.springbatch.mapper.PersonDynamicSqlSupport.*; import static org.assertj.core.api.Assertions.assertThat; +import examples.springbatch.mapper.PersonMapper; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.Test; @@ -25,22 +26,20 @@ import org.mybatis.dynamic.sql.select.CountDSL; import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.test.JobLauncherTestUtils; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.test.JobOperatorTestUtils; import org.springframework.batch.test.context.SpringBatchTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import examples.springbatch.mapper.PersonMapper; - @SpringBatchTest @SpringJUnitConfig(classes = BulkInsertConfiguration.class) class SpringBatchBulkInsertTest { @Autowired - private JobLauncherTestUtils jobLauncherTestUtils; + private JobOperatorTestUtils jobOperatorTestUtils; @Autowired private SqlSessionFactory sqlSessionFactory; @@ -50,7 +49,7 @@ void testThatRowsAreInserted() throws Exception { // starting condition assertThat(rowCount()).isZero(); - JobExecution execution = jobLauncherTestUtils.launchJob(); + JobExecution execution = jobOperatorTestUtils.startJob(); assertThat(execution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); assertThat(numberOfRowsProcessed(execution)).isEqualTo(TestRecordGenerator.recordCount()); diff --git a/src/test/java/examples/springbatch/bulkinsert/TestRecordGenerator.java b/src/test/java/examples/springbatch/bulkinsert/TestRecordGenerator.java index 023e7ee4d..f9dd19447 100644 --- a/src/test/java/examples/springbatch/bulkinsert/TestRecordGenerator.java +++ b/src/test/java/examples/springbatch/bulkinsert/TestRecordGenerator.java @@ -15,25 +15,25 @@ */ package examples.springbatch.bulkinsert; -import org.springframework.batch.item.ItemReader; - import examples.springbatch.common.PersonRecord; +import org.jspecify.annotations.Nullable; +import org.springframework.batch.infrastructure.item.ItemReader; public class TestRecordGenerator implements ItemReader { private int index = 0; private static final PersonRecord[] testRecords = { - new PersonRecord("Fred", "Flintstone"), - new PersonRecord("Wilma", "Flintstone"), - new PersonRecord("Pebbles", "Flintstone"), - new PersonRecord("Barney", "Rubble"), - new PersonRecord("Betty", "Rubble"), - new PersonRecord("Bamm Bamm", "Rubble") + new PersonRecord(null, "Fred", "Flintstone"), + new PersonRecord(null, "Wilma", "Flintstone"), + new PersonRecord(null, "Pebbles", "Flintstone"), + new PersonRecord(null, "Barney", "Rubble"), + new PersonRecord(null, "Betty", "Rubble"), + new PersonRecord(null, "Bamm Bamm", "Rubble") }; @Override - public PersonRecord read() { + public @Nullable PersonRecord read() { if (index < testRecords.length) { return (testRecords[index++]); } else { diff --git a/src/test/java/examples/springbatch/common/PersonProcessor.java b/src/test/java/examples/springbatch/common/PersonProcessor.java index 2a4939cdb..3dbd0b796 100644 --- a/src/test/java/examples/springbatch/common/PersonProcessor.java +++ b/src/test/java/examples/springbatch/common/PersonProcessor.java @@ -15,12 +15,12 @@ */ package examples.springbatch.common; -import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.annotation.BeforeChunk; import org.springframework.batch.core.annotation.BeforeStep; -import org.springframework.batch.core.scope.context.ChunkContext; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.stereotype.Component; @Component @@ -32,11 +32,7 @@ public class PersonProcessor implements ItemProcessor chunk) { incrementChunkCount(); } diff --git a/src/test/java/examples/springbatch/common/PersonRecord.java b/src/test/java/examples/springbatch/common/PersonRecord.java index edf974f53..24a83de5b 100644 --- a/src/test/java/examples/springbatch/common/PersonRecord.java +++ b/src/test/java/examples/springbatch/common/PersonRecord.java @@ -15,41 +15,6 @@ */ package examples.springbatch.common; -public class PersonRecord { - private Integer id; - private String firstName; - private String lastName; +import org.jspecify.annotations.Nullable; - public PersonRecord() { - super(); - } - - public PersonRecord(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} +public record PersonRecord(@Nullable Integer id, String firstName, String lastName) {} diff --git a/src/test/java/examples/springbatch/common/UpdateStatementConvertor.java b/src/test/java/examples/springbatch/common/UpdateStatementConvertor.java index 089486b71..3dc8691ea 100644 --- a/src/test/java/examples/springbatch/common/UpdateStatementConvertor.java +++ b/src/test/java/examples/springbatch/common/UpdateStatementConvertor.java @@ -18,6 +18,8 @@ import static examples.springbatch.mapper.PersonDynamicSqlSupport.*; import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; +import java.util.Objects; + import org.mybatis.dynamic.sql.render.RenderingStrategies; import org.mybatis.dynamic.sql.update.UpdateDSL; import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; @@ -30,9 +32,9 @@ public class UpdateStatementConvertor implements Converter writer(SqlSessionFactory sqlSessionF @Bean public Step step1(ItemReader reader, ItemProcessor processor, ItemWriter writer) { return new StepBuilder("step1", jobRepository) - .chunk(10, transactionManager) + .chunk(10) .reader(reader) .processor(processor) .writer(writer) diff --git a/src/test/java/examples/springbatch/cursor/SpringBatchCursorTest.java b/src/test/java/examples/springbatch/cursor/SpringBatchCursorTest.java index 747df2db0..7499aaf8a 100644 --- a/src/test/java/examples/springbatch/cursor/SpringBatchCursorTest.java +++ b/src/test/java/examples/springbatch/cursor/SpringBatchCursorTest.java @@ -20,6 +20,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.count; import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; +import examples.springbatch.mapper.PersonMapper; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.Test; @@ -27,22 +28,20 @@ import org.mybatis.dynamic.sql.select.SelectDSL; import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.test.JobLauncherTestUtils; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.test.JobOperatorTestUtils; import org.springframework.batch.test.context.SpringBatchTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import examples.springbatch.mapper.PersonMapper; - @SpringBatchTest @SpringJUnitConfig(classes = CursorReaderBatchConfiguration.class) class SpringBatchCursorTest { @Autowired - private JobLauncherTestUtils jobLauncherTestUtils; + private JobOperatorTestUtils jobOperatorTestUtils; @Autowired private SqlSessionFactory sqlSessionFactory; @@ -52,7 +51,7 @@ void testThatRowsAreTransformedToUpperCase() throws Exception { // starting condition assertThat(upperCaseRowCount()).isZero(); - JobExecution execution = jobLauncherTestUtils.launchJob(); + JobExecution execution = jobOperatorTestUtils.startJob(); assertThat(execution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); assertThat(numberOfRowsProcessed(execution)).isEqualTo(2); diff --git a/src/test/java/examples/springbatch/mapper/PersonMapper.java b/src/test/java/examples/springbatch/mapper/PersonMapper.java index a1db34626..94831f8fb 100644 --- a/src/test/java/examples/springbatch/mapper/PersonMapper.java +++ b/src/test/java/examples/springbatch/mapper/PersonMapper.java @@ -18,22 +18,21 @@ import java.util.List; import java.util.Map; +import examples.springbatch.common.PersonRecord; +import org.apache.ibatis.annotations.Arg; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.SelectProvider; import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper; import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper; import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper; import org.mybatis.dynamic.sql.util.springbatch.SpringBatchProviderAdapter; -import examples.springbatch.common.PersonRecord; - @Mapper public interface PersonMapper extends CommonCountMapper, CommonInsertMapper, CommonUpdateMapper { @SelectProvider(type=SpringBatchProviderAdapter.class, method="select") - @Result(column="id", property="id", id=true) - @Result(column="first_name", property="firstName") - @Result(column="last_name", property="lastName") + @Arg(column = "id", javaType = Integer.class, id = true) + @Arg(column = "first_name", javaType = String.class) + @Arg(column = "last_name", javaType = String.class) List selectMany(Map parameterValues); } diff --git a/src/test/java/examples/springbatch/paging/PagingReaderBatchConfiguration.java b/src/test/java/examples/springbatch/paging/PagingReaderBatchConfiguration.java index 1da98bb9f..d87a86089 100644 --- a/src/test/java/examples/springbatch/paging/PagingReaderBatchConfiguration.java +++ b/src/test/java/examples/springbatch/paging/PagingReaderBatchConfiguration.java @@ -29,16 +29,16 @@ import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.batch.MyBatisBatchItemWriter; import org.mybatis.spring.batch.MyBatisPagingItemReader; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.job.Job; import org.springframework.batch.core.job.builder.JobBuilder; -import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.job.parameters.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.Step; import org.springframework.batch.core.step.builder.StepBuilder; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.infrastructure.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemReader; +import org.springframework.batch.infrastructure.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -49,6 +49,8 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.transaction.PlatformTransactionManager; +import java.util.Objects; + import examples.springbatch.common.PersonRecord; import examples.springbatch.mapper.PersonMapper; @@ -61,9 +63,6 @@ public class PagingReaderBatchConfiguration { @Autowired private JobRepository jobRepository; - @Autowired - private PlatformTransactionManager transactionManager; - @Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() @@ -79,7 +78,7 @@ public DataSource dataSource() { public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); - return sessionFactory.getObject(); + return Objects.requireNonNull(sessionFactory.getObject()); } @Bean @@ -119,7 +118,7 @@ public MyBatisBatchItemWriter writer(SqlSessionFactory sqlSessionF @Bean public Step step1(ItemReader reader, ItemProcessor processor, ItemWriter writer) { return new StepBuilder("step1", jobRepository) - .chunk(7, transactionManager) + .chunk(7) .reader(reader) .processor(processor) .writer(writer) diff --git a/src/test/java/examples/springbatch/paging/SpringBatchPagingTest.java b/src/test/java/examples/springbatch/paging/SpringBatchPagingTest.java index c153c8078..a07ea4de2 100644 --- a/src/test/java/examples/springbatch/paging/SpringBatchPagingTest.java +++ b/src/test/java/examples/springbatch/paging/SpringBatchPagingTest.java @@ -20,6 +20,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.count; import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; +import examples.springbatch.mapper.PersonMapper; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.Test; @@ -27,22 +28,20 @@ import org.mybatis.dynamic.sql.select.SelectDSL; import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.test.JobLauncherTestUtils; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.ExecutionContext; +import org.springframework.batch.test.JobOperatorTestUtils; import org.springframework.batch.test.context.SpringBatchTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import examples.springbatch.mapper.PersonMapper; - @SpringBatchTest @SpringJUnitConfig(classes = PagingReaderBatchConfiguration.class) class SpringBatchPagingTest { @Autowired - private JobLauncherTestUtils jobLauncherTestUtils; + private JobOperatorTestUtils jobOperatorTestUtils; @Autowired private SqlSessionFactory sqlSessionFactory; @@ -52,7 +51,7 @@ void testThatRowsAreTransformedToUpperCase() throws Exception { // starting condition assertThat(upperCaseRowCount()).isZero(); - JobExecution execution = jobLauncherTestUtils.launchJob(); + JobExecution execution = jobOperatorTestUtils.startJob(); assertThat(execution.getExitStatus()).isEqualTo(ExitStatus.COMPLETED); assertThat(numberOfChunks(execution)).isEqualTo(14); assertThat(numberOfRowsProcessed(execution)).isEqualTo(93);