Skip to content

Commit 09f8b89

Browse files
committed
GH-1312: Fix Deprecation Warnings in Tests
1 parent e787950 commit 09f8b89

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateDirectReplyToContainerIntegrationTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.assertj.core.api.Assertions.assertThatThrownBy;
21+
import static org.mockito.Mockito.mock;
2122

2223
import java.util.Map;
2324
import java.util.concurrent.CountDownLatch;
@@ -37,6 +38,8 @@
3738
import org.springframework.amqp.utils.test.TestUtils;
3839
import org.springframework.util.ErrorHandler;
3940

41+
import com.rabbitmq.client.Channel;
42+
4043
/**
4144
* @author Gary Russell
4245
* @since 2.0
@@ -74,11 +77,11 @@ public void channelReleasedOnTimeout() throws Exception {
7477
assertThat(TestUtils.getPropertyValue(container, "inUseConsumerChannels", Map.class)).hasSize(0);
7578
assertThat(TestUtils.getPropertyValue(container, "errorHandler")).isSameAs(replyErrorHandler);
7679
Message replyMessage = new Message("foo".getBytes(), new MessageProperties());
77-
assertThatThrownBy(() -> rabbitTemplate.onMessage(replyMessage))
80+
assertThatThrownBy(() -> rabbitTemplate.onMessage(replyMessage, mock(Channel.class)))
7881
.isInstanceOf(AmqpRejectAndDontRequeueException.class)
7982
.hasMessage("No correlation header in reply");
8083
replyMessage.getMessageProperties().setCorrelationId("foo");
81-
assertThatThrownBy(() -> rabbitTemplate.onMessage(replyMessage))
84+
assertThatThrownBy(() -> rabbitTemplate.onMessage(replyMessage, mock(Channel.class)))
8285
.isInstanceOf(AmqpRejectAndDontRequeueException.class)
8386
.hasMessage("Reply received after timeout");
8487

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateHeaderTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@ private void testNoExistingReplyToOrCorrelationGuts(final boolean standardHeader
9696
MessageProperties springProps = new DefaultMessagePropertiesConverter()
9797
.toMessageProperties(basicProps, null, "UTF-8");
9898
Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
99-
template.onMessage(replyMessage);
99+
template.onMessage(replyMessage, mock(Channel.class));
100100
return null;
101101
}).given(mockChannel).basicPublish(any(String.class), any(String.class), Mockito.anyBoolean(),
102102
any(BasicProperties.class), any(byte[].class));
@@ -146,7 +146,7 @@ public void testReplyToOneDeep() throws Exception {
146146
MessageProperties springProps = new DefaultMessagePropertiesConverter()
147147
.toMessageProperties(basicProps, null, "UTF-8");
148148
Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
149-
template.onMessage(replyMessage);
149+
template.onMessage(replyMessage, mock(Channel.class));
150150
return null;
151151
}).given(mockChannel).basicPublish(any(String.class), any(String.class), Mockito.anyBoolean(),
152152
any(BasicProperties.class), any(byte[].class));
@@ -201,7 +201,7 @@ public void testReplyToThreeDeep() throws Exception {
201201
nestedReplyTo.add(replyMessage.getMessageProperties().getReplyTo());
202202
nestedCorrelation.add(replyMessage.getMessageProperties().getCorrelationId());
203203
}
204-
template.onMessage(replyMessage);
204+
template.onMessage(replyMessage, mock(Channel.class));
205205
return null;
206206
}).given(mockChannel).basicPublish(any(String.class), any(String.class), Mockito.anyBoolean(),
207207
any(BasicProperties.class), any(byte[].class));
@@ -251,7 +251,7 @@ public void testReplyToOneDeepCustomCorrelationKey() throws Exception {
251251
MessageProperties springProps = new DefaultMessagePropertiesConverter()
252252
.toMessageProperties(basicProps, null, "UTF-8");
253253
Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
254-
template.onMessage(replyMessage);
254+
template.onMessage(replyMessage, mock(Channel.class));
255255
return null;
256256
}).given(mockChannel).basicPublish(any(String.class), any(String.class), Mockito.anyBoolean(),
257257
any(BasicProperties.class), any(byte[].class));
@@ -308,7 +308,7 @@ public void testReplyToThreeDeepCustomCorrelationKey() throws Exception {
308308
nestedReplyTo.add(replyMessage.getMessageProperties().getReplyTo());
309309
nestedCorrelation.add((String) replyMessage.getMessageProperties().getHeaders().get(CORRELATION_HEADER));
310310
}
311-
template.onMessage(replyMessage);
311+
template.onMessage(replyMessage, mock(Channel.class));
312312
return null;
313313
}).given(mockChannel).basicPublish(any(String.class), any(String.class), Mockito.anyBoolean(),
314314
any(BasicProperties.class), any(byte[].class));

0 commit comments

Comments
 (0)