From 379a8a2d0bcca9a90225f3c3ce20a32d7150380c Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Fri, 22 Apr 2016 12:43:24 -0400 Subject: [PATCH] Async AMQP Tests: Purge ackChannel Since acks may arrive after the timeout and therefore won't be delivered to the ackChannel, purge the channel to clear it instead of waiting for the acks, before stubbing the template. --- .../integration/amqp/outbound/AsyncAmqpGatewayTests.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java index bbb17171b5..b09359067d 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java @@ -163,16 +163,12 @@ public class AsyncAmqpGatewayTests { }); message = MessageBuilder.withPayload("bar").setErrorChannel(errorChannel).build(); gateway.handleMessage(message); - ack = ackChannel.receive(10000); - assertNotNull(ack); assertNull(errorChannel.receive(100)); gateway.setRequiresReply(true); message = MessageBuilder.withPayload("baz").setErrorChannel(errorChannel).build(); gateway.handleMessage(message); - ack = ackChannel.receive(10000); - assertNotNull(ack); received = errorChannel.receive(10000); assertThat(received, instanceOf(ErrorMessage.class)); ErrorMessage error = (ErrorMessage) received; @@ -208,6 +204,8 @@ public class AsyncAmqpGatewayTests { assertNotNull(returned); assertEquals("fiz", returned.getPayload()); + ackChannel.purge(null); + // Simulate a nack - it's hard to get Rabbit to generate one // We must have consumed all the real acks by now, though, to prevent partial stubbing errors