RESOLVED - BATCH-571: Remove reference to Step from StepExecution and reference to Job from JobInstance
JobInstance's reference to Job replaced with jobName string
This commit is contained in:
@@ -19,7 +19,6 @@ import java.util.Date;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -29,7 +28,7 @@ import org.springframework.batch.repeat.ExitStatus;
|
||||
*/
|
||||
public class JobExecutionTests extends TestCase {
|
||||
|
||||
private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), new JobSupport("foo")), new Long(12));
|
||||
private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), "foo"), new Long(12));
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
@@ -96,7 +95,7 @@ public class JobExecutionTests extends TestCase {
|
||||
*/
|
||||
public void testGetJobId() {
|
||||
assertEquals(11, execution.getJobId().longValue());
|
||||
execution = new JobExecution(new JobInstance(new Long(23), new JobParameters(), new JobSupport("testJob")), null);
|
||||
execution = new JobExecution(new JobInstance(new Long(23), new JobParameters(), "testJob"), null);
|
||||
assertEquals(23, execution.getJobId().longValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,26 +17,24 @@ package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
|
||||
/**
|
||||
* @author dsyer
|
||||
*
|
||||
*/
|
||||
public class JobInstanceTests extends TestCase {
|
||||
|
||||
private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), new JobSupport("job"));
|
||||
private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), "job");
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.JobInstance#getJobName()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
instance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("foo"));
|
||||
instance = new JobInstance(new Long(1), new JobParameters(), "foo");
|
||||
assertEquals("foo", instance.getJobName());
|
||||
}
|
||||
|
||||
public void testGetJob(){
|
||||
assertEquals("job", instance.getJob().getName());
|
||||
assertEquals("job", instance.getJobName());
|
||||
}
|
||||
|
||||
public void testCreateWithNulls(){
|
||||
@@ -47,7 +45,7 @@ public class JobInstanceTests extends TestCase {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
instance = new JobInstance(null, null, new JobSupport("testJob"));
|
||||
instance = new JobInstance(null, null, "testJob");
|
||||
assertEquals("testJob", instance.getJobName());
|
||||
assertEquals(0, instance.getJobParameters().getParameters().size());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -224,7 +223,7 @@ public class StepExecutionTests extends TestCase {
|
||||
}
|
||||
|
||||
private StepExecution newStepExecution(Step step, Long long2) {
|
||||
JobInstance job = new JobInstance(new Long(3), new JobParameters(), new JobSupport("testJob"));
|
||||
JobInstance job = new JobInstance(new Long(3), new JobParameters(), "testJob");
|
||||
StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, long2), new Long(4));
|
||||
return execution;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ public class SimpleJobTests extends TestCase {
|
||||
* Check JobRepository to ensure status is being saved.
|
||||
*/
|
||||
private void checkRepository(BatchStatus status, ExitStatus exitStatus) {
|
||||
assertEquals(jobInstance, jobInstanceDao.getJobInstance(jobInstance.getJob(), jobParameters));
|
||||
assertEquals(jobInstance, jobInstanceDao.getJobInstance(job, jobParameters));
|
||||
// because map dao stores in memory, it can be checked directly
|
||||
JobExecution jobExecution = (JobExecution) jobExecutionDao.findJobExecutions(jobInstance).get(0);
|
||||
assertEquals(jobInstance.getId(), jobExecution.getJobId());
|
||||
|
||||
@@ -21,11 +21,8 @@ import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.listener.CompositeExecutionJobListener;
|
||||
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -79,7 +76,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
list.add("foo");
|
||||
}
|
||||
});
|
||||
listener.beforeJob(new JobExecution(new JobInstance(new Long(11L), null, new JobSupport())));
|
||||
listener.beforeJob(new JobExecution(new JobInstance(new Long(11L), null, "testOpenJob")));
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,13 @@ import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
|
||||
public abstract class AbstractJobExecutionDaoTests extends AbstractTransactionalDataSourceSpringContextTests {
|
||||
|
||||
JobExecutionDao dao;
|
||||
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("execTestJob"));
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), "execTestJob");
|
||||
|
||||
JobExecution execution = new JobExecution(jobInstance);
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ public abstract class AbstractJobInstanceDaoTests extends AbstractTransactionalD
|
||||
|
||||
JobInstance fooInstance = dao.createJobInstance(fooJob, fooParams);
|
||||
assertNotNull(fooInstance.getId());
|
||||
assertEquals(fooJob, fooInstance.getJob());
|
||||
assertEquals(fooJob.getName(), fooInstance.getJobName());
|
||||
assertEquals(fooParams, fooInstance.getJobParameters());
|
||||
|
||||
JobInstance retrievedInstance = dao.getJobInstance(fooJob, fooParams);
|
||||
JobParameters retrievedParams = retrievedInstance.getJobParameters();
|
||||
assertEquals(fooInstance, retrievedInstance);
|
||||
assertEquals(fooJob, retrievedInstance.getJob());
|
||||
assertEquals(fooJob.getName(), retrievedInstance.getJobName());
|
||||
assertEquals(fooParams, retrievedParams);
|
||||
|
||||
assertEquals(Long.MAX_VALUE, retrievedParams.getLong("longKey").longValue());
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractJobInstanceDaoTests extends AbstractTransactionalD
|
||||
|
||||
public void testCreationAddsVersion() {
|
||||
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("testVersionAndId"));
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), "testVersionAndId");
|
||||
|
||||
assertNull(jobInstance.getVersion());
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import junit.framework.TestCase;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.repository.dao.JdbcJobExecutionDao;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
@@ -71,9 +69,8 @@ public class JdbcJobDaoQueryTests extends TestCase {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), new JobSupport(
|
||||
"testJob")));
|
||||
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), "testJob"));
|
||||
|
||||
jobExecutionDao.saveJobExecution(jobExecution);
|
||||
assertEquals(1, list.size());
|
||||
String query = (String) list.get(0);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
|
||||
JobExecution firstExecution = jobRepository.createJobExecution(job, jobParams);
|
||||
firstExecution.setStartTime(new Date());
|
||||
|
||||
assertEquals(job, firstExecution.getJobInstance().getJob());
|
||||
assertEquals(job.getName(), firstExecution.getJobInstance().getJobName());
|
||||
|
||||
jobRepository.saveOrUpdate(firstExecution);
|
||||
firstExecution.setEndTime(new Date());
|
||||
@@ -78,7 +78,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
|
||||
JobExecution secondExecution = jobRepository.createJobExecution(job, jobParams);
|
||||
|
||||
assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance());
|
||||
assertEquals(job, secondExecution.getJobInstance().getJob());
|
||||
assertEquals(job.getName(), secondExecution.getJobInstance().getJobName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
|
||||
JobExecution secondExecution = jobRepository.createJobExecution(job, jobParameters);
|
||||
|
||||
assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance());
|
||||
assertEquals(job, secondExecution.getJobInstance().getJob());
|
||||
assertEquals(job.getName(), secondExecution.getJobInstance().getJobName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
|
||||
SimpleJobRepository jobRepository;
|
||||
|
||||
JobSupport jobConfiguration;
|
||||
JobSupport job;
|
||||
|
||||
JobParameters jobParameters;
|
||||
|
||||
@@ -85,9 +85,9 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
|
||||
jobParameters = new JobParametersBuilder().toJobParameters();
|
||||
|
||||
jobConfiguration = new JobSupport();
|
||||
jobConfiguration.setBeanName("RepositoryTest");
|
||||
jobConfiguration.setRestartable(true);
|
||||
job = new JobSupport();
|
||||
job.setBeanName("RepositoryTest");
|
||||
job.setRestartable(true);
|
||||
|
||||
stepConfiguration1 = new StepSupport("TestStep1");
|
||||
|
||||
@@ -97,9 +97,9 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
stepConfigurations.add(stepConfiguration1);
|
||||
stepConfigurations.add(stepConfiguration2);
|
||||
|
||||
jobConfiguration.setSteps(stepConfigurations);
|
||||
job.setSteps(stepConfigurations);
|
||||
|
||||
databaseJob = new JobInstance(new Long(1), jobParameters, jobConfiguration);
|
||||
databaseJob = new JobInstance(new Long(1), jobParameters, job.getName());
|
||||
|
||||
databaseStep1 = "dbStep1";
|
||||
databaseStep2 = "dbStep2";
|
||||
@@ -126,7 +126,7 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
|
||||
public void testSaveOrUpdateValidJobExecution() throws Exception {
|
||||
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1), jobParameters, jobConfiguration));
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1), jobParameters, job.getName()));
|
||||
|
||||
// new execution - call save on job dao
|
||||
jobExecutionDao.saveJobExecution(jobExecution);
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.SimpleJob;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JdbcCursorItemReader;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
@@ -34,7 +33,7 @@ public class JdbcCursorItemReaderPreparedStatementIntegrationTests extends
|
||||
itemReader.setSaveState(true);
|
||||
StepExecutionPreparedStatementSetter pss = new StepExecutionPreparedStatementSetter();
|
||||
JobParameters jobParameters = new JobParametersBuilder().addLong("begin.id", new Long(1)).addLong("end.id", new Long(4)).toJobParameters();
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), jobParameters, new SimpleJob());
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), jobParameters, "simpleJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, new Long(2));
|
||||
StepExecution stepExecution = new StepExecution("taskletStep", jobExecution, new Long(3) );
|
||||
pss.beforeStep(stepExecution);
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.SimpleJob;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
|
||||
@@ -47,7 +46,7 @@ public class StepExecutionPreparedStatementSetterTests extends AbstractTransacti
|
||||
|
||||
pss = new StepExecutionPreparedStatementSetter();
|
||||
JobParameters jobParameters = new JobParametersBuilder().addLong("begin.id", new Long(1)).addLong("end.id", new Long(4)).toJobParameters();
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), jobParameters, new SimpleJob());
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), jobParameters, "simpleJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, new Long(2));
|
||||
stepExecution = new StepExecution("taskletStep", jobExecution, new Long(3) );
|
||||
pss.beforeStep(stepExecution);
|
||||
|
||||
@@ -27,8 +27,6 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.resource.StepExecutionResourceProxy;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
@@ -63,7 +61,7 @@ public class StepExecutionResourceProxyTests extends TestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
jobInstance = new JobInstance(new Long(0), new JobParameters(), new JobSupport("testJob"));
|
||||
jobInstance = new JobInstance(new Long(0), new JobParameters(), "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
stepExecution = jobExecution.createStepExecution(step);
|
||||
@@ -98,7 +96,7 @@ public class StepExecutionResourceProxyTests extends TestCase {
|
||||
public void testNonStandardFilePatternWithJobParameters() throws Exception {
|
||||
resource.setFilePattern("foo/data/%JOB_NAME%/%job.key%-foo");
|
||||
jobInstance = new JobInstance(new Long(0), new JobParametersBuilder().addString("job.key", "spam")
|
||||
.toJobParameters(), new JobSupport("testJob"));
|
||||
.toJobParameters(), "testJob");
|
||||
JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
Step step = new StepSupport("bar");
|
||||
resource.beforeStep(jobExecution.createStepExecution(step));
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -31,7 +30,7 @@ public class AbstractStepTests extends TestCase {
|
||||
final List events = new ArrayList();
|
||||
|
||||
final StepExecution execution = new StepExecution(tested.getName(), new JobExecution(new JobInstance(new Long(1),
|
||||
new JobParameters(), new JobSupport())));
|
||||
new JobParameters(), "jobName")));
|
||||
|
||||
/**
|
||||
* Fills the events list when abstract methods are called.
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
@@ -74,6 +75,8 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
|
||||
private ItemOrientedStep itemOrientedStep;
|
||||
|
||||
private Job job;
|
||||
|
||||
private JobInstance jobInstance;
|
||||
|
||||
private ResourcelessTransactionManager transactionManager;
|
||||
@@ -108,7 +111,8 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
template.setCompletionPolicy(new SimpleCompletionPolicy(1));
|
||||
itemOrientedStep.setChunkOperations(template);
|
||||
|
||||
jobInstance = new JobInstance(new Long(0), new JobParameters(), new JobSupport("FOO"));
|
||||
job = new JobSupport("FOO");
|
||||
jobInstance = new JobInstance(new Long(0), new JobParameters(), job.getName());
|
||||
|
||||
itemOrientedStep.setTransactionManager(transactionManager);
|
||||
|
||||
@@ -149,7 +153,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
new MapStepExecutionDao());
|
||||
itemOrientedStep.setJobRepository(repository);
|
||||
|
||||
JobExecution jobExecution = repository.createJobExecution(jobInstance.getJob(), jobInstance.getJobParameters());
|
||||
JobExecution jobExecution = repository.createJobExecution(job, jobInstance.getJobParameters());
|
||||
StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution);
|
||||
|
||||
itemOrientedStep.execute(stepExecution);
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy;
|
||||
import org.springframework.batch.item.ClearFailedException;
|
||||
@@ -53,7 +52,7 @@ public class ItemSkipPolicyItemHandlerTests extends TestCase {
|
||||
private ItemSkipPolicyItemHandler handler = new ItemSkipPolicyItemHandler(new SkipReaderStub(), writer);
|
||||
|
||||
private StepContribution contribution = new StepContribution(new JobExecution(new JobInstance(new Long(11),
|
||||
new JobParameters(), new JobSupport())).createStepExecution(new StepSupport("foo")));
|
||||
new JobParameters(), "jobName")).createStepExecution(new StepSupport("foo")));
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
// remove the resource if it exists
|
||||
|
||||
@@ -25,10 +25,8 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.launch.EmptyItemWriter;
|
||||
import org.springframework.batch.core.step.JobRepositorySupport;
|
||||
import org.springframework.batch.core.step.item.RepeatOperationsStepFactoryBean;
|
||||
import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.RepeatCallback;
|
||||
@@ -45,9 +43,8 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
|
||||
|
||||
private List list;
|
||||
|
||||
private JobExecution jobExecution = new JobExecution(new JobInstance(new Long(0L), new JobParameters(),
|
||||
new JobSupport("job")));
|
||||
|
||||
private JobExecution jobExecution = new JobExecution(new JobInstance(new Long(0L), new JobParameters(), "job"));
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
factory.setBeanName("RepeatOperationsStep");
|
||||
factory.setItemReader(new ListItemReader(new ArrayList()));
|
||||
|
||||
@@ -65,7 +65,11 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
|
||||
private ItemReader reader;
|
||||
|
||||
private SimpleJob job = new SimpleJob();;
|
||||
private SimpleJob job = new SimpleJob() {
|
||||
{
|
||||
setBeanName("simpleJob");
|
||||
}
|
||||
};
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@@ -188,16 +192,17 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
}
|
||||
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
|
||||
public void testChunkListeners() throws Exception {
|
||||
String[] items = new String[] { "1", "2", "3", "4", "5", "6", "7" };
|
||||
int commitInterval = 3;
|
||||
|
||||
|
||||
SimpleStepFactoryBean factory = getStepFactory(items);
|
||||
class CountingChunkListener implements ChunkListener {
|
||||
int beforeCount = 0;
|
||||
|
||||
int afterCount = 0;
|
||||
|
||||
|
||||
public void afterChunk() {
|
||||
afterCount++;
|
||||
}
|
||||
@@ -207,9 +212,9 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
}
|
||||
}
|
||||
CountingChunkListener chunkListener = new CountingChunkListener();
|
||||
factory.setListeners(new StepListener[]{ chunkListener });
|
||||
factory.setListeners(new StepListener[] { chunkListener });
|
||||
factory.setCommitInterval(commitInterval);
|
||||
|
||||
|
||||
AbstractStep step = (AbstractStep) factory.getObject();
|
||||
|
||||
job.setSteps(Collections.singletonList(step));
|
||||
@@ -220,21 +225,21 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertNull(reader.read());
|
||||
assertEquals(items.length, written.size());
|
||||
|
||||
int expectedListenerCallCount = (items.length / commitInterval ) + 1;
|
||||
|
||||
int expectedListenerCallCount = (items.length / commitInterval) + 1;
|
||||
assertEquals(expectedListenerCallCount, chunkListener.afterCount);
|
||||
assertEquals(expectedListenerCallCount, chunkListener.beforeCount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Commit interval specified is not allowed to be zero or negative.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testCommitIntervalMustBeGreaterThanZero() throws Exception {
|
||||
SimpleStepFactoryBean factory = getStepFactory("foo");
|
||||
// nothing wrong here
|
||||
factory.getObject();
|
||||
|
||||
|
||||
// but exception excpected after setting commit interval to value <= 0
|
||||
factory.setCommitInterval(0);
|
||||
try {
|
||||
@@ -244,7 +249,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
factory.setCommitInterval(-1);
|
||||
try {
|
||||
factory.getObject();
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.batch.core.step.JobRepositorySupport;
|
||||
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
|
||||
@@ -61,7 +60,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
|
||||
factory.setSkippableExceptionClasses(skippableExceptions);
|
||||
factory.setSkipLimit(SKIP_LIMIT);
|
||||
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("skipJob"));
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), "skipJob");
|
||||
jobExecution = new JobExecution(jobInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.JobRepositorySupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -26,7 +25,7 @@ public class TaskletStepTests extends TestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(new Long(0L),
|
||||
new JobParameters(), new JobSupport("testJob")), new Long(12)));
|
||||
new JobParameters(), "testJob"), new Long(12)));
|
||||
}
|
||||
|
||||
public void testTaskletMandatory() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user