diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java index 25f1b246cd..d55da9885f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorWithCustomReleaseStrategyTests.java @@ -12,6 +12,9 @@ */ package org.springframework.integration.aggregator.scenarios; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.junit.Test; import org.springframework.context.ApplicationContext; @@ -22,6 +25,7 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.support.MessageBuilder; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Oleg Zhurakousky @@ -36,10 +40,13 @@ public class AggregatorWithCustomReleaseStrategyTests { final MessageChannel inputChannel = context.getBean("in", MessageChannel.class); QueueChannel resultChannel = context.getBean("resultChannel", QueueChannel.class); + final CountDownLatch latch = new CountDownLatch(2); + new Thread(new Runnable() { public void run() { inputChannel.send(MessageBuilder.withPayload(new Integer[]{1, 2, 3, 4, 5, 6, 7, 8}). setHeader("correlation", "foo").build()); + latch.countDown(); } }).start(); @@ -47,9 +54,11 @@ public class AggregatorWithCustomReleaseStrategyTests { public void run() { inputChannel.send(MessageBuilder.withPayload(new Integer[]{10, 20, 30, 40, 50, 60, 70, 80}). setHeader("correlation", "foo").build()); + latch.countDown(); } }).start(); + assertTrue("Sends failed to complete", latch.await(10, TimeUnit.SECONDS)); Message message = resultChannel.receive(1000); int counter = 0;