Skip to content

Commit 020c24a

Browse files
committed
Rename JobLauncherTestUtils to JobOperatorTestUtils
Resolves #4920
1 parent 9b7323f commit 020c24a

File tree

54 files changed

+528
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+528
-289
lines changed

spring-batch-samples/src/main/resources/org/springframework/batch/samples/jpa/job/jpa.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@
5555
<property name="transactionManager" ref="transactionManager" />
5656
</bean>
5757

58-
<bean id="jobLauncher"
59-
class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
58+
<bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
59+
60+
<bean id="jobOperator"
61+
class="org.springframework.batch.core.launch.support.TaskExecutorJobOperator">
6062
<property name="jobRepository" ref="jobRepository" />
63+
<property name="jobRegistry" ref="jobRegistry" />
6164
</bean>
6265

6366
<jdbc:embedded-database id="dataSource" generate-name="true">

spring-batch-samples/src/main/resources/org/springframework/batch/samples/jpa/job/repository.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@
7575
<property name="transactionManager" ref="transactionManager" />
7676
</bean>
7777

78-
<bean id="jobLauncher"
79-
class="org.springframework.batch.core.launch.support.TaskExecutorJobLauncher">
78+
<bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
79+
80+
<bean id="jobOperator"
81+
class="org.springframework.batch.core.launch.support.TaskExecutorJobOperator">
8082
<property name="jobRepository" ref="jobRepository" />
83+
<property name="jobRegistry" ref="jobRegistry" />
8184
</bean>
8285

8386
<jdbc:embedded-database id="dataSource" generate-name="true">

spring-batch-samples/src/main/resources/org/springframework/batch/samples/restart/stop/stopRestartSample.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<bean id="jobRegistry"
2121
class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
2222

23-
<bean class="org.springframework.batch.test.JobLauncherTestUtils"/>
23+
<bean class="org.springframework.batch.test.JobOperatorTestUtils"/>
2424
<bean class="org.springframework.batch.test.context.BatchTestContextBeanPostProcessor"/>
2525

2626
<!-- The tasklet used in this job will run in an infinite loop. This is useful for testing graceful shutdown from

spring-batch-samples/src/main/resources/simple-job-launcher-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<bean id="jobRegistry"
1818
class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
1919

20-
<bean class="org.springframework.batch.test.JobLauncherTestUtils"/>
20+
<bean class="org.springframework.batch.test.JobOperatorTestUtils"/>
2121
<bean class="org.springframework.batch.test.context.BatchTestContextBeanPostProcessor"/>
2222

2323
</beans>

spring-batch-samples/src/test/java/org/springframework/batch/samples/adapter/readerwriter/DelegatingJobFunctionalTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2007-2023 the original author or authors.
2+
* Copyright 2007-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818
import org.junit.jupiter.api.Test;
1919

2020
import org.springframework.batch.samples.domain.person.PersonService;
21-
import org.springframework.batch.test.JobLauncherTestUtils;
21+
import org.springframework.batch.test.JobOperatorTestUtils;
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2424

@@ -30,14 +30,14 @@
3030
class DelegatingJobFunctionalTests {
3131

3232
@Autowired
33-
private JobLauncherTestUtils jobLauncherTestUtils;
33+
private JobOperatorTestUtils jobOperatorTestUtils;
3434

3535
@Autowired
3636
private PersonService personService;
3737

3838
@Test
3939
void testLaunchJob() throws Exception {
40-
jobLauncherTestUtils.launchJob();
40+
jobOperatorTestUtils.startJob();
4141

4242
assertTrue(personService.getReturnedCount() > 0);
4343
assertEquals(personService.getReturnedCount(), personService.getReceivedCount());

spring-batch-samples/src/test/java/org/springframework/batch/samples/adapter/tasklet/TaskletAdapterJobFunctionalTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121
import org.springframework.batch.core.BatchStatus;
2222
import org.springframework.batch.core.job.JobExecution;
2323
import org.springframework.batch.core.job.parameters.JobParametersBuilder;
24-
import org.springframework.batch.test.JobLauncherTestUtils;
24+
import org.springframework.batch.test.JobOperatorTestUtils;
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2727

@@ -32,12 +32,12 @@
3232
class TaskletAdapterJobFunctionalTests {
3333

3434
@Autowired
35-
private JobLauncherTestUtils jobLauncherTestUtils;
35+
private JobOperatorTestUtils jobOperatorTestUtils;
3636

3737
@Test
3838
void testLaunchJob() throws Exception {
39-
JobExecution jobExecution = jobLauncherTestUtils
40-
.launchJob(new JobParametersBuilder().addString("value", "foo").toJobParameters());
39+
JobExecution jobExecution = jobOperatorTestUtils
40+
.startJob(new JobParametersBuilder().addString("value", "foo").toJobParameters());
4141
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
4242
assertEquals("yes", jobExecution.getExecutionContext().getString("done"));
4343
}

spring-batch-samples/src/test/java/org/springframework/batch/samples/amqp/AmqpJobFunctionalTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,10 +33,10 @@
3333
import org.springframework.batch.core.job.Job;
3434
import org.springframework.batch.core.job.parameters.JobParameters;
3535
import org.springframework.batch.core.repository.explore.JobExplorer;
36-
import org.springframework.batch.core.launch.JobLauncher;
36+
import org.springframework.batch.core.launch.JobOperator;
3737
import org.springframework.batch.item.ItemReader;
3838
import org.springframework.batch.item.ItemWriter;
39-
import org.springframework.batch.test.JobLauncherTestUtils;
39+
import org.springframework.batch.test.JobOperatorTestUtils;
4040
import org.springframework.beans.factory.annotation.Autowired;
4141
import org.springframework.context.annotation.Bean;
4242
import org.springframework.context.annotation.Configuration;
@@ -70,15 +70,15 @@ class AmqpJobFunctionalTests {
7070
public static RabbitMQContainer rabbitmq = new RabbitMQContainer(RABBITMQ_IMAGE);
7171

7272
@Autowired
73-
private JobLauncherTestUtils jobLauncherTestUtils;
73+
private JobOperatorTestUtils jobOperatorTestUtils;
7474

7575
@Autowired
7676
private JobExplorer jobExplorer;
7777

7878
@Test
7979
void testLaunchJobWithXmlConfig() throws Exception {
8080
// given
81-
this.jobLauncherTestUtils.launchJob();
81+
this.jobOperatorTestUtils.startJob();
8282

8383
// when
8484
int count = jobExplorer.getJobInstances("amqp-example-job", 0, 1).size();
@@ -92,11 +92,11 @@ public void testLaunchJobWithJavaConfig() throws Exception {
9292
// given
9393
ApplicationContext context = new AnnotationConfigApplicationContext(AmqpJobConfiguration.class,
9494
AmqpConfiguration.class);
95-
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
95+
JobOperator jobOperator = context.getBean(JobOperator.class);
9696
Job job = context.getBean(Job.class);
9797

9898
// when
99-
jobLauncher.run(job, new JobParameters());
99+
jobOperator.start(job, new JobParameters());
100100

101101
// then
102102
JobExplorer localJobExplorer = context.getBean(JobExplorer.class);

spring-batch-samples/src/test/java/org/springframework/batch/samples/beanwrapper/BeanWrapperMapperSampleJobFunctionalTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020

2121
import org.springframework.batch.core.BatchStatus;
2222
import org.springframework.batch.core.job.JobExecution;
23-
import org.springframework.batch.test.JobLauncherTestUtils;
23+
import org.springframework.batch.test.JobOperatorTestUtils;
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2626

@@ -31,12 +31,12 @@
3131
class BeanWrapperMapperSampleJobFunctionalTests {
3232

3333
@Autowired
34-
private JobLauncherTestUtils jobLauncherTestUtils;
34+
private JobOperatorTestUtils jobOperatorTestUtils;
3535

3636
@Test
3737
void testJobLaunch() throws Exception {
3838
// when
39-
JobExecution jobExecution = this.jobLauncherTestUtils.launchJob();
39+
JobExecution jobExecution = this.jobOperatorTestUtils.startJob();
4040

4141
// then
4242
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());

spring-batch-samples/src/test/java/org/springframework/batch/samples/chunking/RemoteChunkingJobFunctionalTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2023 the original author or authors.
2+
* Copyright 2018-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
import org.springframework.batch.core.job.Job;
2727
import org.springframework.batch.core.job.JobExecution;
2828
import org.springframework.batch.core.job.parameters.JobParameters;
29-
import org.springframework.batch.core.launch.JobLauncher;
29+
import org.springframework.batch.core.launch.JobOperator;
3030
import org.springframework.beans.factory.annotation.Autowired;
3131
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3232
import org.springframework.context.annotation.PropertySource;
@@ -48,7 +48,7 @@
4848
class RemoteChunkingJobFunctionalTests {
4949

5050
@Autowired
51-
private JobLauncher jobLauncher;
51+
private JobOperator jobOperator;
5252

5353
private EmbeddedActiveMQ brokerService;
5454

@@ -74,7 +74,7 @@ void tearDown() throws Exception {
7474
@Test
7575
void testRemoteChunkingJob(@Autowired Job job) throws Exception {
7676
// when
77-
JobExecution jobExecution = this.jobLauncher.run(job, new JobParameters());
77+
JobExecution jobExecution = this.jobOperator.start(job, new JobParameters());
7878

7979
// then
8080
// the manager sent 2 chunks ({1, 2, 3} and {4, 5, 6}) to workers

spring-batch-samples/src/test/java/org/springframework/batch/samples/compositereader/CompositeItemReaderSampleFunctionalTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 the original author or authors.
2+
* Copyright 2024-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
import org.springframework.batch.core.job.parameters.JobParameters;
2929
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
3030
import org.springframework.batch.core.job.builder.JobBuilder;
31-
import org.springframework.batch.core.launch.JobLauncher;
31+
import org.springframework.batch.core.launch.JobOperator;
3232
import org.springframework.batch.core.repository.JobRepository;
3333
import org.springframework.batch.core.step.builder.StepBuilder;
3434
import org.springframework.batch.item.database.JdbcBatchItemWriter;
@@ -59,11 +59,11 @@ record Person(int id, String name) {
5959
void testJobLaunch() throws Exception {
6060
// given
6161
ApplicationContext context = new AnnotationConfigApplicationContext(JobConfiguration.class);
62-
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
62+
JobOperator jobOperator = context.getBean(JobOperator.class);
6363
Job job = context.getBean(Job.class);
6464

6565
// when
66-
JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
66+
JobExecution jobExecution = jobOperator.start(job, new JobParameters());
6767

6868
// then
6969
Assertions.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());

0 commit comments

Comments
 (0)