Update to Mockito 2.10.0
Issue: gh-4608
This commit is contained in:
+2
-2
@@ -89,7 +89,7 @@ public class AspectJMethodSecurityInterceptorTests {
|
||||
when(codeSig.getDeclaringType()).thenReturn(TargetObject.class);
|
||||
when(codeSig.getParameterTypes()).thenReturn(new Class[] { String.class });
|
||||
when(staticPart.getSignature()).thenReturn(codeSig);
|
||||
when(mds.getAttributes(any(JoinPoint.class))).thenReturn(
|
||||
when(mds.getAttributes(any())).thenReturn(
|
||||
SecurityConfig.createList("ROLE_USER"));
|
||||
when(authman.authenticate(token)).thenReturn(token);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class AspectJMethodSecurityInterceptorTests {
|
||||
@Test
|
||||
public void callbackIsNotInvokedWhenPermissionDenied() throws Exception {
|
||||
doThrow(new AccessDeniedException("denied")).when(adm).decide(
|
||||
any(Authentication.class), any(), any(Collection.class));
|
||||
any(), any(), any());
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(token);
|
||||
try {
|
||||
|
||||
+1
-2
@@ -20,7 +20,7 @@ import org.junit.Before;
|
||||
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.context.annotation.Bean;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -76,7 +76,6 @@ public class ReactiveAuthenticationManagerAdapterTests {
|
||||
@Test
|
||||
public void authenticateWhenBadCredentialsThenError() {
|
||||
when(delegate.authenticate(any())).thenThrow(new BadCredentialsException("Failed"));
|
||||
when(authentication.isAuthenticated()).thenReturn(true);
|
||||
|
||||
Mono<Authentication> result = manager.authenticate(authentication);
|
||||
|
||||
|
||||
+5
-13
@@ -40,6 +40,7 @@ import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
@@ -262,19 +263,10 @@ public class DefaultJaasAuthenticationProviderTests {
|
||||
}
|
||||
|
||||
private void verifyFailedLogin() {
|
||||
verify(publisher).publishEvent(
|
||||
argThat(new BaseMatcher<JaasAuthenticationFailedEvent>() {
|
||||
public void describeTo(Description desc) {
|
||||
desc.appendText("isA(org.springframework.security.authentication.jaas.event.JaasAuthenticationFailedEvent)");
|
||||
desc.appendText(" && event.getException() != null");
|
||||
}
|
||||
|
||||
public boolean matches(Object arg) {
|
||||
JaasAuthenticationFailedEvent e = (JaasAuthenticationFailedEvent) arg;
|
||||
return e.getException() != null;
|
||||
}
|
||||
|
||||
}));
|
||||
ArgumentCaptor<JaasAuthenticationFailedEvent> event = ArgumentCaptor.forClass(JaasAuthenticationFailedEvent.class);
|
||||
verify(publisher).publishEvent(event.capture());
|
||||
assertThat(event.getValue()).isInstanceOf(JaasAuthenticationFailedEvent.class);
|
||||
assertThat(event.getValue().getException()).isNotNull();
|
||||
verifyNoMoreInteractions(publisher);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -19,7 +19,7 @@ import org.junit.Before;
|
||||
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.context.ApplicationEvent;
|
||||
import org.springframework.context.event.SmartApplicationListener;
|
||||
|
||||
@@ -63,7 +63,6 @@ public class DelegatingApplicationListenerTests {
|
||||
|
||||
@Test
|
||||
public void processEventEventTypeNotSupported() {
|
||||
when(delegate.supportsSourceType(event.getSource().getClass())).thenReturn(true);
|
||||
listener.onApplicationEvent(event);
|
||||
|
||||
verify(delegate, never()).onApplicationEvent(any(ApplicationEvent.class));
|
||||
|
||||
+13
-12
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.powermock.api.mockito.PowerMockito.doReturn;
|
||||
import static org.powermock.api.mockito.PowerMockito.spy;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
@@ -85,8 +86,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
String version = "1";
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn(version);
|
||||
when(SpringVersion.getVersion()).thenReturn(version);
|
||||
doReturn(version).when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn(version).when(SpringVersion.class,"getVersion");
|
||||
|
||||
performChecks();
|
||||
|
||||
@@ -97,8 +98,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
public void noLoggingIfSpringVersionNull() throws Exception {
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn("1");
|
||||
when(SpringVersion.getVersion()).thenReturn(null);
|
||||
doReturn("1").when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn(null).when(SpringVersion.class,"getVersion");
|
||||
|
||||
performChecks();
|
||||
|
||||
@@ -109,8 +110,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
public void warnIfSpringVersionTooSmall() throws Exception {
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn("3");
|
||||
when(SpringVersion.getVersion()).thenReturn("2");
|
||||
doReturn("3").when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn("2").when(SpringVersion.class,"getVersion");
|
||||
|
||||
performChecks();
|
||||
|
||||
@@ -121,8 +122,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
public void noWarnIfSpringVersionLarger() throws Exception {
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn("4.0.0.RELEASE");
|
||||
when(SpringVersion.getVersion()).thenReturn("4.0.0.RELEASE");
|
||||
doReturn("4.0.0.RELEASE").when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn("4.0.0.RELEASE").when(SpringVersion.class,"getVersion");
|
||||
|
||||
performChecks();
|
||||
|
||||
@@ -135,8 +136,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
String minSpringVersion = "3.2.8.RELEASE";
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn("3.2.0.RELEASE");
|
||||
when(SpringVersion.getVersion()).thenReturn("3.2.10.RELEASE");
|
||||
doReturn("3.2.0.RELEASE").when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn("3.2.10.RELEASE").when(SpringVersion.class,"getVersion");
|
||||
|
||||
performChecks(minSpringVersion);
|
||||
|
||||
@@ -147,8 +148,8 @@ public class SpringSecurityCoreVersionTests {
|
||||
public void noLoggingIfPropertySet() throws Exception {
|
||||
spy(SpringSecurityCoreVersion.class);
|
||||
spy(SpringVersion.class);
|
||||
when(SpringSecurityCoreVersion.getVersion()).thenReturn("3");
|
||||
when(SpringVersion.getVersion()).thenReturn("2");
|
||||
doReturn("3").when(SpringSecurityCoreVersion.class,"getVersion");
|
||||
doReturn("2").when(SpringVersion.class,"getVersion");
|
||||
System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString());
|
||||
|
||||
performChecks();
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
|
||||
* Tests {@link JdbcDaoImpl}.
|
||||
*
|
||||
* @author Ben Alex
|
||||
* @author Eddú Meléndez
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
public class JdbcDaoImplTests {
|
||||
|
||||
@@ -212,6 +212,6 @@ public class JdbcDaoImplTests {
|
||||
|
||||
dao.getMessages().getMessage(code);
|
||||
|
||||
verify(source).getMessage(eq(code), any(Object[].class), any(Locale.class));
|
||||
verify(source).getMessage(eq(code), any(), any());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user