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:
Artem Bilan
2017-01-09 17:39:47 -05:00
committed by Gary Russell
parent e04a8d9948
commit 54654546b9
77 changed files with 392 additions and 413 deletions

View File

@@ -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.
@@ -18,7 +18,7 @@ package org.springframework.integration.mail.config;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

View File

@@ -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.
@@ -33,8 +33,6 @@ import javax.mail.internet.MimeMessage;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -82,13 +80,10 @@ public class MessageWithContentTypeTests {
MimeMessage mMessage = new TestMimeMessage();
// MOCKS
when(sender.createMimeMessage()).thenReturn(mMessage);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
MimeMessage mimeMessage = invocation.getArgumentAt(0, MimeMessage.class);
assertEquals("text/html", mimeMessage.getDataHandler().getContentType());
return null;
}
doAnswer(invocation -> {
MimeMessage mimeMessage = invocation.getArgument(0);
assertEquals("text/html", mimeMessage.getDataHandler().getContentType());
return null;
}).when(sender).send(Mockito.any(MimeMessage.class));
// handle message
@@ -102,4 +97,5 @@ public class MessageWithContentTypeTests {
super(Session.getDefaultInstance(new Properties()));
}
}
}