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

added serialization-based cloning to MapJobExecutionDao
This commit is contained in:
robokaso
2008-10-14 14:02:37 +00:00
parent 2abeefba71
commit 5887005d0d
2 changed files with 54 additions and 14 deletions

View File

@@ -1,7 +1,15 @@
package org.springframework.batch.core.repository.dao;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import static org.junit.Assert.*;
@RunWith(JUnit4ClassRunner.class)
public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@@ -12,4 +20,21 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
return new MapJobExecutionDao();
}
/**
* Modifications to saved entity do not affect the persisted object.
*/
@Test
public void testPersistentCopy() {
JobExecutionDao tested = new MapJobExecutionDao();
JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, new JobParameters(), "mapJob"));
assertNull(jobExecution.getStartTime());
tested.saveJobExecution(jobExecution);
jobExecution.setStartTime(new Date());
JobExecution retrieved = tested.getJobExecution(jobExecution.getId());
assertNull(retrieved.getStartTime());
}
}