BATCH-453: Added stop support to SimpleJobOperator and generated correct sql for remaining schema files.

This commit is contained in:
lucasward
2008-08-26 03:53:41 +00:00
parent c0c8331227
commit f81604e439
12 changed files with 94 additions and 108 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.batch.core.launch.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.easymock.EasyMock.*;
import java.util.Arrays;
import java.util.Collection;
@@ -30,6 +31,7 @@ import java.util.Set;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
@@ -46,6 +48,7 @@ import org.springframework.batch.core.launch.NoSuchJobExecutionException;
import org.springframework.batch.core.launch.NoSuchJobInstanceException;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.core.step.StepSupport;
import org.springframework.batch.support.PropertiesConverter;
@@ -61,6 +64,8 @@ public class SimpleJobOperatorTests {
protected Job job;
private JobExplorer jobExplorer;
private JobRepository jobRepository;
private JobParameters jobParameters;
@@ -108,6 +113,9 @@ public class SimpleJobOperatorTests {
jobExplorer = EasyMock.createNiceMock(JobExplorer.class);
jobOperator.setJobExplorer(jobExplorer);
jobRepository = createMock(JobRepository.class);
jobOperator.setJobRepository(jobRepository);
jobOperator.setJobParametersConverter(new DefaultJobParametersConverter() {
@Override
@@ -138,17 +146,6 @@ public class SimpleJobOperatorTests {
}
}
@Test
public void testStop() throws Exception {
try {
jobOperator.stop(123L);
fail("Expected UnsupportedOperationException");
}
catch (UnsupportedOperationException e) {
// expected
}
}
/**
* Test method for
* {@link org.springframework.batch.core.launch.support.SimpleJobOperator#startNextInstance(java.lang.String)}
@@ -378,5 +375,20 @@ public class SimpleJobOperatorTests {
}
EasyMock.verify(jobExplorer);
}
@Test
public void testStop() throws Exception{
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
jobExplorer.getJobExecution(111L);
expectLastCall().andReturn(jobExecution);
jobRepository.update(jobExecution);
replay(jobExplorer);
replay(jobRepository);
jobOperator.stop(111L);
verify(jobExplorer);
verify(jobRepository);
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
}
}