Upgrade to Mockito 2.2
Issue: SPR-14880
This commit is contained in:
@@ -20,7 +20,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext.Store;
|
||||
@@ -30,19 +29,12 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.TestContextManager;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.CoreMatchers.endsWith;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.expectThrows;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Tests for {@link DisabledIfCondition} that verify actual condition evaluation
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.test.context.support.TestPropertySourceUtils.*;
|
||||
|
||||
|
||||
@@ -58,17 +58,24 @@ public class DelegatingWebConnectionTests {
|
||||
|
||||
@Mock
|
||||
private WebRequestMatcher matcher1;
|
||||
|
||||
@Mock
|
||||
private WebRequestMatcher matcher2;
|
||||
|
||||
@Mock
|
||||
private WebConnection defaultConnection;
|
||||
|
||||
@Mock
|
||||
private WebConnection connection1;
|
||||
|
||||
@Mock
|
||||
private WebConnection connection2;
|
||||
|
||||
|
||||
private DelegatingWebConnection webConnection;
|
||||
|
||||
private WebRequest request;
|
||||
|
||||
private WebResponse expectedResponse;
|
||||
|
||||
|
||||
@@ -78,13 +85,12 @@ public class DelegatingWebConnectionTests {
|
||||
WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.<NameValuePair> emptyList());
|
||||
expectedResponse = new WebResponse(data, request, 100L);
|
||||
webConnection = new DelegatingWebConnection(defaultConnection,
|
||||
new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
|
||||
new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResponseDefault() throws Exception {
|
||||
when(defaultConnection.getResponse(request)).thenReturn(expectedResponse);
|
||||
|
||||
WebResponse response = webConnection.getResponse(request);
|
||||
|
||||
assertThat(response, sameInstance(expectedResponse));
|
||||
@@ -97,9 +103,7 @@ public class DelegatingWebConnectionTests {
|
||||
@Test
|
||||
public void getResponseAllMatches() throws Exception {
|
||||
when(matcher1.matches(request)).thenReturn(true);
|
||||
when(matcher2.matches(request)).thenReturn(true);
|
||||
when(connection1.getResponse(request)).thenReturn(expectedResponse);
|
||||
|
||||
WebResponse response = webConnection.getResponse(request);
|
||||
|
||||
assertThat(response, sameInstance(expectedResponse));
|
||||
@@ -112,7 +116,6 @@ public class DelegatingWebConnectionTests {
|
||||
public void getResponseSecondMatches() throws Exception {
|
||||
when(matcher2.matches(request)).thenReturn(true);
|
||||
when(connection2.getResponse(request)).thenReturn(expectedResponse);
|
||||
|
||||
WebResponse response = webConnection.getResponse(request);
|
||||
|
||||
assertThat(response, sameInstance(expectedResponse));
|
||||
@@ -144,6 +147,7 @@ public class DelegatingWebConnectionTests {
|
||||
|
||||
|
||||
@Controller
|
||||
static class TestController {}
|
||||
static class TestController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.concurrent.Callable;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -45,12 +44,10 @@ import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Tests with Java configuration.
|
||||
|
||||
Reference in New Issue
Block a user