IN PROGRESS - issue BATCH-546: pull duplicates from TaskletStep and ItemOrientedStep into AbstractStep

pulled up listener registration to AbstractStep
This commit is contained in:
robokaso
2008-04-03 09:08:41 +00:00
parent e9f8dca87e
commit 986baed232
7 changed files with 94 additions and 69 deletions

View File

@@ -174,7 +174,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
throw new RuntimeException("Foo");
}
});
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
job.setSteps(Collections.singletonList(step));
JobExecution jobExecution = repository.createJobExecution(job, new JobParameters());
@@ -210,7 +210,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
factory.setListeners(new StepListener[]{ chunkListener });
factory.setCommitInterval(commitInterval);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
job.setSteps(Collections.singletonList(step));

View File

@@ -13,6 +13,7 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.skip.SkipLimitExceededException;
import org.springframework.batch.item.ClearFailedException;
@@ -63,7 +64,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
* Check items causing errors are skipped as expected.
*/
public void testSkip() throws Exception {
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = new StepExecution(step, jobExecution);
step.execute(stepExecution);
@@ -91,7 +92,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
}
});
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = new StepExecution(step, jobExecution);
try {
@@ -110,7 +111,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
factory.setSkipLimit(1);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = new StepExecution(step, jobExecution);
@@ -145,7 +146,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
factory.setItemReader(reader);
factory.setSkippableExceptionClasses(new Class[] { Exception.class });
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = new StepExecution(step, jobExecution);
@@ -179,7 +180,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
factory.setSkipLimit(4);
factory.setItemReader(reader);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = jobExecution.createStepExecution(step);
@@ -206,7 +207,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
factory.setItemReader(reader);
factory.setItemWriter(writer);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
StepExecution stepExecution = jobExecution.createStepExecution(step);

View File

@@ -32,6 +32,7 @@ import org.springframework.batch.core.repository.dao.MapJobExecutionDao;
import org.springframework.batch.core.repository.dao.MapJobInstanceDao;
import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.batch.item.AbstractItemWriter;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemRecoverer;
@@ -119,7 +120,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
};
factory.setItemReader(provider);
factory.setRetryLimit(10);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();
AbstractStep step = (AbstractStep) factory.getObject();
step.execute(new StepExecution(step, jobExecution));
}

View File

@@ -6,19 +6,17 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.StepSupport;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.core.step.tasklet.TaskletStep;
import org.springframework.batch.repeat.ExitStatus;
public class TaskletStepTests extends TestCase {
@@ -109,7 +107,7 @@ public class TaskletStepTests extends TestCase {
public void testSuccessfulExecutionWithListener() throws Exception {
TaskletStep step = new TaskletStep(new StubTasklet(false, false), new JobRepositorySupport());
step.setStepListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
public void beforeStep(StepExecution context) {
list.add("open");
}
@@ -186,7 +184,7 @@ public class TaskletStepTests extends TestCase {
throw new RuntimeException("exception thrown in afterStep to signal failure");
}
};
step.setStepListeners(new StepExecutionListener[] { listener });
step.setStepExecutionListeners(new StepExecutionListener[] { listener });
try {
step.execute(stepExecution);
fail();