diff --git a/dictionary.txt b/dictionary.txt index 267d1ba7c..3817d44d7 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -55,3 +55,4 @@ ben overriden backport mapper +tx diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java index 51d4a5dae..817b0aa67 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java @@ -142,7 +142,7 @@ public class JobExecution extends Entity { * Register a step execution with the current job execution. */ public StepExecution createStepExecution(Step step) { - StepExecution stepExecution = new StepExecution(step, this, null); + StepExecution stepExecution = new StepExecution(step.getName(), this, null); this.stepExecutions.add(stepExecution); return stepExecution; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java index 4b2768ab0..8a923951b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java @@ -37,7 +37,7 @@ public class StepExecution extends Entity { private JobExecution jobExecution; - private Step step; + private String stepName; private BatchStatus status = BatchStatus.STARTING; @@ -69,25 +69,25 @@ public class StepExecution extends Entity { /** * Constructor with mandatory properties. * - * @param step the step to which this execution belongs + * @param stepName the step to which this execution belongs * @param jobExecution the current job execution * @param id the id of this execution */ - public StepExecution(Step step, JobExecution jobExecution, Long id) { + public StepExecution(String stepName, JobExecution jobExecution, Long id) { super(id); - Assert.notNull(step); - this.step = step; + Assert.hasLength(stepName); + this.stepName = stepName; this.jobExecution = jobExecution; } /** * Constructor that substitutes in null for the execution id * - * @param step the step to which this execution belongs + * @param stepName the step to which this execution belongs * @param jobExecution the current job execution */ - public StepExecution(Step step, JobExecution jobExecution) { - this(step, jobExecution, null); + public StepExecution(String stepName, JobExecution jobExecution) { + this(stepName, jobExecution, null); } /** @@ -211,7 +211,7 @@ public class StepExecution extends Entity { * @return the name of the step */ public String getStepName() { - return step.getName(); + return stepName; } /** @@ -232,17 +232,14 @@ public class StepExecution extends Entity { * @see org.springframework.batch.container.common.domain.Entity#equals(java.lang.Object) */ public boolean equals(Object obj) { - // TODO make sure the equality makes sense + Object jobExecutionId = getJobExecutionId(); - if (step == null && jobExecutionId == null || !(obj instanceof StepExecution) || getId() == null) { + if (jobExecutionId == null || !(obj instanceof StepExecution) || getId() == null) { return super.equals(obj); } StepExecution other = (StepExecution) obj; - if (step == null) { - return jobExecutionId.equals(other.getJobExecutionId()); - } - return step.getName().equals(other.getStepName()) - && (jobExecutionId == null || jobExecutionId.equals(other.getJobExecutionId())); + + return stepName.equals(other.getStepName()) && (jobExecutionId.equals(other.getJobExecutionId())); } /* @@ -252,12 +249,12 @@ public class StepExecution extends Entity { */ public int hashCode() { Object jobExecutionId = getJobExecutionId(); - return super.hashCode() + 31 * (step.getName() != null ? step.getName().hashCode() : 0) + 91 + return super.hashCode() + 31 * (stepName != null ? stepName.hashCode() : 0) + 91 * (jobExecutionId != null ? jobExecutionId.hashCode() : 0); } public String toString() { - return super.toString() + ", name=" + step.getName() + ", itemCount=" + itemCount + ", commitCount=" + return super.toString() + ", name=" + stepName + ", itemCount=" + itemCount + ", commitCount=" + commitCount + ", rollbackCount=" + rollbackCount; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 9898770d2..c15bc902d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -354,7 +354,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement public Object mapRow(ResultSet rs, int rowNum) throws SQLException { - StepExecution stepExecution = new StepExecution(step, jobExecution, new Long(rs.getLong(1))); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution, new Long(rs.getLong(1))); stepExecution.setStartTime(rs.getTimestamp(3)); stepExecution.setEndTime(rs.getTimestamp(4)); stepExecution.setStatus(BatchStatus.getStatus(rs.getString(5))); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java index 45ce975c6..c39c8fd0c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java @@ -33,10 +33,10 @@ import org.springframework.batch.support.PropertiesConverter; */ public class StepExecutionTests extends TestCase { - private StepExecution execution = newStepExecution(new StepSupport("stepName"), - new Long(23)); + private StepExecution execution = newStepExecution(new StepSupport("stepName"), new Long(23)); + + private StepExecution blankExecution = new StepExecution("blank", new JobExecution()); - private StepExecution blankExecution = new StepExecution(new StepSupport("blank"), new JobExecution()); /** * Test method for * {@link org.springframework.batch.core.JobExecution#JobExecution()}. @@ -50,7 +50,7 @@ public class StepExecutionTests extends TestCase { * {@link org.springframework.batch.core.JobExecution#JobExecution()}. */ public void testStepExecutionWithNullId() { - assertNull(new StepExecution(new StepSupport("stepName"), new JobExecution()).getId()); + assertNull(new StepExecution("stepName", new JobExecution()).getId()); } /** @@ -118,34 +118,37 @@ public class StepExecutionTests extends TestCase { execution.setItemCount(123); assertEquals(123, execution.getItemCount().intValue()); } - + public void testGetJobExecution() throws Exception { assertNotNull(execution.getJobExecution()); } - + public void testApplyContribution() throws Exception { StepContribution contribution = execution.createStepContribution(); contribution.incrementCommitCount(); execution.apply(contribution); assertEquals(new Integer(1), execution.getCommitCount()); } - + public void testTerminateOnly() throws Exception { assertFalse(execution.isTerminateOnly()); execution.setTerminateOnly(); assertTrue(execution.isTerminateOnly()); } - public void testToStringWithNullName() throws Exception { - String value = new StepExecution(new StepSupport(null), new JobExecution()).toString(); - assertTrue("Should contain name=null: "+value, value.indexOf("name=null")>=0); + public void testNullNameIsIllegal() throws Exception { + try { + new StepExecution(null, new JobExecution()); + fail(); + } + catch (IllegalArgumentException e) { + // expected + } } public void testToString() throws Exception { - assertTrue("Should contain item count: " + execution.toString(), - execution.toString().indexOf("item") >= 0); - assertTrue("Should contain commit count: " + execution.toString(), - execution.toString().indexOf("commit") >= 0); + assertTrue("Should contain item count: " + execution.toString(), execution.toString().indexOf("item") >= 0); + assertTrue("Should contain commit count: " + execution.toString(), execution.toString().indexOf("commit") >= 0); assertTrue("Should contain rollback count: " + execution.toString(), execution.toString().indexOf("rollback") >= 0); } @@ -154,7 +157,7 @@ public class StepExecutionTests extends TestCase { assertNotNull(execution.getExecutionContext()); ExecutionContext context = new ExecutionContext(); context.putString("foo", "bar"); - execution.setExecutionContext(context ); + execution.setExecutionContext(context); assertEquals("bar", execution.getExecutionContext().getString("foo")); } @@ -204,14 +207,12 @@ public class StepExecutionTests extends TestCase { } public void testHashCode() throws Exception { - assertTrue("Hash code same as parent", new Entity(execution.getId()) - .hashCode() != execution.hashCode()); + assertTrue("Hash code same as parent", new Entity(execution.getId()).hashCode() != execution.hashCode()); } public void testHashCodeWithNullIds() throws Exception { - assertTrue("Hash code not same as parent", - new Entity(execution.getId()).hashCode() != blankExecution - .hashCode()); + assertTrue("Hash code not same as parent", new Entity(execution.getId()).hashCode() != blankExecution + .hashCode()); } public void testHashCodeViaHashSet() throws Exception { @@ -224,7 +225,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")); - StepExecution execution = new StepExecution(step, new JobExecution(job, long2), new Long(4)); + StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, long2), new Long(4)); return execution; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java index 3e580794d..88f1ebe3d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java @@ -115,8 +115,8 @@ public class SimpleJobTests extends TestCase { jobExecution = jobRepository.createJobExecution(job, jobParameters); jobInstance = jobExecution.getJobInstance(); - stepExecution1 = new StepExecution(step1, jobExecution, null); - stepExecution2 = new StepExecution(step2, jobExecution, null); + stepExecution1 = new StepExecution(step1.getName(), jobExecution, null); + stepExecution2 = new StepExecution(step2.getName(), jobExecution, null); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java index c5a268cc1..7b85086cf 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java @@ -22,9 +22,6 @@ import junit.framework.TestCase; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; -import org.springframework.batch.core.listener.CompositeStepExecutionListener; -import org.springframework.batch.core.listener.StepExecutionListenerSupport; -import org.springframework.batch.core.step.StepSupport; import org.springframework.batch.repeat.ExitStatus; /** @@ -82,7 +79,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { list.add("foo"); } }); - listener.beforeStep(new StepExecution(new StepSupport("foo"), null)); + listener.beforeStep(new StepExecution("foo", null)); assertEquals(1, list.size()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepDaoTests.java index 915e2e809..b2781ea8c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepDaoTests.java @@ -94,7 +94,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour jobExecution = new JobExecution(jobInstance); jobExecutionDao.saveJobExecution(jobExecution); - stepExecution = new StepExecution(step1, jobExecution, new Long(1)); + stepExecution = new StepExecution(step1.getName(), jobExecution, new Long(1)); stepExecution.setStatus(BatchStatus.STARTED); stepExecution.setStartTime(new Date(System.currentTimeMillis())); stepExecutionDao.saveStepExecution(stepExecution); @@ -122,7 +122,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour } public void testSaveStepExecution() { - StepExecution execution = new StepExecution(step2, jobExecution, null); + StepExecution execution = new StepExecution(step2.getName(), jobExecution, null); execution.setStatus(BatchStatus.STARTED); execution.setStartTime(new Date(System.currentTimeMillis())); execution.setExitStatus(ExitStatus.FAILED.addExitDescription("java.lang.Exception")); @@ -134,7 +134,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour } public void testSaveStepExecutionAndExecutionContext() { - StepExecution execution = new StepExecution(step2, jobExecution, null); + StepExecution execution = new StepExecution(step2.getName(), jobExecution, null); execution.setStatus(BatchStatus.STARTED); execution.setStartTime(new Date(System.currentTimeMillis())); execution.setExecutionContext(executionContext); @@ -165,7 +165,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour } public void testUpdateStepExecutionWithNullId() { - StepExecution stepExecution = new StepExecution(new StepSupport("testStep"), null, null); + StepExecution stepExecution = new StepExecution("testStep", null, null); try { stepExecutionDao.updateStepExecution(stepExecution); fail("Expected IllegalArgumentException"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java index 4118dffda..3bc47b204 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java @@ -67,7 +67,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona jobExecution = repository.createJobExecution(new JobSupport("testJob"), new JobParameters()); jobInstance = jobExecution.getJobInstance(); step = new StepSupport("foo"); - stepExecution = new StepExecution(step, jobExecution); + stepExecution = new StepExecution(step.getName(), jobExecution); dao = getStepExecutionDao(); } @@ -179,10 +179,10 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona public void testConcurrentModificationException() { step = new StepSupport("foo"); - StepExecution exec1 = new StepExecution(step, jobExecution); + StepExecution exec1 = new StepExecution(step.getName(), jobExecution); dao.saveStepExecution(exec1); - StepExecution exec2 = new StepExecution(step, jobExecution); + StepExecution exec2 = new StepExecution(step.getName(), jobExecution); exec2.setId(exec1.getId()); exec2.incrementVersion(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryIntegrationTests.java index 1c03227e7..8a8359018 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryIntegrationTests.java @@ -126,7 +126,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa // first execution JobExecution firstJobExec = jobRepository.createJobExecution(job, jobParameters); - StepExecution firstStepExec = new StepExecution(step, firstJobExec); + StepExecution firstStepExec = new StepExecution(step.getName(), firstJobExec); jobRepository.saveOrUpdate(firstJobExec); jobRepository.saveOrUpdate(firstStepExec); @@ -145,7 +145,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa // second execution JobExecution secondJobExec = jobRepository.createJobExecution(job, jobParameters); - StepExecution secondStepExec = new StepExecution(step, secondJobExec); + StepExecution secondStepExec = new StepExecution(step.getName(), secondJobExec); jobRepository.saveOrUpdate(secondJobExec); jobRepository.saveOrUpdate(secondStepExec); @@ -164,7 +164,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa }; JobExecution jobExec = jobRepository.createJobExecution(job, jobParameters); Step step = new StepSupport("step1"); - StepExecution stepExec = new StepExecution(step, jobExec); + StepExecution stepExec = new StepExecution(step.getName(), jobExec); stepExec.setExecutionContext(ctx); jobRepository.saveOrUpdate(stepExec); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java index b0e8b4ca0..3d4d960f4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java @@ -143,7 +143,7 @@ public class SimpleJobRepositoryTests extends TestCase { public void testSaveOrUpdateStepExecutionException() { - StepExecution stepExecution = new StepExecution(new StepSupport("stepName"), null, null); + StepExecution stepExecution = new StepExecution("stepName", null, null); // failure scenario -- no step id set. try { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JdbcCursorItemReaderPreparedStatementIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JdbcCursorItemReaderPreparedStatementIntegrationTests.java index 8b4973bea..4dbb1e084 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JdbcCursorItemReaderPreparedStatementIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/JdbcCursorItemReaderPreparedStatementIntegrationTests.java @@ -9,7 +9,6 @@ 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.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.database.JdbcCursorItemReader; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -37,7 +36,7 @@ public class JdbcCursorItemReaderPreparedStatementIntegrationTests extends 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()); JobExecution jobExecution = new JobExecution(jobInstance, new Long(2)); - StepExecution stepExecution = new StepExecution(new TaskletStep(), jobExecution, new Long(3) ); + StepExecution stepExecution = new StepExecution("taskletStep", jobExecution, new Long(3) ); pss.beforeStep(stepExecution); List parameterNames = new ArrayList(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java index 334a10505..a7939b8c2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionPreparedStatementSetterTests.java @@ -26,7 +26,6 @@ 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.core.step.tasklet.TaskletStep; import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -50,7 +49,7 @@ public class StepExecutionPreparedStatementSetterTests extends AbstractTransacti 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()); JobExecution jobExecution = new JobExecution(jobInstance, new Long(2)); - stepExecution = new StepExecution(new TaskletStep(), jobExecution, new Long(3) ); + stepExecution = new StepExecution("taskletStep", jobExecution, new Long(3) ); pss.beforeStep(stepExecution); jdbcTemplate = getJdbcTemplate(); } 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 0b6ed6c96..6f74ef783 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 @@ -30,13 +30,17 @@ public class AbstractStepTests extends TestCase { */ final List events = new ArrayList(); - final StepExecution execution = new StepExecution(tested, new JobExecution(new JobInstance(new Long(1), + final StepExecution execution = new StepExecution(tested.getName(), new JobExecution(new JobInstance(new Long(1), new JobParameters(), new JobSupport()))); /** * Fills the events list when abstract methods are called. */ private class EventTrackingStep extends AbstractStep { + + public EventTrackingStep() { + setBeanName("eventTrackingStep"); + } protected void open(ExecutionContext ctx) throws Exception { events.add("open"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicyTests.java index 254a0c1ec..0f1f04d9c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicyTests.java @@ -27,7 +27,7 @@ import org.springframework.batch.core.StepExecution; public class ThreadStepInterruptionPolicyTests extends TestCase { ThreadStepInterruptionPolicy policy = new ThreadStepInterruptionPolicy(); - private StepExecution context = new StepExecution(new StepSupport(), null); + private StepExecution context = new StepExecution("stepSupport", null); /** * Test method for {@link org.springframework.batch.core.step.ThreadStepInterruptionPolicy#checkInterrupted(StepExecution)}. diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java index 48adb486e..ae7589e75 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java @@ -117,7 +117,7 @@ public class ItemOrientedStepTests extends TestCase { public void testStepExecutor() throws Exception { JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); itemOrientedStep.execute(stepExecution); assertEquals(1, processed.size()); @@ -134,7 +134,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); StepContribution contribution = stepExecution.createStepContribution(); itemOrientedStep.processChunk(stepExecution, contribution); assertEquals(1, processed.size()); @@ -150,7 +150,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setJobRepository(repository); JobExecution jobExecution = repository.createJobExecution(jobInstance.getJob(), jobInstance.getJobParameters()); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.execute(stepExecution); assertEquals(1, processed.size()); @@ -175,7 +175,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); try { itemOrientedStep.execute(stepExecution); @@ -205,7 +205,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); try { itemOrientedStep.execute(stepExecution); @@ -240,7 +240,7 @@ public class ItemOrientedStepTests extends TestCase { } }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); try { itemOrientedStep.execute(stepExecution); @@ -262,7 +262,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(tasklet, itemWriter)); itemOrientedStep.registerStream(tasklet); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); itemOrientedStep.execute(stepExecution); @@ -272,7 +272,7 @@ public class ItemOrientedStepTests extends TestCase { public void testSuccessfulExecutionWithExecutionContext() throws Exception { final JobExecution jobExecution = new JobExecution(jobInstance); - final StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + final StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.setJobRepository(new JobRepositorySupport() { public void saveOrUpdateExecutionContext(StepExecution stepExecution) { list.add(stepExecution); @@ -288,7 +288,7 @@ public class ItemOrientedStepTests extends TestCase { public void testSuccessfulExecutionWithFailureOnSaveOfExecutionContext() throws Exception { final JobExecution jobExecution = new JobExecution(jobInstance); - final StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + final StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.setJobRepository(new JobRepositorySupport() { private int counter = 0; @@ -320,7 +320,7 @@ public class ItemOrientedStepTests extends TestCase { MockRestartableItemReader tasklet = new MockRestartableItemReader(); itemOrientedStep.setItemHandler(new SimpleItemHandler(tasklet, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); try { itemOrientedStep.execute(stepExecution); @@ -344,7 +344,7 @@ public class ItemOrientedStepTests extends TestCase { } }, itemWriter)); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.execute(stepExecution); } @@ -363,7 +363,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); itemOrientedStep.registerStream(reader); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); @@ -381,7 +381,7 @@ public class ItemOrientedStepTests extends TestCase { } } }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); @@ -402,7 +402,7 @@ public class ItemOrientedStepTests extends TestCase { } }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.execute(stepExecution); assertEquals(2, list.size()); } @@ -419,7 +419,7 @@ public class ItemOrientedStepTests extends TestCase { }; itemOrientedStep.setStreams(new ItemStream[] { reader }); itemOrientedStep.registerStepExecutionListener(reader); - StepExecution stepExecution = new StepExecution(itemOrientedStep, new JobExecution(jobInstance)); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); itemOrientedStep.execute(stepExecution); assertEquals(1, list.size()); } @@ -440,7 +440,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setStepOperations(stepTemplate); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); itemOrientedStep.execute(stepExecution); assertEquals(1, list.size()); ExitStatus returnedStatus = stepExecution.getExitStatus(); @@ -461,7 +461,7 @@ public class ItemOrientedStepTests extends TestCase { } }, itemWriter)); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); try { itemOrientedStep.execute(stepExecution); fail("Expected RuntimeException"); @@ -485,7 +485,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); itemOrientedStep.setStreams(new ItemStream[] { reader }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecution); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); @@ -525,7 +525,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); @@ -551,7 +551,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); // step.setLastExecution(stepExecution); @@ -578,7 +578,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); // step.setLastExecution(stepExecution); @@ -611,7 +611,7 @@ public class ItemOrientedStepTests extends TestCase { }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); // step.setLastExecution(stepExecution); @@ -639,7 +639,7 @@ public class ItemOrientedStepTests extends TestCase { }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); // step.setLastExecution(stepExecution); @@ -671,7 +671,7 @@ public class ItemOrientedStepTests extends TestCase { }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); try { itemOrientedStep.execute(stepExecution); @@ -702,7 +702,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.registerStream(itemReader); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); // step.setLastExecution(stepExecution); @@ -738,7 +738,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); itemOrientedStep.registerStream(reader); - StepExecution stepExecution = new StepExecution(itemOrientedStep, new JobExecution(jobInstance)); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); try { itemOrientedStep.execute(stepExecution); @@ -761,7 +761,7 @@ public class ItemOrientedStepTests extends TestCase { itemOrientedStep.setStepOperations(template); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep, jobExecutionContext); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); itemOrientedStep.execute(stepExecution); assertEquals(3, processed.size()); @@ -780,7 +780,7 @@ public class ItemOrientedStepTests extends TestCase { } }; itemOrientedStep.setStepExecutionListeners(new StepExecutionListener[] { listener }); - StepExecution stepExecution = new StepExecution(itemOrientedStep, new JobExecution(jobInstance)); + StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); try { itemOrientedStep.execute(stepExecution); fail(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java index 8293e397c..79c817bbf 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java @@ -49,6 +49,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { new JobSupport("job"))); protected void setUp() throws Exception { + factory.setBeanName("RepeatOperationsStep"); factory.setItemReader(new ListItemReader(new ArrayList())); factory.setItemWriter(new EmptyItemWriter()); factory.setJobRepository(new JobRepositorySupport()); @@ -80,7 +81,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { }); Step step = (Step) factory.getObject(); - step.execute(new StepExecution(step, jobExecution)); + step.execute(new StepExecution(step.getName(), jobExecution)); assertEquals(1, list.size()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBeanTests.java index 85cbfbf81..41be985ab 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBeanTests.java @@ -52,6 +52,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { protected int count; protected void setUp() throws Exception { + factory.setBeanName("stepName"); factory.setJobRepository(new JobRepositorySupport()); factory.setTransactionManager(new ResourcelessTransactionManager()); factory.setCommitInterval(COMMIT_INTERVAL); @@ -70,7 +71,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { public void testSkip() throws Exception { AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.execute(stepExecution); assertEquals(2, stepExecution.getSkipCount()); @@ -97,7 +98,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { }); AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); try { step.execute(stepExecution); @@ -117,7 +118,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); try { step.execute(stepExecution); @@ -152,7 +153,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); try { step.execute(stepExecution); @@ -244,7 +245,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase { factory.setItemReader(provider); AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.execute(stepExecution); assertEquals(1, stepExecution.getSkipCount()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java index 8a81e6c06..d7a024964 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java @@ -124,7 +124,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { factory.setRetryLimit(10); AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.execute(stepExecution); assertEquals(0, stepExecution.getSkipCount()); @@ -151,7 +151,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { factory.setRetryLimit(10); AbstractStep step = (AbstractStep) factory.getObject(); - StepExecution stepExecution = new StepExecution(step, jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.execute(stepExecution); assertEquals(2, stepExecution.getSkipCount()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java index 5f207b5e7..9c4f0e3b9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java @@ -72,7 +72,7 @@ public class StepExecutorInterruptionTests extends TestCase { return null; } }, itemWriter)); - stepExecution = new StepExecution(step, jobExecution); + stepExecution = new StepExecution(step.getName(), jobExecution); } public void testInterruptChunk() throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index 599934215..cf3070dc3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -16,7 +16,6 @@ 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.core.step.StepSupport; import org.springframework.batch.repeat.ExitStatus; public class TaskletStepTests extends TestCase { @@ -26,7 +25,7 @@ public class TaskletStepTests extends TestCase { private List list = new ArrayList(); protected void setUp() throws Exception { - stepExecution = new StepExecution(new StepSupport("stepName"), new JobExecution(new JobInstance(new Long(0L), + stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(new Long(0L), new JobParameters(), new JobSupport("testJob")), new Long(12))); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java index f2fb02c89..1a7b4037b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java @@ -7,7 +7,6 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.sample.item.writer.StagingItemWriter; import org.springframework.batch.sample.tasklet.JobSupport; -import org.springframework.batch.sample.tasklet.StepSupport; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.util.ClassUtils; @@ -32,12 +31,13 @@ public class StagingItemReaderTests extends AbstractTransactionalDataSourceSprin "staging-test-context.xml") }; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpBeforeTransaction() */ protected void onSetUpBeforeTransaction() throws Exception { - StepExecution stepExecution = new StepExecution(new StepSupport("stepName"), - new JobExecution(new JobInstance(jobId, new JobParameters(), new JobSupport("testJob")))); + StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(jobId, + new JobParameters(), new JobSupport("testJob")))); reader.beforeStep(stepExecution); writer.beforeStep(stepExecution); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/StagingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/StagingItemWriterTests.java index b2a4f4732..3d87c8f36 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/StagingItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/StagingItemWriterTests.java @@ -20,7 +20,6 @@ import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.sample.tasklet.JobSupport; -import org.springframework.batch.sample.tasklet.StepSupport; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.util.ClassUtils; @@ -37,12 +36,13 @@ public class StagingItemWriterTests extends AbstractTransactionalDataSourceSprin "staging-test-context.xml") }; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpBeforeTransaction() */ protected void onSetUpBeforeTransaction() throws Exception { - StepExecution stepExecution = new StepExecution(new StepSupport("stepName"), - new JobExecution(new JobInstance(new Long(12L), new JobParameters(), new JobSupport("testJob")))); + StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(new Long(12L), + new JobParameters(), new JobSupport("testJob")))); writer.beforeStep(stepExecution); }