From e8a02b01a15eb227db43b3d76b2c2f26cf7c3859 Mon Sep 17 00:00:00 2001 From: robokaso Date: Tue, 14 Oct 2008 15:31:33 +0000 Subject: [PATCH] RESOLVED - BATCH-857: map daos need to be truly transactional for correct restart some more tests --- .../dao/MapExecutionContextDaoTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java index f3178f693..af04972ae 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java @@ -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()); + } }