RESOLVED - issue BATCH-321: Throw exception if attempt to create duplicate job instance occurs (based on job parameters)
http://jira.springframework.org/browse/BATCH-321 repository now throws exception if JobInstance already exists for non-restartable job. Had to tweak sample junit launcher to allow parameter setting because HibernateJob is run twice.
This commit is contained in:
@@ -38,8 +38,14 @@ public abstract class AbstractBatchLauncherTests extends
|
||||
|
||||
private static final String CONTAINER_DEFINITION_LOCATION = "simple-container-definition.xml";
|
||||
|
||||
public AbstractBatchLauncherTests() {
|
||||
setDependencyCheck(false);
|
||||
}
|
||||
|
||||
JobLauncher launcher;
|
||||
private Job job;
|
||||
|
||||
private JobParameters jobParameters = new JobParameters();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -74,11 +80,15 @@ public abstract class AbstractBatchLauncherTests extends
|
||||
return job.getName();
|
||||
}
|
||||
|
||||
public void setJobParameters(JobParameters jobParameters) {
|
||||
this.jobParameters = jobParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public void testLaunchJob() throws Exception {
|
||||
launcher.run(job, new JobParameters());
|
||||
launcher.run(job, jobParameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.springframework.batch.sample;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.JobParametersBuilder;
|
||||
import org.springframework.batch.sample.dao.HibernateCreditWriter;
|
||||
import org.springframework.jdbc.UncategorizedSQLException;
|
||||
import org.springframework.orm.hibernate3.HibernateJdbcException;
|
||||
@@ -48,6 +50,8 @@ public class HibernateFailureJobFunctionalTests extends
|
||||
* @see org.springframework.batch.sample.AbstractValidatingBatchLauncherTests#testLaunchJob()
|
||||
*/
|
||||
public void testLaunchJob() throws Exception {
|
||||
JobParameters params = new JobParametersBuilder().addString("key", "failureJob").toJobParameters();
|
||||
setJobParameters(params);
|
||||
writer.setFailOnFlush(2);
|
||||
|
||||
int before = jdbcTemplate.queryForInt("SELECT COUNT(*) from CUSTOMER");
|
||||
|
||||
Reference in New Issue
Block a user