RESOLVED - BATCH-961: integration tests for JobOperator
tested multiple instances running simultaneously
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
</bean>
|
||||
|
||||
<bean id="infiniteLoopJob" parent="simpleJob">
|
||||
<property name="jobParametersIncrementer">
|
||||
<bean class="org.springframework.batch.sample.common.InfiniteLoopIncrementer" />
|
||||
</property>
|
||||
<property name="steps">
|
||||
<!--bean id="step1" parent="taskletStep">
|
||||
<property name="tasklet">
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -37,7 +38,8 @@ public class JobOperatorFunctionalTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jobRegistry.register(new ReferenceJobFactory(job));
|
||||
if (!jobRegistry.getJobNames().contains(job.getName()))
|
||||
jobRegistry.register(new ReferenceJobFactory(job));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,4 +96,27 @@ public class JobOperatorFunctionalTests {
|
||||
assertTrue(summaries.values().toString().contains(STOPPED.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleSimultaneousInstances() throws Exception {
|
||||
String jobName = job.getName();
|
||||
|
||||
Set<String> names = tested.getJobNames();
|
||||
assertEquals(1, names.size());
|
||||
assertTrue(names.contains(jobName));
|
||||
|
||||
long exec1 = tested.startNextInstance(jobName);
|
||||
long exec2 = tested.startNextInstance(jobName);
|
||||
|
||||
assertTrue(exec1 != exec2);
|
||||
assertTrue(tested.getParameters(exec1) != tested.getParameters(exec2));
|
||||
|
||||
Set<Long> executions = tested.getRunningExecutions(jobName);
|
||||
assertTrue(executions.contains(exec1));
|
||||
assertTrue(executions.contains(exec2));
|
||||
|
||||
tested.stop(exec1);
|
||||
tested.stop(exec2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user