INT-4145: Fix Mocking Issue
JIRA: https://jira.spring.io/browse/INT-4145 Strange stubbing failure on spied template. Perhaps some JIT interaction since the method is used normally before stubbing. Change the spy to a mock for the last part of the test. Remove comment before the mock since it isn't relevant any more
This commit is contained in:
committed by
Artem Bilan
parent
0c1a7658d7
commit
2ad0a44083
@@ -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<Boolean> confirmFuture = new SettableListenableFuture<Boolean>();
|
||||
confirmFuture.set(false);
|
||||
dfa.setPropertyValue("confirm", confirmFuture);
|
||||
new DirectFieldAccessor(gateway).setPropertyValue("template", asyncTemplate);
|
||||
|
||||
message = MessageBuilder.withPayload("buz").setErrorChannel(errorChannel).build();
|
||||
gateway.handleMessage(message);
|
||||
|
||||
Reference in New Issue
Block a user