BATCH-1666: Add abort(long executionId) convenience method to JobOperator

This commit is contained in:
Chris Schaefer
2012-09-30 14:34:43 -04:00
parent 54d1aabfaa
commit 4b68ed3aac
3 changed files with 56 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -393,4 +394,29 @@ public class SimpleJobOperatorTests {
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
}
@Test
public void testAbort() throws Exception {
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
jobExecution.setStatus(BatchStatus.STOPPING);
jobExplorer.getJobExecution(123L);
expectLastCall().andReturn(jobExecution);
jobRepository.update(jobExecution);
replay(jobExplorer);
jobOperator.abandon(123L);
assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus());
assertNotNull(jobExecution.getEndTime());
}
@Test(expected = JobExecutionAlreadyRunningException.class)
public void testAbortNonStopping() throws Exception {
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
jobExecution.setStatus(BatchStatus.STARTED);
jobExplorer.getJobExecution(123L);
expectLastCall().andReturn(jobExecution);
jobRepository.update(jobExecution);
replay(jobExplorer);
jobOperator.abandon(123L);
}
}