INT-4206: Upgrade to Mockito 2.5
JIRA: https://jira.spring.io/browse/INT-4206 * Fix unnecessary dependency resolution in BOM module * Fix `MessagingMethodInvokerHelper` to handle `$MockitoMock$` generated classed which isn't CGLib `Proxies` any more * Provide fixes for test classes according upgrade to Mockito `2.5` * Fix Ceckstyle do not allow static imports for deprecated Mockito classes
This commit is contained in:
committed by
Gary Russell
parent
e04a8d9948
commit
54654546b9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,8 @@ package org.springframework.integration.jms;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -29,7 +31,6 @@ import javax.jms.Session;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.internal.stubbing.answers.DoesNothing;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
@@ -73,7 +74,7 @@ public class ChannelPublishingJmsMessageListenerTests {
|
||||
final QueueChannel requestChannel = new QueueChannel();
|
||||
ChannelPublishingJmsMessageListener listener = new ChannelPublishingJmsMessageListener();
|
||||
Log logger = spy(TestUtils.getPropertyValue(listener, "logger", Log.class));
|
||||
doAnswer(new DoesNothing()).when(logger).error(Matchers.anyString(), Matchers.any(Throwable.class));
|
||||
doAnswer(new DoesNothing()).when(logger).error(anyString(), any(Throwable.class));
|
||||
new DirectFieldAccessor(listener).setPropertyValue("logger", logger);
|
||||
listener.setRequestChannel(requestChannel);
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
|
||||
@@ -533,7 +533,7 @@ public class DefaultJmsHeaderMapperTests {
|
||||
|
||||
Session session = Mockito.mock(Session.class);
|
||||
|
||||
Mockito.doAnswer(invocation -> new StubTextMessage(invocation.getArgumentAt(0, String.class))).when(session)
|
||||
Mockito.doAnswer(invocation -> new StubTextMessage(invocation.getArgument(0))).when(session)
|
||||
.createTextMessage(Mockito.anyString());
|
||||
|
||||
javax.jms.Message request = converter.toMessage(new Foo(), session);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,9 @@ package org.springframework.integration.jms;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -119,7 +119,7 @@ public class JmsOutboundGatewayTests extends LogAdjustingTestSupport {
|
||||
Session session = mock(Session.class);
|
||||
when(connection.createSession(false, 1)).thenReturn(session);
|
||||
MessageConsumer consumer = mock(MessageConsumer.class);
|
||||
when(session.createConsumer(any(Destination.class), anyString())).thenReturn(consumer);
|
||||
when(session.createConsumer(any(Destination.class), isNull())).thenReturn(consumer);
|
||||
when(session.createTemporaryQueue()).thenReturn(mock(TemporaryQueue.class));
|
||||
final Message message = mock(Message.class);
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,8 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -318,7 +318,7 @@ public class SubscribableJmsChannelTests {
|
||||
Log logger = mock(Log.class);
|
||||
final ArrayList<String> logList = new ArrayList<String>();
|
||||
doAnswer(invocation -> {
|
||||
String message = invocation.getArgumentAt(0, String.class);
|
||||
String message = invocation.getArgument(0);
|
||||
if (message.startsWith("Dispatcher has no subscribers")) {
|
||||
logList.add(message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,7 +55,7 @@ public class JmsChannelHistoryTests {
|
||||
|
||||
doAnswer(invocation -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<String> msg = invocation.getArgumentAt(0, Message.class);
|
||||
Message<String> msg = invocation.getArgument(0);
|
||||
MessageHistory history = MessageHistory.read(msg);
|
||||
assertTrue(history.get(0).contains("jmsChannel"));
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user