diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java index f6ec5a3d6..83082c24c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java @@ -13,6 +13,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; +import org.springframework.util.Assert; /** * Tests for {@link AbstractStep}. @@ -103,11 +104,23 @@ public class AbstractStepTests extends TestCase { private static class JobRepositoryStub extends JobRepositorySupport { ExecutionContext saved = new ExecutionContext(); + + static long counter = 0; public void persistExecutionContext(StepExecution stepExecution) { + Assert.state(stepExecution.getId() != null, "StepExecution must already be saved"); saved = stepExecution.getExecutionContext(); } + @Override + public void save(StepExecution stepExecution) { + if (stepExecution.getId() == null) { + stepExecution.setId(counter); + counter++; + } + } + + } protected void setUp() throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java index d06741192..06be8e89d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java @@ -42,12 +42,6 @@ public class JobRepositorySupport implements JobRepository { public void update(JobExecution jobExecution) { } - /* (non-Javadoc) - * @see org.springframework.batch.container.common.repository.JobRepository#saveOrUpdate(org.springframework.batch.container.common.domain.StepExecution) - */ - public void saveOrUpdate(StepExecution stepExecution) { - } - /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#update(org.springframework.batch.container.common.domain.Job) */