IN PROGRESS - issue BATCH-340: Refactor JobRepository for greater clarity and consistency.

http://jira.springframework.org/browse/BATCH-340

renaming and javadoc updates
This commit is contained in:
robokaso
2008-02-07 11:47:43 +00:00
parent 20baeef552
commit 1128bbe187
17 changed files with 236 additions and 231 deletions

View File

@@ -46,6 +46,7 @@ import org.springframework.util.Assert;
*
* @author Lucas Ward
* @author Dave Syer
*
* @see JobRepository
* @see StepDao
* @see JobDao
@@ -72,23 +73,24 @@ public class SimpleJobRepository implements JobRepository {
/**
* <p>
* Create a (@link {@link JobExecution}) based on the passed in
* {@link JobIdentifier} and {@link JobSupport}. However, unique identification of
* a job can only come from the database, and therefore must come from
* JobDao by either creating a new job or finding an existing one, which
* will ensure that the id of the job is populated with the correct value.
* Create a {@link JobExecution} based on the passed in
* {@link JobIdentifier} and {@link JobSupport}. However, unique
* identification of a job can only come from the database, and therefore
* must come from JobDao by either creating a new job or finding an existing
* one, which will ensure that the id of the job is populated with the
* correct value.
* </p>
*
* <p>
* There are two ways in which the method determines if a job should be
* created or an existing one should be returned. The first is
* restartability. The {@link JobSupport} restartable property will be checked
* first. If it is not false, a new job will be created, regardless of
* whether or not one exists. If it is true, the {@link JobDao} will be
* restartability. The {@link JobSupport} restartable property will be
* checked first. If it is false, a new job will be created, regardless
* of whether or not one exists. If it is true, the {@link JobDao} will be
* checked to determine if the job already exists, if it does, it's steps
* will be populated (there must be at least 1) and a new
* {@link JobExecution} will be returned. If no job is found, a new one will
* be created based on the job.
* be created.
* </p>
*
* <p>
@@ -100,10 +102,10 @@ public class SimpleJobRepository implements JobRepository {
* <li>What happens then depends on how many existing job instances we
* find:
* <ul>
* <li>If there are none, or the {@link JobSupport} is marked restartable, then we
* create a new {@link JobInstance}</li>
* <li>If there is more than one and the {@link JobSupport} is not marked as
* restartable, it is an error. This could be caused by a job whose
* <li>If there are none, or the {@link JobSupport} is marked restartable,
* then we create a new {@link JobInstance}</li>
* <li>If there is more than one and the {@link JobSupport} is not marked
* as restartable, it is an error. This could be caused by a job whose
* restartable flag has changed to be more strict (true not false)
* <em>after</em> it has been executed at least once.</li>
* <li>If there is precisely one existing {@link JobInstance} then we check
@@ -213,11 +215,11 @@ public class SimpleJobRepository implements JobRepository {
if (jobExecution.getId() == null) {
// existing instance
jobDao.save(jobExecution);
jobDao.saveJobExecution(jobExecution);
}
else {
// new execution
jobDao.update(jobExecution);
jobDao.updateJobExecution(jobExecution);
}
}
@@ -235,7 +237,7 @@ public class SimpleJobRepository implements JobRepository {
Assert.notNull(job.getId(), "Job cannot be updated if it's ID is null. It must be obtained"
+ "from SimpleJobRepository.findOrCreateJob to be considered valid.");
jobDao.update(job);
jobDao.updateJobInstance(job);
}
/**
@@ -254,13 +256,13 @@ public class SimpleJobRepository implements JobRepository {
if (stepExecution.getId() == null) {
// new execution, obtain id and insert
stepDao.save(stepExecution);
stepDao.save(stepExecution.getId(), stepExecution.getExecutionAttributes());
stepDao.saveStepExecution(stepExecution);
stepDao.saveExecutionAttributes(stepExecution.getId(), stepExecution.getExecutionAttributes());
}
else {
// existing execution, update
stepDao.update(stepExecution);
stepDao.update(stepExecution.getId(), stepExecution.getExecutionAttributes());
stepDao.updateStepExecution(stepExecution);
stepDao.updateExecutionAttributes(stepExecution.getId(), stepExecution.getExecutionAttributes());
}
}
@@ -276,7 +278,7 @@ public class SimpleJobRepository implements JobRepository {
Assert.notNull(step.getId(), "Step cannot be updated if it's ID is null. It must be obtained"
+ "from SimpleJobRepository.findOrCreateJob to be considered valid.");
stepDao.update(step);
stepDao.updateStepInstance(step);
}
@@ -302,7 +304,7 @@ public class SimpleJobRepository implements JobRepository {
Iterator i = steps.iterator();
while (i.hasNext()) {
Step step = (Step) i.next();
StepInstance stepInstance = stepDao.createStep(job, step.getName());
StepInstance stepInstance = stepDao.createStepInstance(job, step.getName());
stepInstances.add(stepInstance);
}
@@ -312,18 +314,18 @@ public class SimpleJobRepository implements JobRepository {
/*
* Find Steps for the given list of Steps with a given JobId
*/
protected List findStepInstances(List steps, JobInstance job) {
protected List findStepInstances(List steps, JobInstance jobInstance) {
List stepInstances = new ArrayList();
Iterator i = steps.iterator();
while (i.hasNext()) {
Step stepConfiguration = (Step) i.next();
StepInstance stepInstance = stepDao.findStep(job, stepConfiguration.getName());
StepInstance stepInstance = stepDao.findStepInstance(jobInstance, stepConfiguration.getName());
if (stepInstance != null) {
if(stepInstance.getLastExecution() != null){
ExecutionAttributes executionAttributes = stepDao.findExecutionAttributes(
stepInstance.getLastExecution().getId());
if (stepInstance.getLastExecution() != null) {
ExecutionAttributes executionAttributes = stepDao.findExecutionAttributes(stepInstance
.getLastExecution().getId());
stepInstance.getLastExecution().setExecutionAttributes(executionAttributes);
}
stepInstance.setStepExecutionCount(stepDao.getStepExecutionCount(stepInstance));

View File

@@ -326,12 +326,12 @@ public class JdbcJobDao implements JobDao, InitializingBean {
* abstraction. Once a new id has been obtained, the JobExecution is saved
* via a SQL INSERT statement.
*
* @see JobDao#save(JobExecution)
* @see JobDao#saveJobExecution(JobExecution)
* @throws IllegalArgumentException
* if jobExecution is null, as well as any of it's fields to be
* persisted.
*/
public void save(JobExecution jobExecution) {
public void saveJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
@@ -392,9 +392,9 @@ public class JdbcJobDao implements JobDao, InitializingBean {
* ID. The database is then queried to ensure that the ID exists, which
* ensures that it is valid.
*
* @see JobDao#update(JobExecution)
* @see JobDao#updateJobExecution(JobExecution)
*/
public void update(JobExecution jobExecution) {
public void updateJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
@@ -437,11 +437,11 @@ public class JdbcJobDao implements JobDao, InitializingBean {
}
/**
* @see JobDao#update(JobInstance)
* @see JobDao#updateJobInstance(JobInstance)
* @throws IllegalArgumentException
* if Job, Job.status, or job.id is null
*/
public void update(JobInstance jobInstance) {
public void updateJobInstance(JobInstance jobInstance) {
Assert.notNull(jobInstance, "Job Cannot be Null");
Assert.notNull(jobInstance.getId(), "Job ID cannot be null");

View File

@@ -138,7 +138,7 @@ public class JdbcStepDao implements StepDao, InitializingBean {
// assume already saved...
return;
}
jobDao.save(jobExecution);
jobDao.saveJobExecution(jobExecution);
}
/**
@@ -146,10 +146,10 @@ public class JdbcStepDao implements StepDao, InitializingBean {
* unique id is created for the step using an incrementer. (@link
* DataFieldMaxValueIncrementer)
*
* @see StepDao#createStep(JobInstance, String)
* @see StepDao#createStepInstance(JobInstance, String)
* @throws IllegalArgumentException if job or stepName is null.
*/
public StepInstance createStep(JobInstance job, String stepName) {
public StepInstance createStepInstance(JobInstance job, String stepName) {
Assert.notNull(job, "Job cannot be null.");
Assert.notNull(stepName, "StepName cannot be null.");
@@ -168,12 +168,12 @@ public class JdbcStepDao implements StepDao, InitializingBean {
* and null will be returned. If one step is found, it will be returned. If
* anymore than one step is found, an exception is thrown.
*
* @see StepDao#findStep(Long, String)
* @see StepDao#findStepInstance(Long, String)
* @throws IllegalArgumentException if job, stepName, or job.id is null.
* @throws IncorrectResultSizeDataAccessException if more than one step is
* found.
*/
public StepInstance findStep(JobInstance jobInstance, String stepName) {
public StepInstance findStepInstance(JobInstance jobInstance, String stepName) {
Assert.notNull(jobInstance, "Job cannot be null.");
Assert.notNull(jobInstance.getId(), "Job ID cannot be null");
@@ -247,7 +247,7 @@ public class JdbcStepDao implements StepDao, InitializingBean {
* Insert execution attributes. A lob creator must be used, since any attributes
* that don't match a provided type must be serialized into a blob.
*/
public void save(final Long executionId, final ExecutionAttributes executionAttributes){
public void saveExecutionAttributes(final Long executionId, final ExecutionAttributes executionAttributes){
Assert.notNull(executionId, "ExecutionId must not be null.");
Assert.notNull(executionAttributes, "The ExecutionAttributes must not be null.");
@@ -320,7 +320,7 @@ public class JdbcStepDao implements StepDao, InitializingBean {
*
* @see {@link LobCreator}
*/
public void update(final Long executionId, ExecutionAttributes executionAttributes){
public void updateExecutionAttributes(final Long executionId, ExecutionAttributes executionAttributes){
Assert.notNull(executionId, "ExecutionId must not be null.");
Assert.notNull(executionAttributes, "The ExecutionAttributes must not be null.");
@@ -394,14 +394,14 @@ public class JdbcStepDao implements StepDao, InitializingBean {
}
/**
* @see StepDao#findSteps(JobInstance)
* @see StepDao#findStepInstances(JobInstance)
*
* Sql implementation which uses a RowMapper to populate a list of all rows
* in the step table with the same JOB_INSTANCE_ID.
*
* @throws IllegalArgumentException if jobId is null.
*/
public List findSteps(final JobInstance jobInstance) {
public List findStepInstances(final JobInstance jobInstance) {
Assert.notNull(jobInstance, "Job cannot be null.");
@@ -460,9 +460,9 @@ public class JdbcStepDao implements StepDao, InitializingBean {
* stepExecutionIncrementor, and then set in the StepExecution. All values
* will then be stored via an INSERT statement.
*
* @see StepDao#save(StepExecution)
* @see StepDao#saveStepExecution(StepExecution)
*/
public void save(StepExecution stepExecution) {
public void saveStepExecution(StepExecution stepExecution) {
validateStepExecution(stepExecution);
@@ -529,9 +529,9 @@ public class JdbcStepDao implements StepDao, InitializingBean {
}
/**
* @see StepDao#update(StepExecution)
* @see StepDao#updateStepExecution(StepExecution)
*/
public void update(StepExecution stepExecution) {
public void updateStepExecution(StepExecution stepExecution) {
validateStepExecution(stepExecution);
Assert.notNull(stepExecution.getId(), "StepExecution Id cannot be null. StepExecution must saved"
@@ -610,10 +610,10 @@ public class JdbcStepDao implements StepDao, InitializingBean {
}
/**
* @see StepDao#update(StepInstance)
* @see StepDao#updateStepInstance(StepInstance)
* @throws IllegalArgumentException if step, or it's status and id is null.
*/
public void update(final StepInstance step) {
public void updateStepInstance(final StepInstance step) {
Assert.notNull(step, "Step cannot be null.");
Assert.notNull(step.getId(), "Step Id cannot be null.");

View File

@@ -32,78 +32,81 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
public interface JobDao {
/**
* Create a job using the provided JobIdentifier as the natural key.
* Create a JobInstance with given name and parameters.
*
* PostConditions: A valid job will be returned which has been persisted and
* contains an unique Id.
*
* @param jobIdentifier
* @return Job
* @param jobName
* @param jobParameters
* @return JobInstance
*/
public JobInstance createJobInstance(String jobName, JobParameters jobParameters);
JobInstance createJobInstance(String jobName, JobParameters jobParameters);
/**
* Find all jobs that match the given JobIdentifier. If no jobs matching the
* Identifier are found, then a list of size 0 will be returned.
* Find all job instances that match the given name and parameters. If no
* matching job instances are found, then a list of size 0 will be
* returned.
*
* @param jobIdentifier
* @param jobName
* @param jobParameters
* @return List of {@link JobInstance} objects matching
* {@link JobIdentifier}
* {@link JobIdentifier}
*/
public List findJobInstances(String jobName, JobParameters jobParameters);
List findJobInstances(String jobName, JobParameters jobParameters);
/**
* Update an existing Job.
* Update an existing JobInstance.
*
* Preconditions: Job must have an ID.
* Preconditions: jobInstance must have an ID.
*
* @param job
* @param jobInstance
*/
public void update(JobInstance job);
void updateJobInstance(JobInstance jobInstance);
/**
* Save a new JobExecution.
*
* Preconditions: JobExecution must have a JobId.
* Preconditions: jobExecution must have a jobInstanceId.
*
* @param jobExecution
*/
public void save(JobExecution jobExecution);
void saveJobExecution(JobExecution jobExecution);
/**
* Update and existing JobExecution.
*
* Preconditions: JobExecution must have an Id (which can be obtained by the
* save method) and a JobId.
* Preconditions: jobExecution must have an Id (which can be obtained by the
* save method) and a jobInstanceId.
*
* @param jobExecution
*/
public void update(JobExecution jobExecution);
void updateJobExecution(JobExecution jobExecution);
/**
* Return the number of JobExecutions with the given Job Id
* Return the number of JobExecutions with the given jobInstanceId
*
* Preconditions: Job must have an id.
* Preconditions: jobInstance must have an id.
*
* @param job
* @param jobInstanceId
*/
public int getJobExecutionCount(Long jobId);
int getJobExecutionCount(Long jobInstanceId);
/**
* Return list of JobExecutions for given job.
* Return list of JobExecutions for given JobInstance.
*
* @param job
* @param jobInstance
* @return list of jobExecutions.
*/
public List findJobExecutions(JobInstance jobInstance);
List findJobExecutions(JobInstance jobInstance);
/**
* Given an id, return the matching JobExecution.
*
* @param jobExecutionId - id of the execution to be returned.
* @return {@link JobExecution} matching the id.
* @throws {@link IncorrectResultSizeDataAccessException} if
* more than one execution is found for the given id.
* @throws {@link IncorrectResultSizeDataAccessException} if more than one
* execution is found for the given id.
*/
public JobExecution getJobExecution(Long jobExecutionId);
JobExecution getJobExecution(Long jobExecutionId);
}

View File

@@ -71,7 +71,7 @@ public class MapJobDao implements JobDao {
if (executions==null) return 0;
return executions.size(); }
public void save(JobExecution jobExecution) {
public void saveJobExecution(JobExecution jobExecution) {
Set executions = (Set) executionsById.get(jobExecution.getJobId());
if (executions==null) {
executions = TransactionAwareProxyFactory.createTransactionalSet();
@@ -91,11 +91,11 @@ public class MapJobDao implements JobDao {
}
}
public void update(JobInstance job) {
public void updateJobInstance(JobInstance job) {
// no-op
}
public void update(JobExecution jobExecution) {
public void updateJobExecution(JobExecution jobExecution) {
// no-op
}

View File

@@ -49,7 +49,7 @@ public class MapStepDao implements StepDao {
restartsById.clear();
}
public StepInstance createStep(JobInstance job, String stepName) {
public StepInstance createStepInstance(JobInstance job, String stepName) {
StepInstance step = new StepInstance(job, stepName, new Long(currentId++));
Set steps = (Set) stepsByJobId.get(job.getId());
if (steps==null) {
@@ -61,7 +61,7 @@ public class MapStepDao implements StepDao {
return step;
}
public StepInstance findStep(JobInstance job, String stepName) {
public StepInstance findStepInstance(JobInstance job, String stepName) {
for (Iterator iter = stepsByJobId.values().iterator(); iter.hasNext();) {
Set steps = (Set) iter.next();
for (Iterator iterator = steps.iterator(); iterator.hasNext();) {
@@ -74,7 +74,7 @@ public class MapStepDao implements StepDao {
return null;
}
public List findSteps(JobInstance job) {
public List findStepInstances(JobInstance job) {
Set steps = (Set) stepsByJobId.get(job.getId());
if (steps==null) {
return new ArrayList();
@@ -91,7 +91,7 @@ public class MapStepDao implements StepDao {
if (executions==null) return 0;
return executions.size(); }
public void save(StepExecution stepExecution) {
public void saveStepExecution(StepExecution stepExecution) {
Set executions = (Set) executionsById.get(stepExecution.getStepId());
if (executions==null) {
executions = TransactionAwareProxyFactory.createTransactionalSet();
@@ -142,11 +142,11 @@ public class MapStepDao implements StepDao {
}
public void update(StepInstance step) {
public void updateStepInstance(StepInstance step) {
// no-op
}
public void update(StepExecution stepExecution) {
public void updateStepExecution(StepExecution stepExecution) {
// no-op
}
@@ -154,11 +154,11 @@ public class MapStepDao implements StepDao {
return null;
}
public void save(Long executionId,
public void saveExecutionAttributes(Long executionId,
ExecutionAttributes executionAttributes) {
}
public void update(Long executionId,
public void updateExecutionAttributes(Long executionId,
ExecutionAttributes executionAttributes) {
}
}

View File

@@ -36,48 +36,49 @@ public interface StepDao {
* Find a step with the given JobId and Step Name. Return null if none are
* found.
*
* @param jobId
* @param jobInstance
* @param stepName
* @return Step
* @return StepInstance
*/
public StepInstance findStep(JobInstance job, String stepName);
StepInstance findStepInstance(JobInstance jobInstance, String stepName);
/**
* Find all steps with the given Job.
* Find all StepInstances of the given JobInstance.
*
* @param job the job to use as a search key
* @param jobInstance the job to use as a search key
* @return list of {@link StepInstance}
*/
public List findSteps(JobInstance job);
List findStepInstances(JobInstance jobInstance);
/**
* Create a step for the given Step Name and Job Id.
* Create a StepInstance for the given name and JobInstance.
*
* @param job
* @param jobInstance
* @param stepName
*
* @return
*/
public StepInstance createStep(JobInstance job, String stepName);
StepInstance createStepInstance(JobInstance jobInstance, String stepName);
/**
* Update an existing Step.
* Update an existing StepInstance.
*
* Preconditions: Step must have an ID.
* Preconditions: StepInstance must have an ID.
*
* @param job
*/
public void update(StepInstance step);
void updateStepInstance(StepInstance stepInstance);
/**
* Save the given StepExecution.
*
* Preconditions: Id must be null. Postconditions: Id will be set to a
* Unique Long.
* Preconditions: Id must be null.
*
* Postconditions: Id will be set to a unique Long.
*
* @param stepExecution
*/
public void save(StepExecution stepExecution);
void saveStepExecution(StepExecution stepExecution);
/**
* Update the given StepExecution
@@ -86,61 +87,60 @@ public interface StepDao {
*
* @param stepExecution
*/
public void update(StepExecution stepExecution);
void updateStepExecution(StepExecution stepExecution);
/**
* Return the count of StepExecutions with the given {@link StepInstance}.
* Return the count of StepExecutions for the given {@link StepInstance}.
*
* @param step the {@link StepInstance} to check for executions
* @param stepInstance the {@link StepInstance} to check for executions
* @return the number of step executions for this step
*/
public int getStepExecutionCount(StepInstance step);
int getStepExecutionCount(StepInstance stepInstance);
/**
* Return all StepExecutions for the given step.
*
* @param step the step to use as a search key
* @param stepInstance the step to use as a search key
* @return list of stepExecutions
*/
public List findStepExecutions(StepInstance step);
List findStepExecutions(StepInstance stepInstance);
/**
* Return a StepExecution for the given id.
*
* @param stepExecutionId
* @return {@link StepExecution} for the provided id.
* @throws {@link IncorrectResultSizeDataAccessException} if more
* than one execution is found.
* @throws {@link IncorrectResultSizeDataAccessException} if more than one
* execution is found.
*/
public StepExecution getStepExecution(Long stepExecutionId, StepInstance stepInstance);
StepExecution getStepExecution(Long stepExecutionId, StepInstance stepInstance);
/**
* Find all {@link ExecutionAttributes} for the given execution id.
*
* @param executionId - Long id of the {@link StepExecution}
* that the attributes belongs to.
* @return attributes for the provided id. If
* none are found, an empty {@link ExecutionAttributes} will be returned.
* @param executionId - Long id of the {@link StepExecution} that the
* attributes belongs to.
* @return attributes for the provided id. If none are found, an empty
* {@link ExecutionAttributes} will be returned.
* @throws IllegalArgumentException if the id is null.
*/
ExecutionAttributes findExecutionAttributes(final Long executionId);
/**
* Save the provided {@link ExecutionAttributes} for the given
* execution Id.
* Save the provided {@link ExecutionAttributes} for the given executionId.
*
* @param executionId to be saved
* @param executionAttributes to be saved.
* @throws IllegalArgumentException if the executionId or
* attributes are null.
* @throws IllegalArgumentException if the executionId or attributes are
* null.
*/
void save(final Long executionId, final ExecutionAttributes executionAttributes);
void saveExecutionAttributes(final Long executionId, final ExecutionAttributes executionAttributes);
/**
* Update the provided execution attributes.
* Update the provided ExecutionAttributes.
*
* @param executionId
* @param executionAttributes
*/
void update(final Long executionId, ExecutionAttributes executionAttributes);
void updateExecutionAttributes(final Long executionId, ExecutionAttributes executionAttributes);
}

View File

@@ -30,19 +30,19 @@ public class MockStepDao implements StepDao {
private int currentNewStep = 0;
public StepInstance createStep(JobInstance job, String stepName) {
public StepInstance createStepInstance(JobInstance job, String stepName) {
StepInstance newStep = (StepInstance) newSteps.get(currentNewStep);
currentNewStep++;
return newStep;
}
public StepInstance findStep(JobInstance job, String stepName) {
public StepInstance findStepInstance(JobInstance job, String stepName) {
StepInstance newStep = (StepInstance) newSteps.get(currentNewStep);
currentNewStep++;
return newStep;
}
public List findSteps(JobInstance job) {
public List findStepInstances(JobInstance job) {
return newSteps;
}
@@ -50,13 +50,13 @@ public class MockStepDao implements StepDao {
return 1;
}
public void save(StepExecution stepExecution) {
public void saveStepExecution(StepExecution stepExecution) {
}
public void update(StepInstance step) {
public void updateStepInstance(StepInstance step) {
}
public void update(StepExecution stepExecution) {
public void updateStepExecution(StepExecution stepExecution) {
}
public void setStepsToReturnOnCreate(List steps) {
@@ -76,11 +76,11 @@ public class MockStepDao implements StepDao {
return null;
}
public void save(Long executionId,
public void saveExecutionAttributes(Long executionId,
ExecutionAttributes executionAttributes) {
}
public void update(Long executionId,
public void updateExecutionAttributes(Long executionId,
ExecutionAttributes executionAttributes) {
}

View File

@@ -39,7 +39,7 @@ import org.springframework.batch.execution.repository.dao.JobDao;
import org.springframework.batch.execution.repository.dao.StepDao;
import org.springframework.batch.item.ExecutionAttributes;
/*
/**
* Test SimpleJobRepository. The majority of test cases are tested using EasyMock,
* however, there were some issues with using it for the stepDao when testing finding
* or creating steps, so an actual mock class had to be written.
@@ -135,11 +135,11 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(jobExecutions);
jobDao.createJobInstance(jobConfiguration.getName(), jobParameters);
jobDaoControl.setReturnValue(databaseJob);
stepDao.createStep(databaseJob, "TestStep1");
stepDao.createStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.createStep(databaseJob, "TestStep2");
stepDao.createStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
jobDao.save(new JobExecution(databaseJob));
jobDao.saveJobExecution(new JobExecution(databaseJob));
jobDaoControl.setMatcher(new ArgumentsMatcher(){
public boolean matches(Object[] expected, Object[] actual) {
return ((JobExecution) actual[0]).getJobInstance().equals(databaseJob);
@@ -165,13 +165,13 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDao.findJobInstances(jobConfiguration.getName(), jobParameters);
jobs.add(databaseJob);
jobDaoControl.setReturnValue(jobs);
stepDao.findStep(databaseJob, "TestStep1");
stepDao.findStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.findExecutionAttributes(databaseStep1.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
stepDao.findStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
stepDao.findExecutionAttributes(databaseStep2.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
@@ -188,8 +188,8 @@ public class SimpleJobRepositoryTests extends TestCase {
// and the executions in the list contain one with an end date
execution.setEndTime(new Date(System.currentTimeMillis()));
jobDaoControl.setReturnValue(executions);
jobDao.update(databaseJob);
jobDao.save(new JobExecution(databaseJob));
jobDao.updateJobInstance(databaseJob);
jobDao.saveJobExecution(new JobExecution(databaseJob));
jobDaoControl.setMatcher(new ArgumentsMatcher(){
public boolean matches(Object[] expected, Object[] actual) {
JobExecution execution = (JobExecution) actual[0];
@@ -241,13 +241,13 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDao.findJobInstances(jobConfiguration.getName(), jobParameters);
jobs.add(databaseJob);
jobDaoControl.setReturnValue(jobs);
stepDao.findStep(databaseJob, "TestStep1");
stepDao.findStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.findExecutionAttributes(databaseStep1.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
stepDao.findStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
stepDao.findExecutionAttributes(databaseStep2.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
@@ -279,11 +279,11 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(jobs);
jobDao.createJobInstance(jobConfiguration.getName(), jobParameters);
jobDaoControl.setReturnValue(databaseJob);
stepDao.createStep(databaseJob, "TestStep1");
stepDao.createStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.createStep(databaseJob, "TestStep2");
stepDao.createStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
jobDao.save(new JobExecution(databaseJob));
jobDao.saveJobExecution(new JobExecution(databaseJob));
jobDaoControl.setMatcher(new ArgumentsMatcher(){
public boolean matches(Object[] expected, Object[] actual) {
return ((JobExecution) actual[0]).getJobInstance().equals(databaseJob);
@@ -319,7 +319,7 @@ public class SimpleJobRepositoryTests extends TestCase {
// successful update
updateJob = new JobInstance(new Long(0L), jobParameters);
jobDao.update(updateJob);
jobDao.updateJobInstance(updateJob);
jobDaoControl.replay();
jobRepository.update(updateJob);
@@ -343,14 +343,14 @@ public class SimpleJobRepositoryTests extends TestCase {
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1), jobParameters));
// new execution - call save on job dao
jobDao.save(jobExecution);
jobDao.saveJobExecution(jobExecution);
jobDaoControl.replay();
jobRepository.saveOrUpdate(jobExecution);
jobDaoControl.reset();
// update existing execution
jobExecution.setId(new Long(5));
jobDao.update(jobExecution);
jobDao.updateJobExecution(jobExecution);
jobDaoControl.replay();
jobRepository.saveOrUpdate(jobExecution);
}
@@ -370,7 +370,7 @@ public class SimpleJobRepositoryTests extends TestCase {
// successful update
step = new StepInstance(new Long(0L));
stepDao.update(step);
stepDao.updateStepInstance(step);
stepDaoControl.replay();
jobRepository.update(step);
}
@@ -380,8 +380,8 @@ public class SimpleJobRepositoryTests extends TestCase {
stepExecution.setId(new Long(11));
ExecutionAttributes executionAttributes = new ExecutionAttributes();
stepExecution.setExecutionAttributes(executionAttributes);
stepDao.update(stepExecution);
stepDao.update(stepExecution.getId(), executionAttributes);
stepDao.updateStepExecution(stepExecution);
stepDao.updateExecutionAttributes(stepExecution.getId(), executionAttributes);
stepDaoControl.replay();
jobRepository.saveOrUpdate(stepExecution);
stepDaoControl.verify();
@@ -391,8 +391,8 @@ public class SimpleJobRepositoryTests extends TestCase {
StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), null, null);
ExecutionAttributes executionAttributes = new ExecutionAttributes();
stepExecution.setExecutionAttributes(executionAttributes);
stepDao.save(stepExecution);
stepDao.save(stepExecution.getId(), executionAttributes);
stepDao.saveStepExecution(stepExecution);
stepDao.saveExecutionAttributes(stepExecution.getId(), executionAttributes);
stepDaoControl.replay();
jobRepository.saveOrUpdate(stepExecution);
stepDaoControl.verify();
@@ -424,11 +424,11 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(jobs);
jobDao.createJobInstance(jobConfiguration.getName(), jobParameters);
jobDaoControl.setReturnValue(databaseJob);
stepDao.createStep(databaseJob, "TestStep1");
stepDao.createStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.createStep(databaseJob, "TestStep2");
stepDao.createStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
jobDao.save(new JobExecution(databaseJob));
jobDao.saveJobExecution(new JobExecution(databaseJob));
jobDaoControl.setMatcher(new ArgumentsMatcher(){
public boolean matches(Object[] expected, Object[] actual) {
return ((JobExecution) actual[0]).getJobInstance().equals(databaseJob);
@@ -453,13 +453,13 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDao.findJobInstances(jobConfiguration.getName(), jobParameters);
jobs.add(databaseJob);
jobDaoControl.setReturnValue(jobs);
stepDao.findStep(databaseJob, "TestStep1");
stepDao.findStepInstance(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.findExecutionAttributes(databaseStep1.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
stepDao.findStepInstance(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
stepDao.findExecutionAttributes(databaseStep2.getLastExecution().getId());
stepDaoControl.setReturnValue(executionAttributes);
@@ -470,9 +470,9 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(1);
jobDao.findJobExecutions(databaseJob);
jobDaoControl.setReturnValue(new ArrayList());
jobDao.update(databaseJob);
jobDao.updateJobInstance(databaseJob);
jobDaoControl.setVoidCallable();
jobDao.save(new JobExecution(databaseJob));
jobDao.saveJobExecution(new JobExecution(databaseJob));
jobDaoControl.setMatcher(new ArgumentsMatcher(){
public boolean matches(Object[] expected, Object[] actual) {
return ((JobExecution) actual[0]).getJobInstance().equals(databaseJob);

View File

@@ -79,9 +79,9 @@ public abstract class AbstractJobDaoTests extends
jobExecution = new JobExecution(jobInstance);
jobExecution.setStartTime(jobExecutionStartTime);
jobExecution.setStatus(BatchStatus.STARTED);
jobDao.save(jobExecution);
jobDao.saveJobExecution(jobExecution);
jobInstance.setLastExecution(jobExecution);
jobDao.update(jobInstance);
jobDao.updateJobInstance(jobInstance);
}
public void testVersionIsNotNullForJob() throws Exception {
@@ -151,9 +151,9 @@ public abstract class AbstractJobDaoTests extends
public void testUpdateJob() {
// Update the returned job with a new status
JobExecution newExecution = new JobExecution(jobInstance);
jobDao.save(newExecution);
jobDao.saveJobExecution(newExecution);
jobInstance.setLastExecution(newExecution);
jobDao.update(jobInstance);
jobDao.updateJobInstance(jobInstance);
// The job just updated should be found, with the saved status.
List jobs = jobDao.findJobInstances(job.getName(), jobParameters);
@@ -180,7 +180,7 @@ public abstract class AbstractJobDaoTests extends
try {
JobInstance testJob = new JobInstance(null, null);
jobDao.update(testJob);
jobDao.updateJobInstance(testJob);
fail();
} catch (IllegalArgumentException ex) {
// expected
@@ -191,7 +191,7 @@ public abstract class AbstractJobDaoTests extends
JobInstance testJob = null;
try {
jobDao.update(testJob);
jobDao.updateJobInstance(testJob);
} catch (IllegalArgumentException ex) {
// expected
}
@@ -202,7 +202,7 @@ public abstract class AbstractJobDaoTests extends
jobExecution.setStatus(BatchStatus.COMPLETED);
jobExecution.setExitStatus(ExitStatus.FINISHED);
jobExecution.setEndTime(new Date(System.currentTimeMillis()));
jobDao.update(jobExecution);
jobDao.updateJobExecution(jobExecution);
List executions = jobDao.findJobExecutions(jobInstance);
assertEquals(executions.size(), 1);
@@ -222,7 +222,7 @@ public abstract class AbstractJobDaoTests extends
// id is invalid
JobExecution execution = new JobExecution(jobInstance, new Long(29432));
try {
jobDao.update(execution);
jobDao.updateJobExecution(execution);
fail("Expected NoSuchBatchDomainObjectException");
} catch (NoSuchBatchDomainObjectException ex) {
// expected
@@ -233,7 +233,7 @@ public abstract class AbstractJobDaoTests extends
JobExecution execution = new JobExecution(jobInstance);
try {
jobDao.update(execution);
jobDao.updateJobExecution(execution);
fail();
} catch (IllegalArgumentException ex) {
// expected
@@ -247,7 +247,7 @@ public abstract class AbstractJobDaoTests extends
// Save new JobExecution for same job
JobExecution testJobExecution = new JobExecution(jobInstance);
jobDao.save(testJobExecution);
jobDao.saveJobExecution(testJobExecution);
// JobExecutionCount should be incremented by 1
assertEquals(jobDao.getJobExecutionCount(jobInstance.getId()), 2);
}

View File

@@ -87,16 +87,16 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
protected void onSetUpInTransaction() throws Exception {
Job job = new JobSupport("TestJob");
jobInstance = jobDao.createJobInstance(job.getName(), jobParameters);
step1 = stepDao.createStep(jobInstance, "TestStep1");
step2 = stepDao.createStep(jobInstance, "TestStep2");
step1 = stepDao.createStepInstance(jobInstance, "TestStep1");
step2 = stepDao.createStepInstance(jobInstance, "TestStep2");
jobExecution = new JobExecution(step2.getJobInstance());
stepExecution = new StepExecution(step1, jobExecution, null);
stepExecution.setStatus(BatchStatus.STARTED);
stepExecution.setStartTime(new Date(System.currentTimeMillis()));
stepDao.save(stepExecution);
stepDao.saveStepExecution(stepExecution);
step1.setLastExecution(stepExecution);
stepDao.update(step1);
stepDao.updateStepInstance(step1);
executionAttributes = new ExecutionAttributes();
executionAttributes.putString("1", "testString1");
@@ -120,19 +120,19 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
public void testFindStepNull() {
StepInstance step = stepDao.findStep(jobInstance, "UnSavedStep");
StepInstance step = stepDao.findStepInstance(jobInstance, "UnSavedStep");
assertNull(step);
}
public void testFindStep() {
StepInstance tempStep = stepDao.findStep(jobInstance, "TestStep1");
StepInstance tempStep = stepDao.findStepInstance(jobInstance, "TestStep1");
assertEquals(tempStep, step1);
}
public void testFindSteps() {
List steps = stepDao.findSteps(jobInstance);
List steps = stepDao.findStepInstances(jobInstance);
assertEquals(steps.size(), 2);
assertTrue(steps.contains(step1));
assertTrue(steps.contains(step2));
@@ -141,28 +141,28 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
public void testFindStepsNotSaved() {
// no steps are saved for given id, empty list should be returned
List steps = stepDao.findSteps(new JobInstance(new Long(38922), jobParameters));
List steps = stepDao.findStepInstances(new JobInstance(new Long(38922), jobParameters));
assertEquals(steps.size(), 0);
}
public void testCreateStep() {
StepInstance step3 = stepDao.createStep(jobInstance, "TestStep3");
StepInstance tempStep = stepDao.findStep(jobInstance, "TestStep3");
StepInstance step3 = stepDao.createStepInstance(jobInstance, "TestStep3");
StepInstance tempStep = stepDao.findStepInstance(jobInstance, "TestStep3");
assertEquals(step3, tempStep);
}
public void testUpdateStepWithoutExecutionAttributes() {
stepDao.update(step1);
StepInstance tempStep = stepDao.findStep(jobInstance, step1.getName());
stepDao.updateStepInstance(step1);
StepInstance tempStep = stepDao.findStepInstance(jobInstance, step1.getName());
assertEquals(tempStep, step1);
}
public void testUpdateStepWithExecutionAttributes() {
stepDao.save(step1.getId(), executionAttributes);
StepInstance tempStep = stepDao.findStep(jobInstance, step1.getName());
stepDao.saveExecutionAttributes(step1.getId(), executionAttributes);
StepInstance tempStep = stepDao.findStepInstance(jobInstance, step1.getName());
ExecutionAttributes tempAttributes = stepDao.findExecutionAttributes(step1.getId());
assertEquals(tempStep, step1);
assertEquals(executionAttributes, tempAttributes);
@@ -176,7 +176,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
execution.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("key1=0,key2=5")));
execution.setExitStatus(new ExitStatus(false, ExitCodeExceptionClassifier.FATAL_EXCEPTION,
"java.lang.Exception"));
stepDao.save(execution);
stepDao.saveStepExecution(execution);
List executions = stepDao.findStepExecutions(step2);
assertEquals(1, executions.size());
StepExecution tempExecution = (StepExecution) executions.get(0);
@@ -194,7 +194,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
stepExecution.setExecutionAttributes(new ExecutionAttributes());
stepExecution.setExitStatus(new ExitStatus(false, ExitCodeExceptionClassifier.FATAL_EXCEPTION,
"java.lang.Exception"));
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
List executions = stepDao.findStepExecutions(step1);
assertEquals(1, executions.size());
StepExecution tempExecution = (StepExecution) executions.get(0);
@@ -205,7 +205,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
public void testUpdateStepExecutionWithNullId() {
StepExecution stepExecution = new StepExecution(null, null, null);
try {
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
@@ -224,13 +224,13 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
assertEquals(1, stepDao.getStepExecutionCount(step1));
StepExecution execution = new StepExecution(step1, new JobExecution(step1.getJobInstance(), new Long(123)),
null);
stepDao.save(execution);
stepDao.saveStepExecution(execution);
assertEquals(2, stepDao.getStepExecutionCount(step1));
}
public void testUpdateStepExecutionVersion() throws Exception {
int before = stepExecution.getVersion().intValue();
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
int after = stepExecution.getVersion().intValue();
assertEquals("StepExecution version not updated", before + 1, after);
}
@@ -239,7 +239,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
stepExecution.incrementVersion(); // not really allowed outside dao
// code
try {
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
fail("Expected OptimisticLockingFailureException");
}
catch (OptimisticLockingFailureException e) {
@@ -253,11 +253,11 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
public void testSaveExecutionAttributes(){
stepDao.save(stepExecution.getId(), executionAttributes);
stepDao.saveExecutionAttributes(stepExecution.getId(), executionAttributes);
ExecutionAttributes attributes = stepDao.findExecutionAttributes(stepExecution.getId());
assertEquals(executionAttributes, attributes);
executionAttributes.putString("newString", "newString");
stepDao.update(stepExecution.getId(), executionAttributes);
stepDao.updateExecutionAttributes(stepExecution.getId(), executionAttributes);
attributes = stepDao.findExecutionAttributes(stepExecution.getId());
assertEquals(executionAttributes, attributes);
}

View File

@@ -67,7 +67,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
return 1;
}
});
sqlDao.save(new JobInstance(new Long(11), new JobParameters()).createJobExecution());
sqlDao.saveJobExecution(new JobInstance(new Long(11), new JobParameters()).createJobExecution());
assertEquals(1, list.size());
String query = (String) list.get(0);
assertTrue("Query did not contain FOO_:" + query, query.indexOf("FOO_") >= 0);

View File

@@ -18,7 +18,7 @@ public class JdbcJobDaoTests extends AbstractJobDaoTests {
assertTrue(LONG_STRING.length() > 250);
jobExecution.setExitStatus(ExitStatus.FINISHED
.addExitDescription(LONG_STRING));
jobDao.update(jobExecution);
jobDao.updateJobExecution(jobExecution);
List executions = jdbcTemplate.queryForList(
"SELECT * FROM BATCH_JOB_EXECUTION where JOB_INSTANCE_ID=?",

View File

@@ -61,7 +61,7 @@ public class JdbcStepDaoPrefixTests extends TestCase {
public void testModifiedUpdateStepExecution(){
stepDao.setTablePrefix("FOO_");
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP_EXECUTION") != -1);
}
@@ -70,7 +70,7 @@ public class JdbcStepDaoPrefixTests extends TestCase {
stepExecutionIncrementer.nextLongValue();
stepExecutionIncrementerControl.setReturnValue(1);
stepExecutionIncrementerControl.replay();
stepDao.save(stepExecution);
stepDao.saveStepExecution(stepExecution);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP_EXECUTION") != -1);
}
@@ -82,7 +82,7 @@ public class JdbcStepDaoPrefixTests extends TestCase {
public void testModifiedUpdateStep(){
stepDao.setTablePrefix("FOO_");
stepDao.update(step);
stepDao.updateStepInstance(step);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP") != -1);
}
@@ -91,20 +91,20 @@ public class JdbcStepDaoPrefixTests extends TestCase {
stepIncrementer.nextLongValue();
stepIncrementerControl.setReturnValue(1);
stepIncrementerControl.replay();
stepDao.createStep(job, "test");
stepDao.createStepInstance(job, "test");
assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP") != -1);
}
public void testModifiedFindSteps(){
stepDao.setTablePrefix("FOO_");
stepDao.findSteps(new JobInstance(new Long(1), new JobParameters()));
stepDao.findStepInstances(new JobInstance(new Long(1), new JobParameters()));
assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP") != -1);
}
public void testModifiedFindStep(){
stepDao.setTablePrefix("FOO_");
try{
stepDao.findStep(job, "test");
stepDao.findStepInstance(job, "test");
}
catch(NullPointerException ex){
//It's going to throw a NullPointerException because the MockJdbcTemplate
@@ -116,7 +116,7 @@ public class JdbcStepDaoPrefixTests extends TestCase {
public void testDefaultFindStep(){
try{
stepDao.findStep(job, "test");
stepDao.findStepInstance(job, "test");
}
catch(NullPointerException ex){
//It's going to throw a NullPointerException because the MockJdbcTemplate
@@ -128,7 +128,7 @@ public class JdbcStepDaoPrefixTests extends TestCase {
}
public void testDefaultFindSteps(){
stepDao.findSteps(new JobInstance(new Long(1), new JobParameters()));
stepDao.findStepInstances(new JobInstance(new Long(1), new JobParameters()));
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP") != -1);
}
@@ -136,12 +136,12 @@ public class JdbcStepDaoPrefixTests extends TestCase {
stepIncrementer.nextLongValue();
stepIncrementerControl.setReturnValue(1);
stepIncrementerControl.replay();
stepDao.createStep(job, "test");
stepDao.createStepInstance(job, "test");
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP") != -1);
}
public void testDefaultUpdateStep(){
stepDao.update(step);
stepDao.updateStepInstance(step);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP") != -1);
}
@@ -154,12 +154,12 @@ public class JdbcStepDaoPrefixTests extends TestCase {
stepExecutionIncrementer.nextLongValue();
stepExecutionIncrementerControl.setReturnValue(1);
stepExecutionIncrementerControl.replay();
stepDao.save(stepExecution);
stepDao.saveStepExecution(stepExecution);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP_EXECUTION") != -1);
}
public void testDefaultUpdateStepExecution(){
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP_EXECUTION") != -1);
}

View File

@@ -28,7 +28,7 @@ public class JdbcStepDaoTests extends AbstractStepDaoTests {
assertTrue(LONG_STRING.length()>250);
stepExecution.setExitStatus(ExitStatus.FINISHED.addExitDescription(LONG_STRING));
stepDao.update(stepExecution);
stepDao.updateStepExecution(stepExecution);
List executions = jdbcTemplate.queryForList(
"SELECT * FROM BATCH_STEP_EXECUTION where STEP_INSTANCE_ID=?",

View File

@@ -57,20 +57,20 @@ public class MapJobDaoTests extends TestCase {
JobInstance job = dao.createJobInstance("foo", jobParameters);
JobExecution execution = new JobExecution(job);
assertNull(execution.getId());
dao.save(execution);
dao.saveJobExecution(execution);
assertNotNull(execution.getId());
}
public void testCorrectExecutionCountForExistingJob() throws Exception {
JobInstance job = dao.createJobInstance("foo", jobParameters);
dao.save(new JobExecution(job));
dao.saveJobExecution(new JobExecution(job));
assertEquals(1, dao.getJobExecutionCount(job.getId()));
}
public void testMultipleExecutionsPerExisting() throws Exception {
JobInstance job = dao.createJobInstance("foo", jobParameters);
dao.save(new JobExecution(job));
dao.saveJobExecution(new JobExecution(job));
Thread.sleep(50L); // Hack, hack, hackety, hack - job executions are not unique if created too close together!
dao.save(new JobExecution(job));
dao.saveJobExecution(new JobExecution(job));
assertEquals(2, dao.getJobExecutionCount(job.getId()));
}
@@ -78,7 +78,7 @@ public class MapJobDaoTests extends TestCase {
JobInstance jobInstance = dao.createJobInstance("foo", jobParameters);
JobExecution jobExecution = new JobExecution(jobInstance);
dao.save(jobExecution);
dao.saveJobExecution(jobExecution);
JobExecution tempExecution = dao.getJobExecution(jobExecution.getId());
assertEquals(jobExecution, tempExecution);
}
@@ -87,7 +87,7 @@ public class MapJobDaoTests extends TestCase {
JobInstance jobInstance = dao.createJobInstance("foo", jobParameters);
JobExecution jobExecution = new JobExecution(jobInstance);
dao.save(jobExecution);
dao.saveJobExecution(jobExecution);
assertNull(dao.getJobExecution(new Long(999999)));
}

View File

@@ -39,45 +39,45 @@ public class MapStepDaoTests extends TestCase {
protected void setUp() throws Exception {
MapStepDao.clear();
job = new JobInstance(new Long(jobId++), new JobParameters());
step = dao.createStep(job, "foo");
step = dao.createStepInstance(job, "foo");
}
public void testCreateUnequal() throws Exception {
StepInstance step2 = dao.createStep(job, "foo");;
StepInstance step2 = dao.createStepInstance(job, "foo");;
assertFalse(step.equals(step2));
assertFalse(step.hashCode()==step2.hashCode());
}
public void testCreateAndRetrieveSingle() throws Exception {
StepInstance result = dao.findStep(job, "foo");
StepInstance result = dao.findStepInstance(job, "foo");
assertEquals(step, result);
}
public void testCreateAndRetrieveSingleWhenMultipleStored() throws Exception {
dao.createStep(job, "bar");;
StepInstance result = dao.findStep(job, "foo");
dao.createStepInstance(job, "bar");;
StepInstance result = dao.findStepInstance(job, "foo");
assertEquals(step, result);
}
public void testCreateAndRetrieveSingleFromList() throws Exception {
List result = dao.findSteps(job);
List result = dao.findStepInstances(job);
assertTrue(result.contains(step));
}
public void testCreateAndRetrieveMultiple() throws Exception {
step = dao.createStep(job, "bar");
List result = dao.findSteps(job);
step = dao.createStepInstance(job, "bar");
List result = dao.findStepInstances(job);
assertEquals(2, result.size());
assertTrue(result.contains(step));
}
public void testFindWithEmptyResults() throws Exception {
List result = dao.findSteps(new JobInstance(new Long(22), new JobParameters()));
List result = dao.findStepInstances(new JobInstance(new Long(22), new JobParameters()));
assertEquals(0, result.size());
}
public void testFindSingleWithEmptyResults() throws Exception {
StepInstance result = dao.findStep(new JobInstance(new Long(22), new JobParameters()), "bar");
StepInstance result = dao.findStepInstance(new JobInstance(new Long(22), new JobParameters()), "bar");
assertEquals(null, result);
}
@@ -88,18 +88,18 @@ public class MapStepDaoTests extends TestCase {
public void testSaveExecutionUpdatesId() throws Exception {
StepExecution execution = new StepExecution(step, null, null);
assertNull(execution.getId());
dao.save(execution);
dao.saveStepExecution(execution);
assertNotNull(execution.getId());
}
public void testCorrectExecutionCountForExisting() throws Exception {
dao.save(new StepExecution(step, null, null));
dao.saveStepExecution(new StepExecution(step, null, null));
assertEquals(1, dao.getStepExecutionCount(step));
}
public void testOnlyOneExecutionPerStep() throws Exception {
dao.save(new StepExecution(step, null, null));
dao.save(new StepExecution(step, null, null));
dao.saveStepExecution(new StepExecution(step, null, null));
dao.saveStepExecution(new StepExecution(step, null, null));
assertEquals(2, dao.getStepExecutionCount(step));
}
@@ -110,7 +110,7 @@ public class MapStepDaoTests extends TestCase {
ExecutionAttributes executionAttributes = new ExecutionAttributes(data);
StepExecution stepExecution = new StepExecution(step, null, null);
stepExecution.setExecutionAttributes(executionAttributes);
dao.save(stepExecution);
dao.saveStepExecution(stepExecution);
StepExecution tempExecution = dao.getStepExecution(stepExecution.getId(), step);
assertEquals(tempExecution, stepExecution);
assertEquals(stepExecution.getExecutionAttributes(), tempExecution.getExecutionAttributes());