Add support to use any type as a job parameter

This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* https://github.com/spring-projects/spring-batch/issues/3960
* https://github.com/spring-projects/spring-batch/issues/2122
* https://github.com/spring-projects/spring-batch/issues/1035
* https://github.com/spring-projects/spring-batch/issues/1983
This commit is contained in:
Mahmoud Ben Hassine
2022-09-30 10:31:22 +02:00
parent 027302469a
commit 2660f2bb27
72 changed files with 2508 additions and 927 deletions

View File

@@ -57,8 +57,8 @@ class RemoteChunkFaultTolerantStepIntegrationTests {
@Test
void testFailedStep() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("unsupported"))));
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(
Collections.singletonMap("item.three", new JobParameter("unsupported", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -69,7 +69,7 @@ class RemoteChunkFaultTolerantStepIntegrationTests {
@Test
void testFailedStepOnError() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -80,7 +80,7 @@ class RemoteChunkFaultTolerantStepIntegrationTests {
@Test
void testSunnyDayFaultTolerant() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3", Integer.class))));
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());

View File

@@ -58,8 +58,8 @@ class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
@Test
@DirtiesContext
void testFailedStep() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("unsupported"))));
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(
Collections.singletonMap("item.three", new JobParameter("unsupported", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -71,7 +71,7 @@ class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
@DirtiesContext
void testFailedStepOnError() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -83,7 +83,7 @@ class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
@DirtiesContext
void testSunnyDayFaultTolerant() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3", Integer.class))));
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());

View File

@@ -52,8 +52,8 @@ class RemoteChunkFaultTolerantStepJmsIntegrationTests {
@Test
void testFailedStep() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("unsupported"))));
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(
Collections.singletonMap("item.three", new JobParameter("unsupported", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -64,7 +64,7 @@ class RemoteChunkFaultTolerantStepJmsIntegrationTests {
@Test
void testFailedStepOnError() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("error", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -75,7 +75,7 @@ class RemoteChunkFaultTolerantStepJmsIntegrationTests {
@Test
void testSunnyDayFaultTolerant() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3", Integer.class))));
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());

View File

@@ -42,7 +42,7 @@ class RemoteChunkStepIntegrationTests {
@Test
void testSunnyDaySimpleStep() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("3", Integer.class))));
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());
@@ -52,7 +52,7 @@ class RemoteChunkStepIntegrationTests {
@Test
void testFailedStep() throws Exception {
JobExecution jobExecution = jobLauncher.run(job,
new JobParameters(Collections.singletonMap("item.three", new JobParameter("fail"))));
new JobParameters(Collections.singletonMap("item.three", new JobParameter("fail", String.class))));
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
assertEquals(9, stepExecution.getReadCount());