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:
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user