From cca630e882b1c885be9a6f74f9c361ce8b543468 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 6 Jan 2014 09:03:05 -0500 Subject: [PATCH] Improve JMS Test Loop sleeping 100ms for up to 10s instead of a hard sleep of 1s. Stop the gateway in a finally block. --- .../integration/jms/JmsOutboundGatewayTests.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java index 079c15d756..c7e89ad103 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/JmsOutboundGatewayTests.java @@ -140,8 +140,16 @@ public class JmsOutboundGatewayTests { gateway.setBeanFactory(beanFactory); gateway.afterPropertiesSet(); gateway.start(); - Thread.sleep(1000); - assertTrue(count.get() > 4); - assertEquals(0, errors.size()); + try { + int n = 0; + while (n++ < 100 && count.get() < 5) { + Thread.sleep(100); + } + assertTrue(count.get() > 4); + assertEquals(0, errors.size()); + } + finally { + gateway.stop(); + } } }