Update versions and update code format
This commit is contained in:
@@ -71,21 +71,23 @@ public class JobConfiguration {
|
||||
@Bean
|
||||
public Step step2() {
|
||||
return new StepBuilder("step2", this.jobRepository)
|
||||
.<String, String>chunk(DEFAULT_CHUNK_COUNT, transactionManager)
|
||||
.reader(new ListItemReader<>(Arrays.asList("1", "2", "3", "4", "5", "6")))
|
||||
.processor(new ItemProcessor<String, String>() {
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
return String.valueOf(Integer.parseInt(item) * -1);
|
||||
.<String, String>chunk(DEFAULT_CHUNK_COUNT, transactionManager)
|
||||
.reader(new ListItemReader<>(Arrays.asList("1", "2", "3", "4", "5", "6")))
|
||||
.processor(new ItemProcessor<String, String>() {
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
return String.valueOf(Integer.parseInt(item) * -1);
|
||||
}
|
||||
})
|
||||
.writer(new ItemWriter<String>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> items) throws Exception {
|
||||
for (Object item : items) {
|
||||
System.out.println(">> " + item);
|
||||
}
|
||||
}).writer(new ItemWriter<String>() {
|
||||
@Override
|
||||
public void write(Chunk<? extends String> items) throws Exception {
|
||||
for (Object item : items) {
|
||||
System.out.println(">> " + item);
|
||||
}
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,14 +63,19 @@ public class JobSkipConfiguration {
|
||||
|
||||
@Bean
|
||||
public Step step2() {
|
||||
return new StepBuilder("step2", this.jobRepository).chunk(3, transactionManager).faultTolerant()
|
||||
.skip(IllegalStateException.class).skipLimit(100).reader(new SkipItemReader())
|
||||
.processor(new ItemProcessor<Object, Object>() {
|
||||
@Override
|
||||
public String process(Object item) throws Exception {
|
||||
return String.valueOf(Integer.parseInt((String) item) * -1);
|
||||
}
|
||||
}).writer(new SkipItemWriter()).build();
|
||||
return new StepBuilder("step2", this.jobRepository).chunk(3, transactionManager)
|
||||
.faultTolerant()
|
||||
.skip(IllegalStateException.class)
|
||||
.skipLimit(100)
|
||||
.reader(new SkipItemReader())
|
||||
.processor(new ItemProcessor<Object, Object>() {
|
||||
@Override
|
||||
public String process(Object item) throws Exception {
|
||||
return String.valueOf(Integer.parseInt((String) item) * -1);
|
||||
}
|
||||
})
|
||||
.writer(new SkipItemWriter())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class TaskStartTests {
|
||||
TaskExecution te = taskExecutions.iterator().next();
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,7 +169,7 @@ public class TaskStartTests {
|
||||
TaskExecution te = taskExecutions.iterator().next();
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
assertThat(this.taskExplorer.getTaskExecution(1).getTaskName()).isEqualTo("batchEvents");
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class TaskStartTests {
|
||||
Page<TaskExecution> taskExecutions = this.taskExplorer.findAll(PageRequest.of(0, 10));
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
assertThat(this.taskExplorer.getTaskExecution(1).getStartTime().isEqual(startDate)).isTrue();
|
||||
|
||||
}
|
||||
@@ -227,7 +227,8 @@ public class TaskStartTests {
|
||||
testFailed = true;
|
||||
}
|
||||
assertThat(testFailed)
|
||||
.as("Expected TaskExecutionException for because of " + "single-instance-enabled is enabled").isTrue();
|
||||
.as("Expected TaskExecutionException for because of " + "single-instance-enabled is enabled")
|
||||
.isTrue();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class TaskInitializerTests {
|
||||
TaskExecution te = taskExecutions.iterator().next();
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,7 +160,7 @@ public class TaskInitializerTests {
|
||||
TaskExecution te = taskExecutions.iterator().next();
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
private boolean tableExists() throws SQLException {
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TaskLauncherSinkTests {
|
||||
assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1);
|
||||
assertThat(waitForTaskToComplete()).isTrue();
|
||||
assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0")
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
private boolean tableExists() throws SQLException {
|
||||
@@ -190,8 +190,9 @@ public class TaskLauncherSinkTests {
|
||||
public Server initH2TCPServer() {
|
||||
Server server;
|
||||
try {
|
||||
server = Server.createTcpServer("-ifNotExists", "-tcp", "-tcpAllowOthers", "-tcpPort",
|
||||
String.valueOf(randomPort)).start();
|
||||
server = Server
|
||||
.createTcpServer("-ifNotExists", "-tcp", "-tcpAllowOthers", "-tcpPort", String.valueOf(randomPort))
|
||||
.start();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
||||
@@ -71,9 +71,10 @@ public class BatchExecutionEventTests {
|
||||
@Test
|
||||
public void testContext() {
|
||||
this.applicationContext = new SpringApplicationBuilder()
|
||||
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(BatchEventsApplication.class))
|
||||
.web(WebApplicationType.NONE).build()
|
||||
.run(getCommandLineParams("--spring.cloud.stream.bindings.job-execution-events.destination=bazbar"));
|
||||
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(BatchEventsApplication.class))
|
||||
.web(WebApplicationType.NONE)
|
||||
.build()
|
||||
.run(getCommandLineParams("--spring.cloud.stream.bindings.job-execution-events.destination=bazbar"));
|
||||
|
||||
assertThat(this.applicationContext.getBean("jobExecutionEventsListener")).isNotNull();
|
||||
assertThat(this.applicationContext.getBean("stepExecutionEventsListener")).isNotNull();
|
||||
@@ -90,8 +91,9 @@ public class BatchExecutionEventTests {
|
||||
"--spring.cloud.task.batch.events.jobExecutionEventBindingName=foobar", "foobar", 1);
|
||||
JobExecutionEvent jobExecutionEvent = this.objectMapper.readValue(result.get(0).getPayload(),
|
||||
JobExecutionEvent.class);
|
||||
Assertions.assertThat(jobExecutionEvent.getJobInstance().getJobName()).isEqualTo("job")
|
||||
.as("Job name should be job");
|
||||
Assertions.assertThat(jobExecutionEvent.getJobInstance().getJobName())
|
||||
.isEqualTo("job")
|
||||
.as("Job name should be job");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,8 +180,10 @@ public class BatchExecutionEventTests {
|
||||
List<Message<byte[]>> results = new ArrayList<>();
|
||||
|
||||
this.applicationContext = new SpringApplicationBuilder()
|
||||
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(clazz)).web(WebApplicationType.NONE)
|
||||
.build().run(getCommandLineParams(channelBinding, enableFailJobConfig));
|
||||
.sources(TestChannelBinderConfiguration.getCompleteConfiguration(clazz))
|
||||
.web(WebApplicationType.NONE)
|
||||
.build()
|
||||
.run(getCommandLineParams(channelBinding, enableFailJobConfig));
|
||||
|
||||
OutputDestination target = this.applicationContext.getBean(OutputDestination.class);
|
||||
|
||||
|
||||
@@ -66,19 +66,23 @@ public class TaskEventTests {
|
||||
List<Message<byte[]>> result = testListener(
|
||||
"--spring.cloud.task.batch.events.itemWriteEventBindingName=task-events", "task-events", 2);
|
||||
TaskExecution taskExecution = this.objectMapper.readValue(result.get(0).getPayload(), TaskExecution.class);
|
||||
Assertions.assertThat(taskExecution.getTaskName()).isEqualTo(TASK_NAME)
|
||||
.as(String.format("Task name should be '%s'", TASK_NAME));
|
||||
Assertions.assertThat(taskExecution.getTaskName())
|
||||
.isEqualTo(TASK_NAME)
|
||||
.as(String.format("Task name should be '%s'", TASK_NAME));
|
||||
taskExecution = this.objectMapper.readValue(result.get(1).getPayload(), TaskExecution.class);
|
||||
Assertions.assertThat(taskExecution.getTaskName()).isEqualTo(TASK_NAME)
|
||||
.as(String.format("Task name should be '%s'", TASK_NAME));
|
||||
Assertions.assertThat(taskExecution.getTaskName())
|
||||
.isEqualTo(TASK_NAME)
|
||||
.as(String.format("Task name should be '%s'", TASK_NAME));
|
||||
}
|
||||
|
||||
private List<Message<byte[]>> testListener(String channelBinding, String bindingName, int numberToRead) {
|
||||
List<Message<byte[]>> results = new ArrayList<>();
|
||||
this.applicationContext = new SpringApplicationBuilder()
|
||||
.sources(TestChannelBinderConfiguration
|
||||
.getCompleteConfiguration(BatchExecutionEventTests.BatchEventsApplication.class))
|
||||
.web(WebApplicationType.NONE).build().run(getCommandLineParams(channelBinding));
|
||||
.sources(TestChannelBinderConfiguration
|
||||
.getCompleteConfiguration(BatchExecutionEventTests.BatchEventsApplication.class))
|
||||
.web(WebApplicationType.NONE)
|
||||
.build()
|
||||
.run(getCommandLineParams(channelBinding));
|
||||
OutputDestination target = this.applicationContext.getBean(OutputDestination.class);
|
||||
for (int i = 0; i < numberToRead; i++) {
|
||||
results.add(target.receive(10000, bindingName));
|
||||
|
||||
Reference in New Issue
Block a user