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 0850bce04f..04bf297083 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 @@ -95,7 +95,7 @@ public class AsyncAmqpGatewayTests { container.setQueueNames("asyncRQ1"); container.afterPropertiesSet(); container.start(); - AsyncRabbitTemplate asyncTemplate = spy(new AsyncRabbitTemplate(template, container)); + AsyncRabbitTemplate asyncTemplate = new AsyncRabbitTemplate(template, container); asyncTemplate.setEnableConfirms(true); asyncTemplate.setMandatory(true); asyncTemplate.start(); @@ -206,9 +206,7 @@ public class AsyncAmqpGatewayTests { ackChannel.receive(10000); 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 - + asyncTemplate = mock(AsyncRabbitTemplate.class); RabbitMessageFuture future = asyncTemplate.new RabbitMessageFuture(null, null); willReturn(future).given(asyncTemplate).sendAndReceive(anyString(), anyString(), any(org.springframework.amqp.core.Message.class)); @@ -217,6 +215,7 @@ public class AsyncAmqpGatewayTests { SettableListenableFuture confirmFuture = new SettableListenableFuture(); confirmFuture.set(false); dfa.setPropertyValue("confirm", confirmFuture); + new DirectFieldAccessor(gateway).setPropertyValue("template", asyncTemplate); message = MessageBuilder.withPayload("buz").setErrorChannel(errorChannel).build(); gateway.handleMessage(message);