OPEN - issue BATCH-814: JobRepository should not require Step or Job (only their names)

Fixed the step execution methods (not job execution yet)
This commit is contained in:
dsyer
2008-09-04 15:01:28 +00:00
parent 783dcef9ce
commit 4726eeaa77
13 changed files with 63 additions and 59 deletions

View File

@@ -19,7 +19,6 @@ import junit.framework.TestCase;
import org.springframework.batch.core.Job;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.ClassUtils;
/**
@@ -31,12 +30,12 @@ public class ClassPathXmlApplicationContextFactoryTests extends TestCase {
private ClassPathXmlApplicationContextFactory factory = new ClassPathXmlApplicationContextFactory();
public void testCreateJob() {
factory.setPath(new Resource[] {new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml"))});
factory.setPath(new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml")));
assertNotNull(factory.createApplicationContext());
}
public void testGetJobName() {
factory.setPath(new Resource[] {new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml"))});
factory.setPath(new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml")));
assertEquals("test-job", factory.createApplicationContext().getBeanNamesForType(Job.class)[0]);
}

View File

@@ -123,8 +123,8 @@ public class SimpleJobRepositoryIntegrationTests {
jobRepository.update(firstJobExec);
jobRepository.add(firstStepExec);
assertEquals(1, jobRepository.getStepExecutionCount(firstJobExec.getJobInstance(), step));
assertEquals(firstStepExec, jobRepository.getLastStepExecution(firstJobExec.getJobInstance(), step));
assertEquals(1, jobRepository.getStepExecutionCount(firstJobExec.getJobInstance(), step.getName()));
assertEquals(firstStepExec, jobRepository.getLastStepExecution(firstJobExec.getJobInstance(), step.getName()));
// first execution failed
firstJobExec.setStartTime(new Date(4));
@@ -142,8 +142,8 @@ public class SimpleJobRepositoryIntegrationTests {
jobRepository.update(secondJobExec);
jobRepository.add(secondStepExec);
assertEquals(2, jobRepository.getStepExecutionCount(secondJobExec.getJobInstance(), step));
assertEquals(secondStepExec, jobRepository.getLastStepExecution(secondJobExec.getJobInstance(), step));
assertEquals(2, jobRepository.getStepExecutionCount(secondJobExec.getJobInstance(), step.getName()));
assertEquals(secondStepExec, jobRepository.getLastStepExecution(secondJobExec.getJobInstance(), step.getName()));
}
/*
@@ -166,7 +166,7 @@ public class SimpleJobRepositoryIntegrationTests {
jobRepository.add(stepExec);
jobRepository.updateExecutionContext(stepExec);
StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step);
StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step.getName());
assertEquals(stepExec, retrievedStepExec);
assertEquals(ctx, retrievedStepExec.getExecutionContext());

View File

@@ -19,7 +19,6 @@ import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
@@ -48,11 +47,11 @@ public class JobRepositorySupport implements JobRepository {
public void update(JobInstance job) {
}
public StepExecution getLastStepExecution(JobInstance jobInstance, Step step) {
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) {
return null;
}
public int getStepExecutionCount(JobInstance jobInstance, Step step) {
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
return 0;
}

View File

@@ -141,7 +141,7 @@ public class ChunkOrientedStepIntegrationTests {
catch (RuntimeException e) {
assertEquals(BatchStatus.UNKNOWN, stepExecution.getStatus());
StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobExecution.getJobInstance(), step);
StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobExecution.getJobInstance(), step.getName());
assertEquals(lastStepExecution, stepExecution);
assertFalse(lastStepExecution == stepExecution);