Update to Mockito 2.10.0
Issue: gh-4608
This commit is contained in:
@@ -64,8 +64,8 @@ public class FilterChainProxyTests {
|
||||
fc.doFilter(extraWrapper, (HttpServletResponse) args[1]);
|
||||
return null;
|
||||
}
|
||||
}).when(filter).doFilter(any(HttpServletRequest.class),
|
||||
any(HttpServletResponse.class), any(FilterChain.class));
|
||||
}).when(filter).doFilter(any(),
|
||||
any(), any());
|
||||
fcp = new FilterChainProxy(new DefaultSecurityFilterChain(matcher,
|
||||
Arrays.asList(filter)));
|
||||
fcp.setFilterChainValidator(mock(FilterChainProxy.FilterChainValidator.class));
|
||||
@@ -127,12 +127,12 @@ public class FilterChainProxyTests {
|
||||
@Test
|
||||
public void requestIsWrappedForMatchingAndFilteringWhenMatchIsFound()
|
||||
throws Exception {
|
||||
when(matcher.matches(any(HttpServletRequest.class))).thenReturn(true);
|
||||
when(matcher.matches(any())).thenReturn(true);
|
||||
fcp.doFilter(request, response, chain);
|
||||
verify(matcher).matches(any(FirewalledRequest.class));
|
||||
verify(filter).doFilter(any(FirewalledRequest.class),
|
||||
any(HttpServletResponse.class), any(FilterChain.class));
|
||||
verify(chain).doFilter(any(FirewalledRequest.class),
|
||||
verify(chain).doFilter(any(),
|
||||
any(HttpServletResponse.class));
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class FilterChainProxyTests {
|
||||
when(fw.getFirewalledRequest(firstFwr)).thenReturn(fwr);
|
||||
when(fwr.getRequest()).thenReturn(firstFwr);
|
||||
when(firstFwr.getRequest()).thenReturn(request);
|
||||
when(matcher.matches(any(HttpServletRequest.class))).thenReturn(true);
|
||||
when(matcher.matches(any())).thenReturn(true);
|
||||
firstFcp.doFilter(request, response, chain);
|
||||
verify(firstFwr).reset();
|
||||
verify(fwr).reset();
|
||||
|
||||
@@ -72,13 +72,7 @@ public class WebExpressionVoterTests {
|
||||
EvaluationContextPostProcessor postProcessor = mock(
|
||||
EvaluationContextPostProcessor.class);
|
||||
when(postProcessor.postProcess(any(EvaluationContext.class),
|
||||
any(FilterInvocation.class))).thenAnswer(new Answer<EvaluationContext>() {
|
||||
|
||||
public EvaluationContext answer(InvocationOnMock invocation)
|
||||
throws Throwable {
|
||||
return invocation.getArgumentAt(0, EvaluationContext.class);
|
||||
}
|
||||
});
|
||||
any(FilterInvocation.class))).thenAnswer( invocation -> invocation.getArgument(0));
|
||||
WebExpressionConfigAttribute weca = new WebExpressionConfigAttribute(ex,
|
||||
postProcessor);
|
||||
EvaluationContext ctx = mock(EvaluationContext.class);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class AbstractRememberMeServicesServlet3Tests {
|
||||
MockRememberMeServices services = new MockRememberMeServices();
|
||||
services.setCookie(new String[] { "mycookie" }, 1000, request, response);
|
||||
verify(response).addCookie(cookie.capture());
|
||||
verifyStatic();
|
||||
verifyStatic(ReflectionUtils.class);
|
||||
ReflectionUtils.invokeMethod(same(method), eq(cookie.getValue()), eq(true));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AbstractRememberMeServicesServlet3Tests {
|
||||
mock(UserDetailsService.class));
|
||||
services.setCookie(new String[] { "mycookie" }, 1000, request, response);
|
||||
verify(response).addCookie(cookie.capture());
|
||||
verifyStatic();
|
||||
verifyStatic(ReflectionUtils.class);
|
||||
ReflectionUtils.invokeMethod(same(method), eq(cookie.getValue()), eq(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareOnlyThisForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
@@ -50,6 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("unchecked")
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareOnlyThisForTest(ReflectionUtils.class)
|
||||
@PowerMockIgnore("javax.security.auth.*")
|
||||
public class AbstractRememberMeServicesTests {
|
||||
|
||||
static User joe = new User("joe", "password", true, true, true, true,
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ChangeSessionIdAuthenticationStrategyTests {
|
||||
|
||||
new ChangeSessionIdAuthenticationStrategy().applySessionFixation(request);
|
||||
|
||||
verifyStatic();
|
||||
verifyStatic(ReflectionUtils.class);
|
||||
ReflectionUtils.invokeMethod(same(method), eq(request));
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public class ConcurrentSessionFilterTests {
|
||||
|
||||
filter.doFilter(request, response, new MockFilterChain());
|
||||
|
||||
verify(handler).logout(eq(request), eq(response), any(Authentication.class));
|
||||
verify(handler).logout(eq(request), eq(response), any());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -64,9 +64,6 @@ public class WebAsyncManagerIntegrationFilterTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(asyncWebRequest.getNativeRequest(HttpServletRequest.class)).thenReturn(
|
||||
request);
|
||||
when(request.getRequestURI()).thenReturn("/");
|
||||
filterChain = new MockFilterChain();
|
||||
|
||||
threadFactory = new JoinableThreadFactory();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CookieCsrfTokenRepositoryServlet3Tests {
|
||||
repository.saveToken(token, request, response);
|
||||
|
||||
verify(response).addCookie(cookie.capture());
|
||||
verifyStatic();
|
||||
verifyStatic(ReflectionUtils.class);
|
||||
ReflectionUtils.invokeMethod(same(this.method), eq(cookie.getValue()), eq(true));
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class CookieCsrfTokenRepositoryServlet3Tests {
|
||||
repository.saveToken(token, request, response);
|
||||
|
||||
verify(response).addCookie(cookie.capture());
|
||||
verifyStatic(never());
|
||||
verifyStatic(ReflectionUtils.class, never());
|
||||
ReflectionUtils.invokeMethod(same(this.method), eq(cookie.getValue()), eq(true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,12 +65,8 @@ public class MvcRequestMatcherTests {
|
||||
|
||||
@Test
|
||||
public void extractUriTemplateVariablesSuccess() throws Exception {
|
||||
when(this.result.extractUriTemplateVariables())
|
||||
.thenReturn(Collections.singletonMap("p", "path"));
|
||||
when(this.introspector.getMatchableHandlerMapping(this.request))
|
||||
.thenReturn(this.mapping);
|
||||
when(this.mapping.match(eq(this.request), this.pattern.capture()))
|
||||
.thenReturn(this.result);
|
||||
|
||||
this.matcher = new MvcRequestMatcher(this.introspector, "/{p}");
|
||||
when(this.introspector.getMatchableHandlerMapping(this.request)).thenReturn(null);
|
||||
@@ -123,10 +119,6 @@ public class MvcRequestMatcherTests {
|
||||
|
||||
@Test
|
||||
public void matchesServletPathFalse() throws Exception {
|
||||
when(this.introspector.getMatchableHandlerMapping(this.request))
|
||||
.thenReturn(this.mapping);
|
||||
when(this.mapping.match(eq(this.request), this.pattern.capture()))
|
||||
.thenReturn(this.result);
|
||||
this.matcher.setServletPath("/spring");
|
||||
this.request.setServletPath("/");
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||
import org.springframework.security.web.util.matcher.AndRequestMatcher;
|
||||
|
||||
@@ -107,7 +108,6 @@ public class AndRequestMatcherTests {
|
||||
@Test
|
||||
public void matchesMultiBothFalse() {
|
||||
when(delegate.matches(request)).thenReturn(false);
|
||||
when(delegate2.matches(request)).thenReturn(false);
|
||||
matcher = new AndRequestMatcher(delegate, delegate2);
|
||||
|
||||
assertThat(matcher.matches(request)).isFalse();
|
||||
@@ -121,4 +121,4 @@ public class AndRequestMatcherTests {
|
||||
|
||||
assertThat(matcher.matches(request)).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,6 @@ public class AntPathRequestMatcherTests {
|
||||
}
|
||||
|
||||
private HttpServletRequest createRequestWithNullMethod(String path) {
|
||||
when(this.request.getQueryString()).thenReturn("doesntMatter");
|
||||
when(this.request.getServletPath()).thenReturn(path);
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ public class OrRequestMatcherTests {
|
||||
@Test
|
||||
public void matchesMultiTrue() {
|
||||
when(delegate.matches(request)).thenReturn(true);
|
||||
when(delegate2.matches(request)).thenReturn(true);
|
||||
matcher = new OrRequestMatcher(delegate, delegate2);
|
||||
|
||||
assertThat(matcher.matches(request)).isTrue();
|
||||
@@ -116,7 +115,6 @@ public class OrRequestMatcherTests {
|
||||
@Test
|
||||
public void matchesMultiSingleFalse() {
|
||||
when(delegate.matches(request)).thenReturn(true);
|
||||
when(delegate2.matches(request)).thenReturn(false);
|
||||
matcher = new OrRequestMatcher(delegate, delegate2);
|
||||
|
||||
assertThat(matcher.matches(request)).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user