IN PROGRESS - BATCH-857: map daos need to be truly transactional for correct restart

added cloning to step and execution context map daos
This commit is contained in:
robokaso
2008-10-14 15:05:32 +00:00
parent 5887005d0d
commit b8b734d69c
5 changed files with 60 additions and 8 deletions

View File

@@ -483,6 +483,8 @@ public class SimpleJobTests extends TestCase {
}
stepExecution.setExitStatus(ExitStatus.FINISHED);
stepExecution.setStatus(BatchStatus.COMPLETED);
jobRepository.update(stepExecution);
jobRepository.updateExecutionContext(stepExecution);
}

View File

@@ -35,6 +35,10 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
JobExecution retrieved = tested.getJobExecution(jobExecution.getId());
assertNull(retrieved.getStartTime());
tested.updateJobExecution(jobExecution);
jobExecution.setEndTime(new Date());
assertNull(retrieved.getEndTime());
}
}

View File

@@ -1,7 +1,14 @@
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import java.util.Date;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.internal.runners.JUnit4ClassRunner;
@@ -19,5 +26,29 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(),
new MapExecutionContextDao());
}
/**
* Modifications to saved entity do not affect the persisted object.
*/
@Test
public void testPersistentCopy() {
StepExecutionDao tested = new MapStepExecutionDao();
JobExecution jobExecution = new JobExecution((long) 77);
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
assertNull(stepExecution.getEndTime());
tested.saveStepExecution(stepExecution);
stepExecution.setEndTime(new Date());
StepExecution retrieved = tested.getStepExecution(jobExecution, "stepName");
assertNull(retrieved.getEndTime());
stepExecution.setEndTime(null);
tested.updateStepExecution(stepExecution);
stepExecution.setEndTime(new Date());
StepExecution stored = tested.getStepExecution(jobExecution, "stepName");
assertNull(stored.getEndTime());
}
}