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.
This commit is contained in:
Gary Russell
2016-04-22 12:43:24 -04:00
parent a98ce143e2
commit 379a8a2d0b

View File

@@ -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