Updated SimpleStepExecutionSplitter to return a Set with addressable elements

This commit is contained in:
Michael Minella
2016-04-19 16:31:23 -05:00
parent 6e0d0531ce
commit ade242f2c4
2 changed files with 28 additions and 8 deletions

View File

@@ -15,8 +15,16 @@
*/
package org.springframework.batch.core.partition.support;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
@@ -29,13 +37,6 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory
import org.springframework.batch.core.step.tasklet.TaskletStep;
import org.springframework.batch.item.ExecutionContext;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -69,6 +70,22 @@ public class SimpleStepExecutionSplitterTests {
}
}
/**
* Tests the results of BATCH-2490
* @throws Exception
*/
@Test
public void testAddressabilityOfSetResults() throws Exception {
SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, true, step.getName(),
new SimplePartitioner());
Set<StepExecution> execs = splitter.split(stepExecution, 2);
assertEquals(2, execs.size());
StepExecution execution = execs.iterator().next();
execs.remove(execution);
assertEquals(1, execs.size());
}
@Test
public void testSimpleStepExecutionProviderJobRepositoryStepPartitioner() throws Exception {
final Map<String, ExecutionContext> map = Collections.singletonMap("foo", new ExecutionContext());