From 20c9540c67d44e7d31c6e3b9819c1f9226d51b4a Mon Sep 17 00:00:00 2001 From: dsyer Date: Thu, 4 Jun 2009 16:40:50 +0000 Subject: [PATCH] RESOLVED - issue BATCH-1272: Write skips do not work in a multi-threaded step Fix problems with test case? --- .../context/StepContextRepeatCallbackTests.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java index 62abfa53a..48cec9dfc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextRepeatCallbackTests.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue; import java.util.concurrent.CountDownLatch; +import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Test; @@ -89,14 +90,17 @@ public class StepContextRepeatCallbackTests { @Test public void testUnfinishedWork() throws Exception { StepSynchronizationManager.register(stepExecution); - final CountDownLatch latch = new CountDownLatch(1); + final CountDownLatch background = new CountDownLatch(1); + final CountDownLatch foreground = new CountDownLatch(1); final StepContextRepeatCallback callback = new StepContextRepeatCallback(stepExecution) { + private Log logger = LogFactory.getLog(getClass()); @Override public RepeatStatus doInChunkContext(RepeatContext context, ChunkContext chunkContext) throws Exception { + foreground.countDown(); if (context==null) { - LogFactory.getLog(getClass()).debug("Waiting for latch"); - latch.await(); - LogFactory.getLog(getClass()).debug("Released"); + logger.debug("Waiting for latch"); + background.await(); + logger.debug("Released"); } return RepeatStatus.FINISHED; } @@ -111,8 +115,9 @@ public class StepContextRepeatCallbackTests { } } }).start(); + foreground.await(); assertEquals(RepeatStatus.CONTINUABLE, callback.doInIteration(new RepeatContextSupport(null))); - latch.countDown(); + background.countDown(); } }