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 2013-2016 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.text.DateFormat;
|
||||
@@ -120,7 +121,7 @@ public class HttpProxyScenarioTests {
|
||||
final String contentDispositionValue = "attachment; filename=\"test.txt\"";
|
||||
|
||||
Mockito.doAnswer(invocation -> {
|
||||
URI uri = invocation.getArgumentAt(0, URI.class);
|
||||
URI uri = invocation.getArgument(0);
|
||||
assertEquals(new URI("http://testServer/test?foo=bar&FOO=BAR"), uri);
|
||||
HttpEntity<?> httpEntity = (HttpEntity<?>) invocation.getArguments()[2];
|
||||
HttpHeaders httpHeaders = httpEntity.getHeaders();
|
||||
@@ -131,9 +132,9 @@ public class HttpProxyScenarioTests {
|
||||
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
|
||||
responseHeaders.set("Connection", "close");
|
||||
responseHeaders.set("Content-Disposition", contentDispositionValue);
|
||||
return new ResponseEntity<Object>(responseHeaders, HttpStatus.OK);
|
||||
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
|
||||
}).when(template).exchange(Mockito.any(URI.class), Mockito.any(HttpMethod.class),
|
||||
Mockito.any(HttpEntity.class), (Class<?>) Mockito.any(Class.class));
|
||||
Mockito.any(HttpEntity.class), (Class<?>) isNull());
|
||||
|
||||
PropertyAccessor dfa = new DirectFieldAccessor(this.handler);
|
||||
dfa.setPropertyValue("restTemplate", template);
|
||||
@@ -173,7 +174,7 @@ public class HttpProxyScenarioTests {
|
||||
|
||||
RestTemplate template = Mockito.spy(new RestTemplate());
|
||||
Mockito.doAnswer(invocation -> {
|
||||
URI uri = invocation.getArgumentAt(0, URI.class);
|
||||
URI uri = invocation.getArgument(0);
|
||||
assertEquals(new URI("http://testServer/testmp"), uri);
|
||||
HttpEntity<?> httpEntity = (HttpEntity<?>) invocation.getArguments()[2];
|
||||
HttpHeaders httpHeaders = httpEntity.getHeaders();
|
||||
@@ -190,7 +191,7 @@ public class HttpProxyScenarioTests {
|
||||
responseHeaders.set("Content-Type", "text/plain");
|
||||
return new ResponseEntity<Object>(responseHeaders, HttpStatus.OK);
|
||||
}).when(template).exchange(Mockito.any(URI.class), Mockito.any(HttpMethod.class),
|
||||
Mockito.any(HttpEntity.class), (Class<?>) Mockito.any(Class.class));
|
||||
Mockito.any(HttpEntity.class), (Class<?>) isNull());
|
||||
|
||||
PropertyAccessor dfa = new DirectFieldAccessor(this.handlermp);
|
||||
dfa.setPropertyValue("restTemplate", template);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -32,7 +33,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
@@ -73,14 +73,14 @@ public class MultipartAsRawByteArrayTests {
|
||||
|
||||
@Override
|
||||
public Integer answer(InvocationOnMock invocation) throws Throwable {
|
||||
byte[] buff = invocation.getArgumentAt(0, byte[].class);
|
||||
byte[] buff = invocation.getArgument(0);
|
||||
buff[0] = 'f';
|
||||
buff[1] = 'o';
|
||||
buff[2] = 'o';
|
||||
return done++ > 0 ? -1 : 3;
|
||||
}
|
||||
|
||||
}).when(sis).read(Matchers.any(byte[].class));
|
||||
}).when(sis).read(any(byte[].class));
|
||||
when(request.getInputStream()).thenReturn(sis);
|
||||
when(request.getMethod()).thenReturn("POST");
|
||||
when(request.getHeaderNames()).thenReturn(mock(Enumeration.class));
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user