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

some more tests
This commit is contained in:
robokaso
2008-10-14 15:31:33 +00:00
parent b8b734d69c
commit e8a02b01a1

View File

@@ -1,7 +1,13 @@
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.ExecutionContext;
/**
* Tests for {@link MapExecutionContextDao}.
@@ -31,6 +37,25 @@ public class MapExecutionContextDaoTests extends AbstractExecutionContextDaoTest
protected ExecutionContextDao getExecutionContextDao() {
return new MapExecutionContextDao();
}
@Test
public void testPersistentCopy() throws Exception {
MapExecutionContextDao tested = new MapExecutionContextDao();
JobExecution jobExecution = new JobExecution((long)1);
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
assertTrue(stepExecution.getExecutionContext().isEmpty());
tested.persistExecutionContext(stepExecution);
stepExecution.getExecutionContext().put("key","value");
ExecutionContext retrieved = tested.getExecutionContext(stepExecution);
assertTrue(retrieved.isEmpty());
tested.persistExecutionContext(jobExecution);
jobExecution.getExecutionContext().put("key", "value");
retrieved = tested.getExecutionContext(jobExecution);
assertTrue(retrieved.isEmpty());
}
}