Upgrade to Mockito 3.4.6
Closes gh-22838
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
@@ -23,8 +23,9 @@ import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -53,6 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Greg Turnquist
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ConditionEvaluationReportTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
@@ -76,7 +78,6 @@ class ConditionEvaluationReportTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.report = ConditionEvaluationReport.get(this.beanFactory);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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,10 +21,10 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
|
||||
@@ -45,6 +45,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Stephane Nicoll
|
||||
* @author Artsiom Yudovin
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HibernatePropertiesTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
@@ -53,11 +54,6 @@ class HibernatePropertiesTests {
|
||||
@Mock
|
||||
private Supplier<String> ddlAutoSupplier;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noCustomNamingStrategy() {
|
||||
this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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,8 +21,9 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
@@ -40,6 +41,7 @@ import static org.mockito.Mockito.verify;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TemplateAvailabilityProvidersTests {
|
||||
|
||||
private TemplateAvailabilityProviders providers;
|
||||
@@ -58,7 +60,6 @@ class TemplateAvailabilityProvidersTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.providers = new TemplateAvailabilityProviders(Collections.singleton(this.provider));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.util.Map;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import reactor.netty.http.server.HttpRequestDecoderSpec;
|
||||
import reactor.netty.http.server.HttpServer;
|
||||
|
||||
@@ -49,6 +50,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Brian Clozel
|
||||
* @author Artsiom Yudovin
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class NettyWebServerFactoryCustomizerTests {
|
||||
|
||||
private MockEnvironment environment;
|
||||
@@ -62,7 +64,6 @@ class NettyWebServerFactoryCustomizerTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.environment = new MockEnvironment();
|
||||
this.serverProperties = new ServerProperties();
|
||||
ConfigurationPropertySources.attach(this.environment);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
@@ -24,8 +24,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
|
||||
@@ -56,6 +57,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DefaultErrorViewResolverTests {
|
||||
|
||||
private DefaultErrorViewResolver resolver;
|
||||
@@ -71,7 +73,6 @@ class DefaultErrorViewResolverTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
|
||||
applicationContext.refresh();
|
||||
this.resourceProperties = new ResourceProperties();
|
||||
@@ -115,6 +116,8 @@ class DefaultErrorViewResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveWhenSeries5xxTemplateMatchShouldReturnTemplate() {
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/503"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(false);
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/5xx"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(true);
|
||||
ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.SERVICE_UNAVAILABLE,
|
||||
@@ -124,6 +127,8 @@ class DefaultErrorViewResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveWhenSeries4xxTemplateMatchShouldReturnTemplate() {
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/404"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(false);
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/4xx"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(true);
|
||||
ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.NOT_FOUND, this.model);
|
||||
@@ -170,9 +175,10 @@ class DefaultErrorViewResolverTests {
|
||||
@Test
|
||||
void resolveWhenExactResourceMatchAndSeriesTemplateMatchShouldFavorResource() throws Exception {
|
||||
setResourceLocation("/exact");
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/4xx"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(true);
|
||||
given(this.templateAvailabilityProvider.isTemplateAvailable(eq("error/404"), any(Environment.class),
|
||||
any(ClassLoader.class), any(ResourceLoader.class))).willReturn(false);
|
||||
ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.NOT_FOUND, this.model);
|
||||
verifyNoMoreInteractions(this.templateAvailabilityProvider);
|
||||
MockHttpServletResponse response = render(resolved);
|
||||
assertThat(response.getContentAsString().trim()).isEqualTo("exact/404");
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_HTML_VALUE);
|
||||
|
||||
Reference in New Issue
Block a user