Copying and pasting StepLocatorStepFactoryBean from spring-batch-admin and adding a-probably-overkill unit test for it.

This commit is contained in:
Tom Vaughan
2012-09-21 16:53:36 -04:00
parent d0e0334674
commit 78d8863748
2 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
package org.springframework.batch.core.step;
import org.junit.Test;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.SimpleJob;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Tests for StepLocatorStepFactoryBean.
*
* @author tvaughan
*/
public class StepLocatorStepFactoryBeanTests {
@Test
public void testFoo() throws Exception {
Step testStep1 = buildTestStep("foo");
Step testStep2 = buildTestStep("bar");
Step testStep3 = buildTestStep("baz");
SimpleJob simpleJob = new SimpleJob(); // is a StepLocator
simpleJob.addStep(testStep1);
simpleJob.addStep(testStep2);
simpleJob.addStep(testStep3);
StepLocatorStepFactoryBean stepLocatorStepFactoryBean = new StepLocatorStepFactoryBean();
stepLocatorStepFactoryBean.setStepLocator(simpleJob);
stepLocatorStepFactoryBean.setStepName("bar");
assertEquals(testStep2, stepLocatorStepFactoryBean.getObject());
}
private Step buildTestStep(final String stepName) {
return new Step() {
public String getName() {
return stepName;
}
public boolean isAllowStartIfComplete() {
throw new UnsupportedOperationException("Not supported yet.");
}
public int getStartLimit() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void execute(StepExecution stepExecution) throws JobInterruptedException {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
@Test
public void testGetObjectType() {
assertTrue((new StepLocatorStepFactoryBean()).getObjectType().isAssignableFrom(Step.class));
}
}