From 43d9e98f0054ebf58b7853e45700791ef1f07265 Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 20 Mar 2009 10:30:10 +0000 Subject: [PATCH] Try to fix timout error in build --- .../batch/repeat/jms/AsynchronousTests.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java index 9ddcda0a8..22edf4f2a 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java @@ -95,7 +95,7 @@ public class AsynchronousTests { } } - List list = new ArrayList(); + private volatile List list = new ArrayList(); private void assertInitialState() { int count = simpleJdbcTemplate.queryForInt("select count(*) from T_FOOS"); @@ -120,7 +120,7 @@ public class AsynchronousTests { container.start(); // Need to sleep for at least a second here... - Thread.sleep(1000L); + waitFor(list,2,2000); System.err.println(simpleJdbcTemplate.queryForList("select * from T_FOOS")); @@ -161,7 +161,7 @@ public class AsynchronousTests { // Need to sleep here, but not too long or the // container goes into its own recovery cycle and spits out the bad // message... - Thread.sleep(1000L); + waitFor(list,2,2000); container.stop(); @@ -182,4 +182,17 @@ public class AsynchronousTests { } + /** + * @param list + * @param timeout + * @throws InterruptedException + */ + private void waitFor(List list, int size, int timeout) throws InterruptedException { + int count = 0; + int max = timeout / 100; + while (count