From b49418aaaf1df161031a4d1281a8303dfdc994a1 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Mon, 27 Dec 2021 18:36:32 +0800 Subject: [PATCH 1/2] Enforce use of BDDMockito 1. Replace Mockito.verify*() with BDDMockito.then() 2. Replace Mockito.doReturn() with BDDMockito.willReturn() 3. Adjust checkstyle rule See gh-29178 --- .../CloudFoundrySecurityInterceptorTests.java | 9 +- .../servlet/TokenValidatorTests.java | 11 +- .../JmxEndpointAutoConfigurationTests.java | 5 +- ...AuditEventsEndpointDocumentationTests.java | 7 +- .../LoggersEndpointDocumentationTests.java | 13 ++- .../SessionsEndpointDocumentationTests.java | 7 +- .../metrics/MeterRegistryConfigurerTests.java | 24 ++-- .../MetricsAutoConfigurationTests.java | 9 +- ...ocationListenerBeanPostProcessorTests.java | 7 +- ...ldManagementContextConfigurationTests.java | 4 +- ...meManagementContextConfigurationTests.java | 4 +- .../audit/listener/AuditListenerTests.java | 7 +- .../actuate/cache/CachesEndpointTests.java | 23 ++-- .../CouchbaseHealthIndicatorTests.java | 9 +- ...CouchbaseReactiveHealthIndicatorTests.java | 8 +- ...rsionServiceParameterValueMapperTests.java | 7 +- .../CachingOperationInvokerAdvisorTests.java | 7 +- .../cache/CachingOperationInvokerTests.java | 22 ++-- .../endpoint/jmx/EndpointMBeanTests.java | 7 +- ...acksonJmxOperationResponseMapperTests.java | 7 +- .../jmx/JmxEndpointExporterTests.java | 11 +- .../web/ServletEndpointRegistrarTests.java | 13 ++- .../AbstractWebEndpointIntegrationTests.java | 11 +- .../influx/InfluxDbHealthIndicatorTests.java | 7 +- .../IntegrationGraphEndpointTests.java | 9 +- .../jdbc/DataSourceHealthIndicatorTests.java | 7 +- .../actuate/jms/JmsHealthIndicatorTests.java | 8 +- .../ldap/LdapHealthIndicatorTests.java | 9 +- .../actuate/logging/LoggersEndpointTests.java | 13 ++- .../LoggersEndpointWebIntegrationTests.java | 32 +++--- .../PrometheusPushGatewayManagerTests.java | 26 ++--- .../mongo/MongoHealthIndicatorTests.java | 11 +- .../neo4j/Neo4jHealthIndicatorTests.java | 5 +- .../Neo4jReactiveHealthIndicatorTests.java | 5 +- .../actuate/quartz/QuartzEndpointTests.java | 16 +-- .../redis/RedisHealthIndicatorTests.java | 9 +- .../RedisReactiveHealthIndicatorTests.java | 9 +- .../AuthenticationAuditListenerTests.java | 8 +- .../AuthorizationAuditListenerTests.java | 6 +- .../session/SessionsEndpointTests.java | 7 +- .../solr/SolrHealthIndicatorTests.java | 40 +++---- ...aReaderFactoryContextInitializerTests.java | 5 +- .../amqp/RabbitAutoConfigurationTests.java | 38 ++++--- .../BatchDataSourceInitializerTests.java | 5 +- ...ndraAutoConfigurationIntegrationTests.java | 5 +- .../domain/EntityScannerTests.java | 10 +- ...earchRestClientAutoConfigurationTests.java | 4 +- ...IntegrationDataSourceInitializerTests.java | 4 +- .../jooq/JooqExceptionTranslatorTests.java | 9 +- .../jooq/JooqPropertiesTests.java | 5 +- .../kafka/KafkaAutoConfigurationTests.java | 11 +- .../MailSenderAutoConfigurationTests.java | 8 +- .../mongo/MongoClientFactorySupportTests.java | 7 +- .../orm/jpa/HibernatePropertiesTests.java | 7 +- .../quartz/QuartzAutoConfigurationTests.java | 4 +- ...JdbcSessionDataSourceInitializerTests.java | 5 +- ...essionAutoConfigurationHazelcastTests.java | 8 +- .../session/SessionPropertiesTests.java | 7 +- .../TaskExecutionAutoConfigurationTests.java | 5 +- .../TemplateAvailabilityProvidersTests.java | 16 +-- .../validation/ValidatorAdapterTests.java | 20 ++-- .../RestTemplateAutoConfigurationTests.java | 12 +- .../JettyWebServerFactoryCustomizerTests.java | 13 ++- .../NettyWebServerFactoryCustomizerTests.java | 16 +-- ...dertowWebServerFactoryCustomizerTests.java | 29 ++--- ...ebServerFactoryAutoConfigurationTests.java | 24 ++-- ...activeWebServerFactoryCustomizerTests.java | 13 ++- .../WebFluxAutoConfigurationTests.java | 5 +- ...ntHttpConnectorAutoConfigurationTests.java | 8 +- .../WebClientAutoConfigurationTests.java | 16 +-- ...ebServerFactoryAutoConfigurationTests.java | 24 ++-- ...ervletWebServerFactoryCustomizerTests.java | 23 ++-- ...tWebServerServletContextListenerTests.java | 7 +- .../error/DefaultErrorViewResolverTests.java | 10 +- .../boot/cli/command/CommandRunnerTests.java | 9 +- .../EncodePasswordCommandTests.java | 13 ++- .../cli/command/init/InitCommandTests.java | 4 +- ...ementArtifactCoordinatesResolverTests.java | 7 +- ...rySystemSessionAutoConfigurationTests.java | 11 +- ...ToolsDataSourceAutoConfigurationTests.java | 11 +- ...eddedDataSourceAutoConfigurationTests.java | 7 +- ...ooledDataSourceAutoConfigurationTests.java | 18 +-- .../LocalDevToolsAutoConfigurationTests.java | 13 ++- .../OptionalLiveReloadServerTests.java | 7 +- .../ClassPathFileChangeListenerTests.java | 11 +- .../ConnectionOutputStreamTests.java | 7 +- .../client/DelayedLiveReloadTriggerTests.java | 7 +- .../RemoteClientConfigurationTests.java | 5 +- .../remote/server/DispatcherFilterTests.java | 13 +-- .../remote/server/DispatcherTests.java | 14 +-- ...aderFilesResourcePatternResolverTests.java | 17 +-- .../boot/devtools/restart/RestarterTests.java | 5 +- .../server/HttpRestartServerHandlerTests.java | 7 +- .../server/HttpRestartServerTests.java | 12 +- .../client/HttpTunnelConnectionTests.java | 10 +- .../server/HttpTunnelServerHandlerTests.java | 7 +- .../tunnel/server/HttpTunnelServerTests.java | 14 +-- .../orm/jpa/TestEntityManagerTests.java | 28 ++--- ...yMappingContextCustomizerFactoryTests.java | 7 +- .../WebTestClientAutoConfigurationTests.java | 7 +- .../MockMvcAutoConfigurationTests.java | 3 + ...ApplicationContextAssertProviderTests.java | 9 +- ...InheritedNestedTestConfigurationTests.java | 13 ++- ...tingBeanWithQualifierIntegrationTests.java | 7 +- .../mockito/MockBeanWithAopProxyTests.java | 10 +- .../MockitoTestExecutionListenerTests.java | 12 +- .../mockito/QualifierDefinitionTests.java | 7 +- ...nClassForExistingBeanIntegrationTests.java | 7 +- ...rationClassForNewBeanIntegrationTests.java | 7 +- ...nFieldForExistingBeanIntegrationTests.java | 7 +- ...rationFieldForNewBeanIntegrationTests.java | 7 +- ...tClassForExistingBeanIntegrationTests.java | 7 +- ...OnTestClassForNewBeanIntegrationTests.java | 7 +- ...dForExistingBeanCacheIntegrationTests.java | 7 +- ...tFieldForExistingBeanIntegrationTests.java | 7 +- ...tingBeanWithQualifierIntegrationTests.java | 7 +- ...orExistingGenericBeanIntegrationTests.java | 7 +- ...ngBeansWithOnePrimaryIntegrationTests.java | 7 +- ...OnTestFieldForNewBeanIntegrationTests.java | 7 +- ...thAopProxyAndNotProxyTargetAwareTests.java | 8 +- .../mockito/SpyBeanWithAopProxyTests.java | 12 +- ...ClassModeBeforeMethodIntegrationTests.java | 7 +- .../mockito/SpyBeanWithJdkProxyTests.java | 5 +- .../ApplicationContextTestUtilsTests.java | 13 ++- .../LocalHostUriTemplateHandlerTests.java | 7 +- ...RootUriRequestExpectationManagerTests.java | 13 ++- .../web/client/TestRestTemplateTests.java | 9 +- .../web/htmlunit/LocalHostWebClientTests.java | 9 +- ...lHostWebConnectionHtmlUnitDriverTests.java | 7 +- ...ientContextCustomizerIntegrationTests.java | 7 +- .../platform/build/BuilderTests.java | 64 ++++++----- .../platform/build/LifecycleTests.java | 14 +-- .../buildpack/platform/build/PhaseTests.java | 55 +++++---- .../platform/docker/DockerApiTests.java | 24 ++-- .../transport/HttpClientTransportTests.java | 23 ++-- .../boot/loader/jar/JarFileTests.java | 5 +- .../boot/maven/ArtifactsLibrariesTests.java | 9 +- .../org/springframework/boot/BannerTests.java | 10 +- .../DefaultPropertiesPropertySourceTests.java | 10 +- .../boot/SpringApplicationTests.java | 107 +++++++++--------- .../boot/SpringBootExceptionHandlerTests.java | 12 +- .../boot/StartupInfoLoggerTests.java | 7 +- .../AvailabilityChangeEventTests.java | 7 +- .../SpringApplicationBuilderTests.java | 18 ++- ...onfigDataEnvironmentContributorsTests.java | 12 +- ...nfigDataEnvironmentPostProcessorTests.java | 24 ++-- ...validConfigDataPropertyExceptionTests.java | 7 +- .../ConfigurationPropertiesTests.java | 5 +- ...ConfigurationPropertiesRegistrarTests.java | 6 +- .../properties/bind/BindConverterTests.java | 5 +- .../properties/bind/BindResultTests.java | 12 +- ...undPropertiesTrackingBindHandlerTests.java | 8 +- ...figurationPropertySourcesCachingTests.java | 21 ++-- .../ApplicationConversionServiceTests.java | 24 ++-- .../diagnostics/FailureAnalyzersTests.java | 15 +-- ...PostProcessorApplicationListenerTests.java | 7 +- .../boot/jdbc/DataSourceUnwrapperTests.java | 10 +- .../boot/json/JacksonJsonParserTests.java | 7 +- .../boot/logging/DeferredLogTests.java | 43 ++++--- .../boot/logging/DeferredLogsTests.java | 24 ++-- .../DelegatingLoggingSystemFactoryTests.java | 12 +- .../log4j2/Log4J2LoggingSystemTests.java | 7 +- .../logback/LogbackLoggingSystemTests.java | 7 +- .../logback/SpringProfileActionTests.java | 13 ++- .../origin/OriginTrackedResourceTests.java | 33 +++--- ...nfoApplicationContextInitializerTests.java | 7 +- ...itializationDependencyConfigurerTests.java | 5 +- .../boot/task/TaskExecutorBuilderTests.java | 34 +++--- .../boot/task/TaskSchedulerBuilderTests.java | 20 ++-- ...enceCachingMetadataReaderFactoryTests.java | 9 +- .../boot/util/LambdaSafeTests.java | 31 ++--- .../web/client/RestTemplateBuilderTests.java | 16 +-- .../client/RootUriTemplateHandlerTests.java | 15 +-- .../TomcatReactiveWebServerFactoryTests.java | 13 ++- .../TomcatServletWebServerFactoryTests.java | 15 +-- ...ctiveWebServerApplicationContextTests.java | 7 +- .../AbstractFilterRegistrationBeanTests.java | 38 ++++--- .../servlet/FilterRegistrationBeanTests.java | 11 +- .../ServletListenerRegistrationBeanTests.java | 7 +- .../servlet/ServletRegistrationBeanTests.java | 35 +++--- ...rvletWebServerApplicationContextTests.java | 5 +- ...rvletWebServerApplicationContextTests.java | 71 ++++++------ ...rvletWebServerApplicationContextTests.java | 5 +- .../AbstractServletWebServerFactoryTests.java | 11 +- .../servlet/support/ErrorPageFilterTests.java | 5 +- ...extApplicationContextInitializerTests.java | 11 +- .../SpringBootServletInitializerTests.java | 5 +- .../WebServiceTemplateBuilderTests.java | 28 ++--- .../SpyBeanSampleDataJpaApplicationTests.java | 5 +- src/checkstyle/checkstyle.xml | 2 +- 190 files changed, 1291 insertions(+), 1142 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java index c45a66e15b..4278a7a5f3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,12 +35,13 @@ import org.springframework.util.Base64Utils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link CloudFoundrySecurityInterceptor}. * * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CloudFoundrySecurityInterceptorTests { @@ -115,7 +116,7 @@ class CloudFoundrySecurityInterceptorTests { given(this.securityService.getAccessLevel(accessToken, "my-app-id")).willReturn(AccessLevel.FULL); SecurityResponse response = this.interceptor.preHandle(this.request, EndpointId.of("test")); ArgumentCaptor tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class); - verify(this.tokenValidator).validate(tokenArgumentCaptor.capture()); + then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture()); Token token = tokenArgumentCaptor.getValue(); assertThat(token.toString()).isEqualTo(accessToken); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK); @@ -129,7 +130,7 @@ class CloudFoundrySecurityInterceptorTests { given(this.securityService.getAccessLevel(accessToken, "my-app-id")).willReturn(AccessLevel.RESTRICTED); SecurityResponse response = this.interceptor.preHandle(this.request, EndpointId.of("info")); ArgumentCaptor tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class); - verify(this.tokenValidator).validate(tokenArgumentCaptor.capture()); + then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture()); Token token = tokenArgumentCaptor.getValue(); assertThat(token.toString()).isEqualTo(accessToken); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java index a7b568ecbd..2603afeb05 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java @@ -33,7 +33,6 @@ 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.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryAuthorizationException; @@ -46,12 +45,14 @@ import org.springframework.util.StreamUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.never; /** * Tests for {@link TokenValidator}. * * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class TokenValidatorTests { @@ -109,7 +110,7 @@ class TokenValidatorTests { String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}"; String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}"; this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))); - verify(this.securityService).fetchTokenKeys(); + then(this.securityService).should().fetchTokenKeys(); } @Test @@ -119,7 +120,7 @@ class TokenValidatorTests { String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}"; String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}"; this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))); - verify(this.securityService).fetchTokenKeys(); + then(this.securityService).should().fetchTokenKeys(); } @Test @@ -129,7 +130,7 @@ class TokenValidatorTests { String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}"; String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}"; this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))); - verify(this.securityService, Mockito.never()).fetchTokenKeys(); + then(this.securityService).should(never()).fetchTokenKeys(); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java index 7bb06ee23a..4a7c4faed6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java @@ -35,13 +35,14 @@ import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link JmxEndpointAutoConfiguration}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class JmxEndpointAutoConfigurationTests { @@ -72,7 +73,7 @@ class JmxEndpointAutoConfigurationTests { .withBean(EndpointObjectNameFactory.class, () -> factory).run((context) -> { ArgumentCaptor argumentCaptor = ArgumentCaptor .forClass(ExposableJmxEndpoint.class); - verify(factory).getObjectName(argumentCaptor.capture()); + then(factory).should().getObjectName(argumentCaptor.capture()); ExposableJmxEndpoint jmxEndpoint = argumentCaptor.getValue(); assertThat(jmxEndpoint.getEndpointId().toLowerCaseString()).isEqualTo("test"); }); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java index 5b267f0430..f507c4207a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -33,7 +33,7 @@ import org.springframework.context.annotation.Import; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -46,6 +46,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing {@link AuditEventsEndpoint}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -83,7 +84,7 @@ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentation "Restricts the events to those with the given principal. Optional."), parameterWithName("type") .description("Restricts the events to those with the given type. Optional.")))); - verify(this.repository).find("alice", now.toInstant(), "logout"); + then(this.repository).should().find("alice", now.toInstant(), "logout"); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java index 81ad2c352a..aac18dd585 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -40,7 +40,7 @@ import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.payload.JsonFieldType; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -52,6 +52,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing the {@link LoggersEndpoint}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -114,7 +115,7 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest .andExpect(status().isNoContent()) .andDo(MockMvcRestDocumentation.document("loggers/set", requestFields(fieldWithPath("configuredLevel") .description("Level for the logger. May be omitted to clear the level.").optional()))); - verify(this.loggingSystem).setLogLevel("com.example", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("com.example", LogLevel.DEBUG); } @Test @@ -127,8 +128,8 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest requestFields(fieldWithPath("configuredLevel").description( "Level for the logger group. May be omitted to clear the level of the loggers.") .optional()))); - verify(this.loggingSystem).setLogLevel("test.member1", LogLevel.DEBUG); - verify(this.loggingSystem).setLogLevel("test.member2", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member1", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member2", LogLevel.DEBUG); resetLogger(); } @@ -142,7 +143,7 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest this.mockMvc .perform(post("/actuator/loggers/com.example").content("{}").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNoContent()).andDo(MockMvcRestDocumentation.document("loggers/clear")); - verify(this.loggingSystem).setLogLevel("com.example", null); + then(this.loggingSystem).should().setLogLevel("com.example", null); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java index d57c041e28..e21697c5ea 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -38,7 +38,7 @@ import org.springframework.session.Session; import org.springframework.test.context.TestPropertySource; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -52,6 +52,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing the {@link ShutdownEndpoint}. * * @author Andy Wilkinson + * @author Yanming Zhou */ @TestPropertySource(properties = "spring.jackson.serialization.write-dates-as-timestamps=false") class SessionsEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -102,7 +103,7 @@ class SessionsEndpointDocumentationTests extends MockMvcEndpointDocumentationTes void deleteASession() throws Exception { this.mockMvc.perform(delete("/actuator/sessions/{id}", sessionTwo.getId())).andExpect(status().isNoContent()) .andDo(document("sessions/delete")); - verify(this.sessionRepository).deleteById(sessionTwo.getId()); + then(this.sessionRepository).should().deleteById(sessionTwo.getId()); } private static MapSession createSession(Instant creationTime, Instant lastAccessedTime) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java index bb9dbe5d08..5b65c4c068 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,16 +35,16 @@ import org.springframework.beans.factory.ObjectProvider; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link MeterRegistryConfigurer}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class MeterRegistryConfigurerTests { @@ -77,7 +77,7 @@ class MeterRegistryConfigurerTests { createObjectProvider(this.filters), createObjectProvider(this.binders), false, false); CompositeMeterRegistry composite = new CompositeMeterRegistry(); configurer.configure(composite); - verify(this.mockCustomizer).customize(composite); + then(this.mockCustomizer).should().customize(composite); } @Test @@ -87,7 +87,7 @@ class MeterRegistryConfigurerTests { MeterRegistryConfigurer configurer = new MeterRegistryConfigurer(createObjectProvider(this.customizers), createObjectProvider(this.filters), createObjectProvider(this.binders), false, false); configurer.configure(this.mockRegistry); - verify(this.mockCustomizer).customize(this.mockRegistry); + then(this.mockCustomizer).should().customize(this.mockRegistry); } @Test @@ -97,7 +97,7 @@ class MeterRegistryConfigurerTests { MeterRegistryConfigurer configurer = new MeterRegistryConfigurer(createObjectProvider(this.customizers), createObjectProvider(this.filters), createObjectProvider(this.binders), false, false); configurer.configure(this.mockRegistry); - verify(this.mockConfig).meterFilter(this.mockFilter); + then(this.mockConfig).should().meterFilter(this.mockFilter); } @Test @@ -107,7 +107,7 @@ class MeterRegistryConfigurerTests { MeterRegistryConfigurer configurer = new MeterRegistryConfigurer(createObjectProvider(this.customizers), createObjectProvider(this.filters), createObjectProvider(this.binders), false, false); configurer.configure(this.mockRegistry); - verify(this.mockBinder).bindTo(this.mockRegistry); + then(this.mockBinder).should().bindTo(this.mockRegistry); } @Test @@ -117,7 +117,7 @@ class MeterRegistryConfigurerTests { createObjectProvider(this.filters), createObjectProvider(this.binders), false, true); CompositeMeterRegistry composite = new CompositeMeterRegistry(); configurer.configure(composite); - verify(this.mockBinder).bindTo(composite); + then(this.mockBinder).should().bindTo(composite); } @Test @@ -126,7 +126,7 @@ class MeterRegistryConfigurerTests { MeterRegistryConfigurer configurer = new MeterRegistryConfigurer(createObjectProvider(this.customizers), createObjectProvider(this.filters), null, false, true); configurer.configure(this.mockRegistry); - verifyNoInteractions(this.mockBinder); + then(this.mockBinder).shouldHaveNoInteractions(); } @Test @@ -139,9 +139,9 @@ class MeterRegistryConfigurerTests { createObjectProvider(this.filters), createObjectProvider(this.binders), false, false); configurer.configure(this.mockRegistry); InOrder ordered = inOrder(this.mockBinder, this.mockConfig, this.mockCustomizer); - ordered.verify(this.mockCustomizer).customize(this.mockRegistry); - ordered.verify(this.mockConfig).meterFilter(this.mockFilter); - ordered.verify(this.mockBinder).bindTo(this.mockRegistry); + then(this.mockCustomizer).should(ordered).customize(this.mockRegistry); + then(this.mockConfig).should(ordered).meterFilter(this.mockFilter); + then(this.mockBinder).should(ordered).bindTo(this.mockRegistry); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java index 6737aba194..aa545f71fd 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -33,13 +33,14 @@ import org.springframework.core.annotation.Order; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link MetricsAutoConfiguration}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class MetricsAutoConfigurationTests { @@ -67,8 +68,8 @@ class MetricsAutoConfigurationTests { assertThat(filters[0].accept((Meter.Id) null)).isEqualTo(MeterFilterReply.DENY); assertThat(filters[1]).isInstanceOf(PropertiesMeterFilter.class); assertThat(filters[2].accept((Meter.Id) null)).isEqualTo(MeterFilterReply.ACCEPT); - verify((MeterBinder) context.getBean("meterBinder")).bindTo(meterRegistry); - verify(context.getBean(MeterRegistryCustomizer.class)).customize(meterRegistry); + then((MeterBinder) context.getBean("meterBinder")).should().bindTo(meterRegistry); + then(context.getBean(MeterRegistryCustomizer.class)).should().customize(meterRegistry); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java index b3c528054f..8f42b64fd8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java @@ -26,13 +26,14 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport import org.springframework.util.function.SingletonSupplier; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link MetricsRepositoryMethodInvocationListenerBeanPostProcessor} . * * @author Phillip Webb + * @author Yanming Zhou */ class MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests { @@ -49,10 +50,10 @@ class MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests { assertThat(result).isSameAs(bean); ArgumentCaptor customizer = ArgumentCaptor .forClass(RepositoryFactoryCustomizer.class); - verify(bean).addRepositoryFactoryCustomizer(customizer.capture()); + then(bean).should().addRepositoryFactoryCustomizer(customizer.capture()); RepositoryFactorySupport repositoryFactory = mock(RepositoryFactorySupport.class); customizer.getValue().customize(repositoryFactory); - verify(repositoryFactory).addInvocationListener(this.listener); + then(repositoryFactory).should().addInvocationListener(this.listener); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java index d19975c9a8..a03fd05abe 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java @@ -31,8 +31,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link JerseyChildManagementContextConfiguration}. @@ -89,7 +89,7 @@ class JerseyChildManagementContextConfigurationTests { ResourceConfig config = context.getBean(ResourceConfig.class); ManagementContextResourceConfigCustomizer customizer = context .getBean(ManagementContextResourceConfigCustomizer.class); - verify(customizer).customize(config); + then(customizer).should().customize(config); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java index e15bdbb46e..9af16cba82 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java @@ -32,8 +32,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link JerseySameManagementContextConfiguration}. @@ -99,7 +99,7 @@ class JerseySameManagementContextConfigurationTests { ResourceConfig config = context.getBean(ResourceConfig.class); ManagementContextResourceConfigCustomizer customizer = context .getBean(ManagementContextResourceConfigCustomizer.class); - verify(customizer).customize(config); + then(customizer).should().customize(config); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java index f241a4f031..dc9e92b0c4 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,13 +23,14 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.audit.AuditEvent; import org.springframework.boot.actuate.audit.AuditEventRepository; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link AuditListener}. * * @author Phillip Webb + * @author Yanming Zhou */ class AuditListenerTests { @@ -39,7 +40,7 @@ class AuditListenerTests { AuditEvent event = new AuditEvent("principal", "type", Collections.emptyMap()); AuditListener listener = new AuditListener(repository); listener.onApplicationEvent(new AuditApplicationEvent(event)); - verify(repository).add(event); + then(repository).should().add(event); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java index e05af5ad1e..34c2713e94 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -34,14 +34,15 @@ import org.springframework.cache.support.SimpleCacheManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link CachesEndpoint}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class CachesEndpointTests { @@ -126,8 +127,8 @@ class CachesEndpointTests { Cache b = mockCache("b"); CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a, b))); endpoint.clearCaches(); - verify(a).clear(); - verify(b).clear(); + then(a).should().clear(); + then(b).should().clear(); } @Test @@ -136,8 +137,8 @@ class CachesEndpointTests { Cache b = mockCache("b"); CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a, b))); assertThat(endpoint.clearCache("a", null)).isTrue(); - verify(a).clear(); - verify(b, never()).clear(); + then(a).should().clear(); + then(b).should(never()).clear(); } @Test @@ -161,9 +162,9 @@ class CachesEndpointTests { cacheManagers.put("another", cacheManager(anotherA)); CachesEndpoint endpoint = new CachesEndpoint(cacheManagers); assertThat(endpoint.clearCache("a", "another")).isTrue(); - verify(a, never()).clear(); - verify(anotherA).clear(); - verify(b, never()).clear(); + then(a).should(never()).clear(); + then(anotherA).should().clear(); + then(b).should(never()).clear(); } @Test @@ -171,7 +172,7 @@ class CachesEndpointTests { Cache a = mockCache("a"); CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a))); assertThat(endpoint.clearCache("unknown", null)).isFalse(); - verify(a, never()).clear(); + then(a).should(never()).clear(); } @Test @@ -179,7 +180,7 @@ class CachesEndpointTests { Cache a = mockCache("a"); CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a))); assertThat(endpoint.clearCache("a", "unknown")).isFalse(); - verify(a, never()).clear(); + then(a).should(never()).clear(); } private CacheManager cacheManager(Cache... caches) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java index 5a3928d392..d5235b0ad7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -34,14 +34,15 @@ import org.springframework.boot.actuate.health.Status; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link CouchbaseHealthIndicator} * * @author Eddú Meléndez * @author Stephane Nicoll + * @author Yanming Zhou */ class CouchbaseHealthIndicatorTests { @@ -61,7 +62,7 @@ class CouchbaseHealthIndicatorTests { assertThat(health.getDetails()).containsEntry("sdk", "test-sdk"); assertThat(health.getDetails()).containsKey("endpoints"); assertThat((List>) health.getDetails().get("endpoints")).hasSize(1); - verify(cluster).diagnostics(); + then(cluster).should().diagnostics(); } @Test @@ -82,7 +83,7 @@ class CouchbaseHealthIndicatorTests { assertThat(health.getDetails()).containsEntry("sdk", "test-sdk"); assertThat(health.getDetails()).containsKey("endpoints"); assertThat((List>) health.getDetails().get("endpoints")).hasSize(2); - verify(cluster).diagnostics(); + then(cluster).should().diagnostics(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java index f2f13535cc..50b164c6d9 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,8 +35,8 @@ import org.springframework.boot.actuate.health.Status; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link CouchbaseReactiveHealthIndicator}. @@ -58,7 +58,7 @@ class CouchbaseReactiveHealthIndicatorTests { assertThat(health.getDetails()).containsEntry("sdk", "test-sdk"); assertThat(health.getDetails()).containsKey("endpoints"); assertThat((List>) health.getDetails().get("endpoints")).hasSize(1); - verify(cluster).diagnostics(); + then(cluster).should().diagnostics(); } @Test @@ -79,7 +79,7 @@ class CouchbaseReactiveHealthIndicatorTests { assertThat(health.getDetails()).containsEntry("sdk", "test-sdk"); assertThat(health.getDetails()).containsKey("endpoints"); assertThat((List>) health.getDetails().get("endpoints")).hasSize(2); - verify(cluster).diagnostics(); + then(cluster).should().diagnostics(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java index 3b82e15475..8660e244dd 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -30,14 +30,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link ConversionServiceParameterValueMapper}. * * @author Phillip Webb + * @author Yanming Zhou */ class ConversionServiceParameterValueMapperTests { @@ -47,7 +48,7 @@ class ConversionServiceParameterValueMapperTests { ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper(conversionService); Object mapped = mapper.mapParameterValue(new TestOperationParameter(Integer.class), "123"); assertThat(mapped).isEqualTo(123); - verify(conversionService).convert("123", Integer.class); + then(conversionService).should().convert("123", Integer.class); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java index cc1ba56efa..3471b9e7c4 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java @@ -38,13 +38,14 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link CachingOperationInvokerAdvisor}. * * @author Phillip Webb * @author Stephane Nicoll + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CachingOperationInvokerAdvisorTests { @@ -85,7 +86,7 @@ class CachingOperationInvokerAdvisorTests { OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters, this.invoker); assertThat(advised).isSameAs(this.invoker); - verify(this.timeToLive).apply(EndpointId.of("foo")); + then(this.timeToLive).should().apply(EndpointId.of("foo")); } @Test @@ -95,7 +96,7 @@ class CachingOperationInvokerAdvisorTests { OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters, this.invoker); assertThat(advised).isSameAs(this.invoker); - verify(this.timeToLive).apply(EndpointId.of("foo")); + then(this.timeToLive).should().apply(EndpointId.of("foo")); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java index 6a8edada25..bbd72290fb 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java @@ -37,10 +37,9 @@ import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link CachingOperationInvoker}. @@ -48,6 +47,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Stephane Nicoll * @author Christoph Dreis * @author Phillip Webb + * @author Yanming Zhou */ class CachingOperationInvokerTests { @@ -143,10 +143,10 @@ class CachingOperationInvokerTests { CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); Object response = invoker.invoke(context); assertThat(response).isSameAs(expected); - verify(target, times(1)).invoke(context); + then(target).should().invoke(context); Object cachedResponse = invoker.invoke(context); assertThat(cachedResponse).isSameAs(response); - verifyNoMoreInteractions(target); + then(target).shouldHaveNoMoreInteractions(); } @Test @@ -161,7 +161,7 @@ class CachingOperationInvokerTests { invoker.invoke(context); invoker.invoke(context); invoker.invoke(context); - verify(target, times(3)).invoke(context); + then(target).should(times(3)).invoke(context); } @Test @@ -180,7 +180,7 @@ class CachingOperationInvokerTests { assertThat(invoker.invoke(context)).isEqualTo(result1); assertThat(invoker.invoke(context)).isEqualTo(result2); assertThat(invoker.invoke(context)).isEqualTo(result3); - verify(target, times(3)).invoke(context); + then(target).should(times(3)).invoke(context); } @Test @@ -201,8 +201,8 @@ class CachingOperationInvokerTests { assertThat(invoker.invoke(authenticatedContext)).isEqualTo(authenticatedResult); assertThat(invoker.invoke(anonymousContext)).isEqualTo(anonymousResult); assertThat(invoker.invoke(authenticatedContext)).isEqualTo(authenticatedResult); - verify(target, times(1)).invoke(anonymousContext); - verify(target, times(1)).invoke(authenticatedContext); + then(target).should().invoke(anonymousContext); + then(target).should().invoke(authenticatedContext); } @Test @@ -218,7 +218,7 @@ class CachingOperationInvokerTests { Thread.sleep(10); } invoker.invoke(context); - verify(target, times(2)).invoke(context); + then(target).should(times(2)).invoke(context); } @Test @@ -235,10 +235,10 @@ class CachingOperationInvokerTests { CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); Object response = invoker.invoke(contextV2); assertThat(response).isSameAs(expectedV2); - verify(target, times(1)).invoke(contextV2); + then(target).should().invoke(contextV2); Object cachedResponse = invoker.invoke(contextV3); assertThat(cachedResponse).isNotSameAs(response); - verify(target, times(1)).invoke(contextV3); + then(target).should().invoke(contextV3); } private static class MonoOperationInvoker implements OperationInvoker { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java index 21f7f7ce84..170d622168 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java @@ -37,15 +37,16 @@ import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link EndpointMBean}. * * @author Phillip Webb * @author Stephane Nicoll + * @author Yanming Zhou */ class EndpointMBeanTests { @@ -160,8 +161,8 @@ class EndpointMBeanTests { TestJmxOperationResponseMapper responseMapper = spy(this.responseMapper); EndpointMBean bean = new EndpointMBean(responseMapper, null, this.endpoint); bean.invoke("testOperation", NO_PARAMS, NO_SIGNATURE); - verify(responseMapper).mapResponseType(String.class); - verify(responseMapper).mapResponse("result"); + then(responseMapper).should().mapResponseType(String.class); + then(responseMapper).should().mapResponse("result"); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java index 09fbc96a41..6a22c4f78f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -32,13 +32,14 @@ import org.springframework.boot.test.json.BasicJsonTester; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link JacksonJmxOperationResponseMapper} * * @author Phillip Webb + * @author Yanming Zhou */ class JacksonJmxOperationResponseMapperTests { @@ -59,7 +60,7 @@ class JacksonJmxOperationResponseMapperTests { JacksonJmxOperationResponseMapper mapper = new JacksonJmxOperationResponseMapper(objectMapper); Set response = Collections.singleton("test"); mapper.mapResponse(response); - verify(objectMapper).convertValue(eq(response), any(JavaType.class)); + then(objectMapper).should().convertValue(eq(response), any(JavaType.class)); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java index b58b9f56ec..9e35ac8ca2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -43,14 +43,15 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.verify; /** * Tests for {@link JmxEndpointExporter}. * * @author Stephane Nicoll * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class JmxEndpointExporterTests { @@ -112,7 +113,7 @@ class JmxEndpointExporterTests { void afterPropertiesSetShouldRegisterMBeans() throws Exception { this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation())); this.exporter.afterPropertiesSet(); - verify(this.mBeanServer).registerMBean(this.objectCaptor.capture(), this.objectNameCaptor.capture()); + then(this.mBeanServer).should().registerMBean(this.objectCaptor.capture(), this.objectNameCaptor.capture()); assertThat(this.objectCaptor.getValue()).isInstanceOf(EndpointMBean.class); assertThat(this.objectNameCaptor.getValue().getKeyProperty("name")).isEqualTo("test"); } @@ -121,7 +122,7 @@ class JmxEndpointExporterTests { void registerShouldUseObjectNameFactory() throws Exception { this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation())); this.exporter.afterPropertiesSet(); - verify(this.objectNameFactory).getObjectName(any(ExposableJmxEndpoint.class)); + then(this.objectNameFactory).should().getObjectName(any(ExposableJmxEndpoint.class)); } @Test @@ -147,7 +148,7 @@ class JmxEndpointExporterTests { this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation())); this.exporter.afterPropertiesSet(); this.exporter.destroy(); - verify(this.mBeanServer).unregisterMBean(this.objectNameCaptor.capture()); + then(this.mBeanServer).should().unregisterMBean(this.objectNameCaptor.capture()); assertThat(this.objectNameCaptor.getValue().getKeyProperty("name")).isEqualTo("test"); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java index e4e2a419c5..9deff8ac3a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java @@ -40,14 +40,15 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletEndpointRegistrar}. * * @author Phillip Webb * @author Stephane Nicoll + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletEndpointRegistrarTests { @@ -92,9 +93,9 @@ class ServletEndpointRegistrarTests { ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class)); ServletEndpointRegistrar registrar = new ServletEndpointRegistrar(basePath, Collections.singleton(endpoint)); registrar.onStartup(this.servletContext); - verify(this.servletContext).addServlet(eq("test-actuator-endpoint"), this.servlet.capture()); + then(this.servletContext).should().addServlet(eq("test-actuator-endpoint"), this.servlet.capture()); assertThat(this.servlet.getValue()).isInstanceOf(TestServlet.class); - verify(this.dynamic).addMapping(expectedMapping); + then(this.dynamic).should().addMapping(expectedMapping); } @Test @@ -104,7 +105,7 @@ class ServletEndpointRegistrarTests { new EndpointServlet(TestServlet.class).withInitParameter("a", "b")); ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint)); registrar.onStartup(this.servletContext); - verify(this.dynamic).setInitParameters(Collections.singletonMap("a", "b")); + then(this.dynamic).should().setInitParameters(Collections.singletonMap("a", "b")); } @Test @@ -113,7 +114,7 @@ class ServletEndpointRegistrarTests { ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class).withLoadOnStartup(7)); ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint)); registrar.onStartup(this.servletContext); - verify(this.dynamic).setLoadOnStartup(7); + then(this.dynamic).should().setLoadOnStartup(7); } @Test @@ -122,7 +123,7 @@ class ServletEndpointRegistrarTests { ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class)); ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint)); registrar.onStartup(this.servletContext); - verify(this.dynamic).setLoadOnStartup(-1); + then(this.dynamic).should().setLoadOnStartup(-1); } private ExposableServletEndpoint mockEndpoint(EndpointServlet endpointServlet) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index 0afb46250e..bedb03b83c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -54,7 +54,7 @@ import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Abstract base class for web endpoint integration tests. @@ -62,6 +62,7 @@ import static org.mockito.Mockito.verify; * @param the type of application context used by the tests * @author Andy Wilkinson * @author Scott Frederick + * @author Yanming Zhou */ public abstract class AbstractWebEndpointIntegrationTests { @@ -188,7 +189,7 @@ public abstract class AbstractWebEndpointIntegrationTests { client.post().uri("/voidwrite").exchange().expectStatus().isNoContent().expectBody().isEmpty(); - verify(context.getBean(EndpointDelegate.class)).write(); + then(context.getBean(EndpointDelegate.class)).should().write(); }); } @@ -202,7 +203,7 @@ public abstract class AbstractWebEndpointIntegrationTests { client.delete().uri("/voiddelete").exchange().expectStatus().isNoContent().expectBody().isEmpty(); - verify(context.getBean(EndpointDelegate.class)).delete(); + then(context.getBean(EndpointDelegate.class)).should().delete(); }); } @@ -212,7 +213,7 @@ public abstract class AbstractWebEndpointIntegrationTests body = new HashMap<>(); body.put("foo", "one"); client.post().uri("/test").bodyValue(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); - verify(context.getBean(EndpointDelegate.class)).write("one", null); + then(context.getBean(EndpointDelegate.class)).should().write("one", null); }); } @@ -221,7 +222,7 @@ public abstract class AbstractWebEndpointIntegrationTests { client.post().uri("/test").contentType(MediaType.APPLICATION_JSON).exchange().expectStatus().isNoContent() .expectBody().isEmpty(); - verify(context.getBean(EndpointDelegate.class)).write(null, null); + then(context.getBean(EndpointDelegate.class)).should().write(null, null); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java index 068f4c29d1..508d3b7b37 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java @@ -28,13 +28,14 @@ import org.springframework.boot.actuate.health.Status; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link InfluxDbHealthIndicator}. * * @author Eddú Meléndez + * @author Yanming Zhou */ class InfluxDbHealthIndicatorTests { @@ -48,7 +49,7 @@ class InfluxDbHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("version")).isEqualTo("0.9"); - verify(influxDb).ping(); + then(influxDb).should().ping(); } @Test @@ -59,7 +60,7 @@ class InfluxDbHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat((String) health.getDetails().get("error")).contains("Connection failed"); - verify(influxDb).ping(); + then(influxDb).should().ping(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java index fc9468b71f..a389b2bb79 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,13 +23,14 @@ import org.springframework.integration.graph.IntegrationGraphServer; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link IntegrationGraphEndpoint}. * * @author Tim Ysewyn + * @author Yanming Zhou */ class IntegrationGraphEndpointTests { @@ -42,14 +43,14 @@ class IntegrationGraphEndpointTests { Graph mockedGraph = mock(Graph.class); given(this.server.getGraph()).willReturn(mockedGraph); Graph graph = this.endpoint.graph(); - verify(this.server).getGraph(); + then(this.server).should().getGraph(); assertThat(graph).isEqualTo(mockedGraph); } @Test void writeOperationShouldRebuildGraph() { this.endpoint.rebuild(); - verify(this.server).rebuild(); + then(this.server).should().rebuild(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java index c7af6e5e1f..2161c1211e 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -34,15 +34,16 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link DataSourceHealthIndicator}. * * @author Dave Syer * @author Stephane Nicoll + * @author Yanming Zhou */ class DataSourceHealthIndicatorTests { @@ -106,7 +107,7 @@ class DataSourceHealthIndicatorTests { this.indicator.setDataSource(dataSource); Health health = this.indicator.health(); assertThat(health.getDetails().get("database")).isNotNull(); - verify(connection, times(2)).close(); + then(connection).should(times(2)).close(); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java index 93d39f95c6..e04a751b06 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java @@ -30,16 +30,16 @@ import org.springframework.boot.actuate.health.Status; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willAnswer; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link JmsHealthIndicator}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class JmsHealthIndicatorTests { @@ -55,7 +55,7 @@ class JmsHealthIndicatorTests { Health health = indicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("provider")).isEqualTo("JMS test provider"); - verify(connection, times(1)).close(); + then(connection).should().close(); } @Test @@ -80,7 +80,7 @@ class JmsHealthIndicatorTests { Health health = indicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getDetails().get("provider")).isNull(); - verify(connection, times(1)).close(); + then(connection).should().close(); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java index 76e93fe177..be55705fe7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.ldap.core.LdapTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link LdapHealthIndicator} * * @author Eddú Meléndez + * @author Yanming Zhou */ class LdapHealthIndicatorTests { @@ -46,7 +47,7 @@ class LdapHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("version")).isEqualTo("3"); - verify(ldapTemplate).executeReadOnly((ContextExecutor) any()); + then(ldapTemplate).should().executeReadOnly((ContextExecutor) any()); } @Test @@ -59,7 +60,7 @@ class LdapHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat((String) health.getDetails().get("error")).contains("Connection failed"); - verify(ldapTemplate).executeReadOnly((ContextExecutor) any()); + then(ldapTemplate).should().executeReadOnly((ContextExecutor) any()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java index 7ced35e133..4ac9d7c94f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -35,8 +35,8 @@ import org.springframework.boot.logging.LoggingSystem; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link LoggersEndpoint}. @@ -45,6 +45,7 @@ import static org.mockito.Mockito.verify; * @author Andy Wilkinson * @author HaiTao Zhang * @author Madhura Bhave + * @author Yanming Zhou */ class LoggersEndpointTests { @@ -120,25 +121,25 @@ class LoggersEndpointTests { @Test void configureLogLevelShouldSetLevelOnLoggingSystem() { new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("ROOT", LogLevel.DEBUG); - verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG); } @Test void configureLogLevelWithNullSetsLevelOnLoggingSystemToNull() { new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("ROOT", null); - verify(this.loggingSystem).setLogLevel("ROOT", null); + then(this.loggingSystem).should().setLogLevel("ROOT", null); } @Test void configureLogLevelInLoggerGroupShouldSetLevelOnLoggingSystem() { new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("test", LogLevel.DEBUG); - verify(this.loggingSystem).setLogLevel("test.member", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member", LogLevel.DEBUG); } @Test void configureLogLevelWithNullInLoggerGroupShouldSetLevelOnLoggingSystem() { new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("test", null); - verify(this.loggingSystem).setLogLevel("test.member", null); + then(this.loggingSystem).should().setLogLevel("test.member", null); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java index 6364b144b4..6ae41c744f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java @@ -43,9 +43,8 @@ import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Integration tests for {@link LoggersEndpoint} when exposed via Jersey, Spring MVC, and @@ -58,6 +57,7 @@ import static org.mockito.Mockito.verifyNoInteractions; * @author Andy Wilkinson * @author HaiTao Zhang * @author Madhura Bhave + * @author Yanming Zhou */ class LoggersEndpointWebIntegrationTests { @@ -124,7 +124,7 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) .bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus() .isNoContent(); - verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG); } @WebEndpointTest @@ -132,7 +132,7 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V2_JSON)) .bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus() .isNoContent(); - verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG); } @WebEndpointTest @@ -140,7 +140,7 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON)) .bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus() .isNoContent(); - verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG); } @WebEndpointTest @@ -148,8 +148,8 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V2_JSON)) .bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus() .isNoContent(); - verify(this.loggingSystem).setLogLevel("test.member1", LogLevel.DEBUG); - verify(this.loggingSystem).setLogLevel("test.member2", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member1", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member2", LogLevel.DEBUG); } @WebEndpointTest @@ -157,8 +157,8 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/test").contentType(MediaType.APPLICATION_JSON) .bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus() .isNoContent(); - verify(this.loggingSystem).setLogLevel("test.member1", LogLevel.DEBUG); - verify(this.loggingSystem).setLogLevel("test.member2", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member1", LogLevel.DEBUG); + then(this.loggingSystem).should().setLogLevel("test.member2", LogLevel.DEBUG); } @WebEndpointTest @@ -166,37 +166,37 @@ class LoggersEndpointWebIntegrationTests { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) .bodyValue(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus() .isBadRequest(); - verifyNoInteractions(this.loggingSystem); + then(this.loggingSystem).shouldHaveNoInteractions(); } @WebEndpointTest void setLoggerWithNullLogLevel() { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON)) .bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); - verify(this.loggingSystem).setLogLevel("ROOT", null); + then(this.loggingSystem).should().setLogLevel("ROOT", null); } @WebEndpointTest void setLoggerWithNoLogLevel() { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON)) .bodyValue(Collections.emptyMap()).exchange().expectStatus().isNoContent(); - verify(this.loggingSystem).setLogLevel("ROOT", null); + then(this.loggingSystem).should().setLogLevel("ROOT", null); } @WebEndpointTest void setLoggerGroupWithNullLogLevel() { this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V3_JSON)) .bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); - verify(this.loggingSystem).setLogLevel("test.member1", null); - verify(this.loggingSystem).setLogLevel("test.member2", null); + then(this.loggingSystem).should().setLogLevel("test.member1", null); + then(this.loggingSystem).should().setLogLevel("test.member2", null); } @WebEndpointTest void setLoggerGroupWithNoLogLevel() { this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V3_JSON)) .bodyValue(Collections.emptyMap()).exchange().expectStatus().isNoContent(); - verify(this.loggingSystem).setLogLevel("test.member1", null); - verify(this.loggingSystem).setLogLevel("test.member2", null); + then(this.loggingSystem).should().setLogLevel("test.member1", null); + then(this.loggingSystem).should().setLogLevel("test.member2", null); } @WebEndpointTest diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java index 2ef0342240..2d42eaeab3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java @@ -39,16 +39,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link PrometheusPushGatewayManager}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class PrometheusPushGatewayManagerTests { @@ -110,9 +110,9 @@ class PrometheusPushGatewayManagerTests { void createShouldSchedulePushAsFixedRate() throws Exception { new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job", this.groupingKey, null); - verify(this.scheduler).scheduleAtFixedRate(this.task.capture(), eq(this.pushRate)); + then(this.scheduler).should().scheduleAtFixedRate(this.task.capture(), eq(this.pushRate)); this.task.getValue().run(); - verify(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey); + then(this.pushGateway).should().pushAdd(this.registry, "job", this.groupingKey); } @Test @@ -122,7 +122,7 @@ class PrometheusPushGatewayManagerTests { PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, ownedScheduler, this.pushRate, "job", this.groupingKey, null); manager.shutdown(); - verify(ownedScheduler).shutdown(); + then(ownedScheduler).should().shutdown(); } @Test @@ -132,7 +132,7 @@ class PrometheusPushGatewayManagerTests { PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, otherScheduler, this.pushRate, "job", this.groupingKey, null); manager.shutdown(); - verify(otherScheduler, never()).shutdown(); + then(otherScheduler).should(never()).shutdown(); } @Test @@ -141,8 +141,8 @@ class PrometheusPushGatewayManagerTests { PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.PUSH); manager.shutdown(); - verify(this.future).cancel(false); - verify(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey); + then(this.future).should().cancel(false); + then(this.pushGateway).should().pushAdd(this.registry, "job", this.groupingKey); } @Test @@ -151,8 +151,8 @@ class PrometheusPushGatewayManagerTests { PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.DELETE); manager.shutdown(); - verify(this.future).cancel(false); - verify(this.pushGateway).delete("job", this.groupingKey); + then(this.future).should().cancel(false); + then(this.pushGateway).should().delete("job", this.groupingKey); } @Test @@ -161,15 +161,15 @@ class PrometheusPushGatewayManagerTests { PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.NONE); manager.shutdown(); - verify(this.future).cancel(false); - verifyNoInteractions(this.pushGateway); + then(this.future).should().cancel(false); + then(this.pushGateway).shouldHaveNoInteractions(); } @Test void pushDoesNotThrowException() throws Exception { new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job", this.groupingKey, null); - verify(this.scheduler).scheduleAtFixedRate(this.task.capture(), eq(this.pushRate)); + then(this.scheduler).should().scheduleAtFixedRate(this.task.capture(), eq(this.pushRate)); willThrow(RuntimeException.class).given(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey); this.task.getValue().run(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java index 27b23247a5..a976b693c2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -26,13 +26,14 @@ import org.springframework.data.mongodb.core.MongoTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link MongoHealthIndicator}. * * @author Christian Dupuis + * @author Yanming Zhou */ class MongoHealthIndicatorTests { @@ -46,8 +47,8 @@ class MongoHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("version")).isEqualTo("2.6.4"); - verify(commandResult).getString("version"); - verify(mongoTemplate).executeCommand("{ buildInfo: 1 }"); + then(commandResult).should().getString("version"); + then(mongoTemplate).should().executeCommand("{ buildInfo: 1 }"); } @Test @@ -58,7 +59,7 @@ class MongoHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat((String) health.getDetails().get("error")).contains("Connection failed"); - verify(mongoTemplate).executeCommand("{ buildInfo: 1 }"); + then(mongoTemplate).should().executeCommand("{ buildInfo: 1 }"); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java index d5c28227e6..a44a5ff5ba 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java @@ -36,9 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link Neo4jHealthIndicator}. @@ -46,6 +46,7 @@ import static org.mockito.Mockito.verify; * @author Eric Spiegelberg * @author Stephane Nicoll * @author Michael Simons + * @author Yanming Zhou */ class Neo4jHealthIndicatorTests { @@ -100,7 +101,7 @@ class Neo4jHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails()).containsEntry("server", "4711@My Home"); - verify(session, times(2)).close(); + then(session).should(times(2)).close(); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java index 61b721b2ac..33ba91fd95 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java @@ -37,15 +37,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link Neo4jReactiveHealthIndicator}. * * @author Michael J. Simons * @author Stephane Nicoll + * @author Yanming Zhou */ class Neo4jReactiveHealthIndicatorTests { @@ -81,7 +82,7 @@ class Neo4jReactiveHealthIndicatorTests { assertThat(health.getDetails()).containsEntry("server", "4711@My Home"); assertThat(health.getDetails()).containsEntry("edition", "some edition"); }).verifyComplete(); - verify(session, times(2)).close(); + then(session).should(times(2)).close(); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java index 8f9787af00..1a7b4a2b93 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java @@ -75,15 +75,15 @@ import org.springframework.util.MultiValueMap; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link QuartzEndpoint}. * * @author Vedran Pavic * @author Stephane Nicoll + * @author Yanming Zhou */ class QuartzEndpointTests { @@ -118,9 +118,9 @@ class QuartzEndpointTests { QuartzReport quartzReport = this.endpoint.quartzReport(); assertThat(quartzReport.getJobs().getGroups()).containsOnly("jobSamples", "DEFAULT"); assertThat(quartzReport.getTriggers().getGroups()).containsOnly("triggerSamples"); - verify(this.scheduler).getJobGroupNames(); - verify(this.scheduler).getTriggerGroupNames(); - verifyNoMoreInteractions(this.scheduler); + then(this.scheduler).should().getJobGroupNames(); + then(this.scheduler).should().getTriggerGroupNames(); + then(this.scheduler).shouldHaveNoMoreInteractions(); } @Test @@ -669,9 +669,9 @@ class QuartzEndpointTests { given(sanitizer.sanitize("secret", "value")).willReturn("----"); QuartzJobDetails jobDetails = new QuartzEndpoint(this.scheduler, sanitizer).quartzJob("samples", "hello"); assertThat(jobDetails.getData()).containsOnly(entry("test", "value"), entry("secret", "----")); - verify(sanitizer).sanitize("test", "value"); - verify(sanitizer).sanitize("secret", "value"); - verifyNoMoreInteractions(sanitizer); + then(sanitizer).should().sanitize("test", "value"); + then(sanitizer).should().sanitize("secret", "value"); + then(sanitizer).shouldHaveNoMoreInteractions(); } private void mockJobs(JobDetail... jobs) throws SchedulerException { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java index 0dfd4f2672..1ffaee209d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java @@ -33,9 +33,9 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link RedisHealthIndicator}. @@ -43,6 +43,7 @@ import static org.mockito.Mockito.verify; * @author Christian Dupuis * @author Richard Santana * @author Stephane Nicoll + * @author Yanming Zhou */ class RedisHealthIndicatorTests { @@ -77,7 +78,7 @@ class RedisHealthIndicatorTests { assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails().get("slots_up")).isEqualTo(4L); assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L); - verify(redisConnectionFactory, atLeastOnce()).getConnection(); + then(redisConnectionFactory).should(atLeastOnce()).getConnection(); } @Test @@ -89,7 +90,7 @@ class RedisHealthIndicatorTests { assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails().get("slots_up")).isEqualTo(4L); assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L); - verify(redisConnectionFactory, atLeastOnce()).getConnection(); + then(redisConnectionFactory).should(atLeastOnce()).getConnection(); } @Test @@ -101,7 +102,7 @@ class RedisHealthIndicatorTests { assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails().get("slots_up")).isEqualTo(3L); assertThat(health.getDetails().get("slots_fail")).isEqualTo(1L); - verify(redisConnectionFactory, atLeastOnce()).getConnection(); + then(redisConnectionFactory).should(atLeastOnce()).getConnection(); } private RedisHealthIndicator createHealthIndicator(RedisConnection redisConnection) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java index cb45f42bfe..913f8e8604 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java @@ -34,8 +34,8 @@ import org.springframework.data.redis.connection.ReactiveServerCommands; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link RedisReactiveHealthIndicator}. @@ -45,6 +45,7 @@ import static org.mockito.Mockito.verify; * @author Nikolay Rybak * @author Artsiom Yudovin * @author Scott Frederick + * @author Yanming Zhou */ class RedisReactiveHealthIndicatorTests { @@ -63,7 +64,7 @@ class RedisReactiveHealthIndicatorTests { assertThat(h.getDetails()).containsOnlyKeys("version"); assertThat(h.getDetails().get("version")).isEqualTo("2.8.9"); }).verifyComplete(); - verify(redisConnection).closeLater(); + then(redisConnection).should().closeLater(); } @Test @@ -77,7 +78,7 @@ class RedisReactiveHealthIndicatorTests { assertThat(h.getDetails().get("slots_up")).isEqualTo(4L); assertThat(h.getDetails().get("slots_fail")).isEqualTo(0L); }).verifyComplete(); - verify(redisConnectionFactory.getReactiveConnection()).closeLater(); + then(redisConnectionFactory.getReactiveConnection()).should().closeLater(); } @Test @@ -115,7 +116,7 @@ class RedisReactiveHealthIndicatorTests { Mono health = healthIndicator.health(); StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN)) .verifyComplete(); - verify(redisConnection).closeLater(); + then(redisConnection).should().closeLater(); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java index e74db11946..17b0c69697 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -35,9 +35,9 @@ import org.springframework.security.web.authentication.switchuser.Authentication import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link AuthenticationAuditListener}. @@ -65,7 +65,7 @@ class AuthenticationAuditListenerTests { this.listener.onApplicationEvent(new InteractiveAuthenticationSuccessEvent( new UsernamePasswordAuthenticationToken("user", "password"), getClass())); // No need to audit this one (it shadows a regular AuthenticationSuccessEvent) - verify(this.publisher, never()).publishEvent(any(ApplicationEvent.class)); + then(this.publisher).should(never()).publishEvent(any(ApplicationEvent.class)); } @Test @@ -105,7 +105,7 @@ class AuthenticationAuditListenerTests { private AuditApplicationEvent handleAuthenticationEvent(AbstractAuthenticationEvent event) { ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(AuditApplicationEvent.class); this.listener.onApplicationEvent(event); - verify(this.publisher).publishEvent(eventCaptor.capture()); + then(this.publisher).should().publishEvent(eventCaptor.capture()); return eventCaptor.getValue(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java index 3fb709256e..a979fd2fe9 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -33,8 +33,8 @@ import org.springframework.security.authentication.AuthenticationCredentialsNotF import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link AuthorizationAuditListener}. @@ -82,7 +82,7 @@ class AuthorizationAuditListenerTests { private AuditApplicationEvent handleAuthorizationEvent(AbstractAuthorizationEvent event) { ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(AuditApplicationEvent.class); this.listener.onApplicationEvent(event); - verify(this.publisher).publishEvent(eventCaptor.capture()); + then(this.publisher).should().publishEvent(eventCaptor.capture()); return eventCaptor.getValue(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java index 32a48b4abf..95e983b410 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -28,13 +28,14 @@ import org.springframework.session.Session; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link SessionsEndpoint}. * * @author Vedran Pavic + * @author Yanming Zhou */ class SessionsEndpointTests { @@ -80,7 +81,7 @@ class SessionsEndpointTests { @Test void deleteSession() { this.endpoint.deleteSession(session.getId()); - verify(this.repository).deleteById(session.getId()); + then(this.repository).should().deleteById(session.getId()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java index 3b3ecb23f2..ef5f8c1512 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -32,10 +32,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link SolrHealthIndicator} @@ -43,6 +42,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Andy Wilkinson * @author Markus Schuch * @author Phillip Webb + * @author Yanming Zhou */ class SolrHealthIndicatorTests { @@ -52,8 +52,8 @@ class SolrHealthIndicatorTests { given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(0)); SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); assertHealth(healthIndicator, Status.UP, 0, "root"); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).shouldHaveNoMoreInteractions(); } @Test @@ -62,8 +62,8 @@ class SolrHealthIndicatorTests { given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(400)); SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); assertHealth(healthIndicator, Status.DOWN, 400, "root"); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).shouldHaveNoMoreInteractions(); } @Test @@ -74,9 +74,9 @@ class SolrHealthIndicatorTests { given(solrClient.ping()).willReturn(mockPingResponse(0)); SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); assertHealth(healthIndicator, Status.UP, 0, "particular core"); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verify(solrClient, times(1)).ping(); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).should().ping(); + then(solrClient).shouldHaveNoMoreInteractions(); } @Test @@ -87,9 +87,9 @@ class SolrHealthIndicatorTests { given(solrClient.ping()).willReturn(mockPingResponse(400)); SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); assertHealth(healthIndicator, Status.DOWN, 400, "particular core"); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verify(solrClient, times(1)).ping(); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).should().ping(); + then(solrClient).shouldHaveNoMoreInteractions(); } @Test @@ -101,8 +101,8 @@ class SolrHealthIndicatorTests { Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat((String) health.getDetails().get("error")).contains("Connection failed"); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).shouldHaveNoMoreInteractions(); } @Test @@ -113,12 +113,12 @@ class SolrHealthIndicatorTests { given(solrClient.ping()).willReturn(mockPingResponse(0)); SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); healthIndicator.health(); - verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull()); - verify(solrClient, times(1)).ping(); - verifyNoMoreInteractions(solrClient); + then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); + then(solrClient).should().ping(); + then(solrClient).shouldHaveNoMoreInteractions(); healthIndicator.health(); - verify(solrClient, times(2)).ping(); - verifyNoMoreInteractions(solrClient); + then(solrClient).should(times(2)).ping(); + then(solrClient).shouldHaveNoMoreInteractions(); } private void assertHealth(SolrHealthIndicator healthIndicator, Status expectedStatus, int expectedStatusCode, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java index 5db77876fe..289ec6c092 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java @@ -39,14 +39,15 @@ import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link SharedMetadataReaderFactoryContextInitializer}. * * @author Dave Syer * @author Phillip Webb + * @author Yanming Zhou */ class SharedMetadataReaderFactoryContextInitializerTests { @@ -84,7 +85,7 @@ class SharedMetadataReaderFactoryContextInitializerTests { assertThat(bean).isSameAs(configurationAnnotationPostProcessor); ArgumentCaptor metadataReaderFactory = ArgumentCaptor .forClass(MetadataReaderFactory.class); - verify(configurationAnnotationPostProcessor).setMetadataReaderFactory(metadataReaderFactory.capture()); + then(configurationAnnotationPostProcessor).should().setMetadataReaderFactory(metadataReaderFactory.capture()); assertThat(metadataReaderFactory.getValue()) .isInstanceOf(ConcurrentReferenceCachingMetadataReaderFactory.class); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index dba9917b9e..fc6a1cff6e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -78,9 +78,9 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link RabbitAutoConfiguration}. @@ -90,6 +90,7 @@ import static org.mockito.Mockito.verify; * @author Gary Russell * @author HaiTao Zhang * @author Franjo Zilic + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class RabbitAutoConfigurationTests { @@ -173,10 +174,10 @@ class RabbitAutoConfigurationTests { given(rcf.newConnection(isNull(), eq(addresses), anyString())).willReturn(mock(Connection.class)); ReflectionTestUtils.setField(connectionFactory, "rabbitConnectionFactory", rcf); connectionFactory.createConnection(); - verify(rcf).newConnection(isNull(), eq(addresses), eq("test#0")); + then(rcf).should().newConnection(isNull(), eq(addresses), eq("test#0")); connectionFactory.resetConnection(); connectionFactory.createConnection(); - verify(rcf).newConnection(isNull(), eq(addresses), eq("test#1")); + then(rcf).should().newConnection(isNull(), eq(addresses), eq("test#1")); }); } @@ -354,10 +355,11 @@ class RabbitAutoConfigurationTests { RabbitTemplate template = mock(RabbitTemplate.class); ConnectionFactory connectionFactory = mock(ConnectionFactory.class); configurer.configure(template, connectionFactory); - verify(template).setMessageConverter(context.getBean("myMessageConverter", MessageConverter.class)); - verify(template).setExchange("my-exchange"); - verify(template).setRoutingKey("my-routing-key"); - verify(template).setDefaultReceiveQueue("default-queue"); + then(template).should() + .setMessageConverter(context.getBean("myMessageConverter", MessageConverter.class)); + then(template).should().setExchange("my-exchange"); + then(template).should().setRoutingKey("my-routing-key"); + then(template).should().setDefaultReceiveQueue("default-queue"); }); } @@ -428,7 +430,7 @@ class RabbitAutoConfigurationTests { SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context .getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class); rabbitListenerContainerFactory.setBatchSize(10); - verify(rabbitListenerContainerFactory).setBatchSize(10); + then(rabbitListenerContainerFactory).should().setBatchSize(10); assertThat(rabbitListenerContainerFactory.getAdviceChain()).isNull(); }); } @@ -548,9 +550,9 @@ class RabbitAutoConfigurationTests { .getBean(SimpleRabbitListenerContainerFactoryConfigurer.class); SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class); configurer.configure(factory, mock(ConnectionFactory.class)); - verify(factory).setConcurrentConsumers(5); - verify(factory).setMaxConcurrentConsumers(10); - verify(factory).setPrefetchCount(40); + then(factory).should().setConcurrentConsumers(5); + then(factory).should().setMaxConcurrentConsumers(10); + then(factory).should().setPrefetchCount(40); }); } @@ -562,7 +564,7 @@ class RabbitAutoConfigurationTests { .getBean(SimpleRabbitListenerContainerFactoryConfigurer.class); SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class); configurer.configure(factory, mock(ConnectionFactory.class)); - verify(factory).setConsumerBatchEnabled(true); + then(factory).should().setConsumerBatchEnabled(true); }); } @@ -577,9 +579,9 @@ class RabbitAutoConfigurationTests { .getBean(DirectRabbitListenerContainerFactoryConfigurer.class); DirectRabbitListenerContainerFactory factory = mock(DirectRabbitListenerContainerFactory.class); configurer.configure(factory, mock(ConnectionFactory.class)); - verify(factory).setConsumersPerQueue(5); - verify(factory).setPrefetchCount(40); - verify(factory).setDeBatchingEnabled(false); + then(factory).should().setConsumersPerQueue(5); + then(factory).should().setPrefetchCount(40); + then(factory).should().setDeBatchingEnabled(false); }); } @@ -602,7 +604,7 @@ class RabbitAutoConfigurationTests { Message message = mock(Message.class); Exception ex = new Exception("test"); mir.recover(new Object[] { "foo", message }, ex); - verify(messageRecoverer).recover(message, ex); + then(messageRecoverer).should().recover(message, ex); RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(advice, "retryOperations"); assertThat(retryTemplate).isNotNull(); SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) ReflectionTestUtils.getField(retryTemplate, "retryPolicy"); @@ -843,8 +845,8 @@ class RabbitAutoConfigurationTests { ConnectionFactoryCustomizer.class); InOrder inOrder = inOrder(firstCustomizer, secondCustomizer); com.rabbitmq.client.ConnectionFactory targetConnectionFactory = getTargetConnectionFactory(context); - inOrder.verify(firstCustomizer).customize(targetConnectionFactory); - inOrder.verify(secondCustomizer).customize(targetConnectionFactory); + then(firstCustomizer).should(inOrder).customize(targetConnectionFactory); + then(secondCustomizer).should(inOrder).customize(targetConnectionFactory); inOrder.verifyNoMoreInteractions(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java index f4b9740b33..6e7f8081f9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java @@ -23,13 +23,14 @@ import org.junit.jupiter.api.Test; import org.springframework.core.io.DefaultResourceLoader; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link BatchDataSourceInitializer}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class BatchDataSourceInitializerTests { @@ -41,7 +42,7 @@ class BatchDataSourceInitializerTests { BatchDataSourceInitializer initializer = new BatchDataSourceInitializer(dataSource, new DefaultResourceLoader(), properties); assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); + then(dataSource).shouldHaveNoInteractions(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java index fb31156f8a..7a707129c6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java @@ -31,13 +31,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Integration tests for {@link CassandraAutoConfiguration}. * * @author Andy Wilkinson + * @author Yanming Zhou */ @Testcontainers(disabledWithoutDocker = true) class CassandraAutoConfigurationIntegrationTests { @@ -61,7 +62,7 @@ class CassandraAutoConfigurationIntegrationTests { context.getBean(CqlSession.class); DriverConfigLoader driverConfigLoader = context.getBean(DriverConfigLoader.class); context.close(); - verify(driverConfigLoader).close(); + then(driverConfigLoader).should().close(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java index e78e03aec8..4347dbd0de 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java @@ -41,14 +41,14 @@ import org.springframework.core.type.filter.AnnotationTypeFilter; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link EntityScanner}. * * @author Phillip Webb + * @author Yanming Zhou */ class EntityScannerTests { @@ -112,10 +112,10 @@ class EntityScannerTests { TestEntityScanner scanner = new TestEntityScanner(context, candidateComponentProvider); scanner.scan(Entity.class); ArgumentCaptor annotationTypeFilter = ArgumentCaptor.forClass(AnnotationTypeFilter.class); - verify(candidateComponentProvider).addIncludeFilter(annotationTypeFilter.capture()); - verify(candidateComponentProvider) + then(candidateComponentProvider).should().addIncludeFilter(annotationTypeFilter.capture()); + then(candidateComponentProvider).should() .findCandidateComponents("org.springframework.boot.autoconfigure.domain.scan"); - verifyNoMoreInteractions(candidateComponentProvider); + then(candidateComponentProvider).shouldHaveNoMoreInteractions(); assertThat(annotationTypeFilter.getValue().getAnnotationType()).isEqualTo(Entity.class); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java index bb7b457beb..43e20819eb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java @@ -40,8 +40,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link ElasticsearchRestClientAutoConfiguration}. @@ -223,7 +223,7 @@ class ElasticsearchRestClientAutoConfigurationTests { assertThat(context).hasSingleBean(Sniffer.class); Sniffer sniffer = context.getBean(Sniffer.class); assertThat(sniffer).isSameAs(customSniffer); - verifyNoInteractions(customSniffer); + then(customSniffer).shouldHaveNoInteractions(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java index e2d35d5382..874b2576c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.core.io.DefaultResourceLoader; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link IntegrationDataSourceInitializer}. @@ -41,7 +41,7 @@ class IntegrationDataSourceInitializerTests { IntegrationDataSourceInitializer initializer = new IntegrationDataSourceInitializer(dataSource, new DefaultResourceLoader(), properties); assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); + then(dataSource).shouldHaveNoInteractions(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java index d405bb7f0b..05abebf7db 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java @@ -31,14 +31,15 @@ import org.springframework.jdbc.BadSqlGrammarException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.never; /** * Tests for {@link JooqExceptionTranslator} * * @author Andy Wilkinson + * @author Yanming Zhou */ class JooqExceptionTranslatorTests { @@ -54,7 +55,7 @@ class JooqExceptionTranslatorTests { given(context.sqlException()).willReturn(sqlException); this.exceptionTranslator.exception(context); ArgumentCaptor captor = ArgumentCaptor.forClass(RuntimeException.class); - verify(context).exception(captor.capture()); + then(context).should().exception(captor.capture()); assertThat(captor.getValue()).isInstanceOf(BadSqlGrammarException.class); } @@ -66,7 +67,7 @@ class JooqExceptionTranslatorTests { given(configuration.dialect()).willReturn(SQLDialect.POSTGRES); given(context.sqlException()).willReturn(new SQLException(null, null, 123456789)); this.exceptionTranslator.exception(context); - verify(context, times(0)).exception(any()); + then(context).should(never()).exception(any()); } static Object[] exceptionTranslation() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java index 98d10be1db..c7e44cd3e6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java @@ -33,14 +33,15 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link JooqProperties}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class JooqPropertiesTests { @@ -59,7 +60,7 @@ class JooqPropertiesTests { DataSource dataSource = mockStandaloneDataSource(); SQLDialect sqlDialect = properties.determineSqlDialect(dataSource); assertThat(sqlDialect).isEqualTo(SQLDialect.POSTGRES); - verify(dataSource, never()).getConnection(); + then(dataSource).should(never()).getConnection(); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index e5b0095d83..3b88eee9c1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -75,9 +75,9 @@ import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link KafkaAutoConfiguration}. @@ -86,6 +86,7 @@ import static org.mockito.Mockito.verify; * @author Stephane Nicoll * @author Eddú Meléndez * @author Nakul Mishra + * @author Yanming Zhou */ class KafkaAutoConfigurationTests { @@ -332,10 +333,10 @@ class KafkaAutoConfigurationTests { .asProperties(); assertThat((List) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) .containsExactly("localhost:9092", "localhost:9093"); - verify(context.getBean("&firstStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class), never()) - .setAutoStartup(false); - verify(context.getBean("&secondStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class), - never()).setAutoStartup(false); + then(context.getBean("&firstStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class)) + .should(never()).setAutoStartup(false); + then(context.getBean("&secondStreamsBuilderFactoryBean", StreamsBuilderFactoryBean.class)) + .should(never()).setAutoStartup(false); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java index b8eede2a23..a1dcd6d29a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java @@ -37,16 +37,16 @@ import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link MailSenderAutoConfiguration}. * * @author Stephane Nicoll * @author Eddú Meléndez + * @author Yanming Zhou */ class MailSenderAutoConfigurationTests { @@ -223,7 +223,7 @@ class MailSenderAutoConfigurationTests { .withPropertyValues("spring.mail.host:10.0.0.23", "spring.mail.test-connection:true").run((context) -> { assertThat(context).hasSingleBean(JavaMailSenderImpl.class); JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class); - verify(mailSender, times(1)).testConnection(); + then(mailSender).should().testConnection(); }); } @@ -234,7 +234,7 @@ class MailSenderAutoConfigurationTests { .run((context) -> { assertThat(context).hasSingleBean(JavaMailSenderImpl.class); JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class); - verify(mailSender, never()).testConnection(); + then(mailSender).should(never()).testConnection(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java index 6e697ea881..84a9232a3a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -30,8 +30,8 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link MongoClientFactorySupport}. @@ -43,6 +43,7 @@ import static org.mockito.Mockito.verify; * @author Mark Paluch * @author Artsiom Yudovin * @author Scott Frederick + * @author Yanming Zhou */ abstract class MongoClientFactorySupportTests { @@ -97,7 +98,7 @@ abstract class MongoClientFactorySupportTests { void customizerIsInvoked() { MongoClientSettingsBuilderCustomizer customizer = mock(MongoClientSettingsBuilderCustomizer.class); createMongoClient(customizer); - verify(customizer).customize(any(MongoClientSettings.Builder.class)); + then(customizer).should().customize(any(MongoClientSettings.Builder.class)); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java index 0e9b84db6f..de2f2741e5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java @@ -36,8 +36,8 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link HibernateProperties}. @@ -45,6 +45,7 @@ import static org.mockito.Mockito.verify; * @author Stephane Nicoll * @author Artsiom Yudovin * @author Chris Bono + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HibernatePropertiesTests { @@ -141,14 +142,14 @@ class HibernatePropertiesTests { assertThat(hibernateProperties).doesNotContainKey(AvailableSettings.HBM2DDL_AUTO); assertThat(hibernateProperties).containsEntry(AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create"); - verify(this.ddlAutoSupplier, never()).get(); + then(this.ddlAutoSupplier).should(never()).get(); })); } private ContextConsumer assertDefaultDdlAutoNotInvoked(String expectedDdlAuto) { return assertHibernateProperties((hibernateProperties) -> { assertThat(hibernateProperties).containsEntry(AvailableSettings.HBM2DDL_AUTO, expectedDdlAuto); - verify(this.ddlAutoSupplier, never()).get(); + then(this.ddlAutoSupplier).should(never()).get(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java index f8d6f6769f..5fdedbfbdb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java @@ -70,8 +70,8 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.util.Assert; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link QuartzAutoConfiguration}. @@ -172,7 +172,7 @@ class QuartzAutoConfigurationTests { Scheduler scheduler = context.getBean(Scheduler.class); assertThat(scheduler.getMetaData().getThreadPoolSize()).isEqualTo(50); Executor executor = context.getBean(Executor.class); - verifyNoInteractions(executor); + then(executor).shouldHaveNoInteractions(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java index 622c6d9c77..4099cd3396 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java @@ -23,13 +23,14 @@ import org.junit.jupiter.api.Test; import org.springframework.core.io.DefaultResourceLoader; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link JdbcSessionDataSourceInitializer}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class JdbcSessionDataSourceInitializerTests { @@ -41,7 +42,7 @@ class JdbcSessionDataSourceInitializerTests { JdbcSessionDataSourceInitializer initializer = new JdbcSessionDataSourceInitializer(dataSource, new DefaultResourceLoader(), properties); assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); + then(dataSource).shouldHaveNoInteractions(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java index d21ad5c84b..b3c7ce676f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java @@ -36,14 +36,14 @@ import org.springframework.session.jdbc.JdbcIndexedSessionRepository; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Hazelcast specific tests for {@link SessionAutoConfiguration}. * * @author Vedran Pavic + * @author Yanming Zhou */ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigurationTests { @@ -80,7 +80,7 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur assertThat(repository).hasFieldOrPropertyWithValue("defaultMaxInactiveInterval", (int) new ServerProperties().getServlet().getSession().getTimeout().getSeconds()); HazelcastInstance hazelcastInstance = context.getBean(HazelcastInstance.class); - verify(hazelcastInstance, times(1)).getMap("spring:session:sessions"); + then(hazelcastInstance).should().getMap("spring:session:sessions"); } @Test @@ -89,7 +89,7 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur "spring.session.hazelcast.map-name=foo:bar:biz").run((context) -> { validateSessionRepository(context, Hazelcast4IndexedSessionRepository.class); HazelcastInstance hazelcastInstance = context.getBean(HazelcastInstance.class); - verify(hazelcastInstance, times(1)).getMap("foo:bar:biz"); + then(hazelcastInstance).should().getMap("foo:bar:biz"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java index 7d7286b1c3..8f9124946a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -22,13 +22,14 @@ import java.util.function.Supplier; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link SessionProperties}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class SessionPropertiesTests { @@ -39,7 +40,7 @@ class SessionPropertiesTests { properties.setTimeout(Duration.ofMinutes(1)); Supplier fallback = mock(Supplier.class); assertThat(properties.determineTimeout(fallback)).isEqualTo(Duration.ofMinutes(1)); - verifyNoInteractions(fallback); + then(fallback).shouldHaveNoInteractions(); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java index da16bf270e..648e811bde 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java @@ -43,14 +43,15 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link TaskExecutionAutoConfiguration}. * * @author Stephane Nicoll * @author Camille Vienot + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class TaskExecutionAutoConfigurationTests { @@ -119,7 +120,7 @@ class TaskExecutionAutoConfigurationTests { this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> { TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class); ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build(); - verify(customizer).customize(executor); + then(customizer).should().customize(executor); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java index e89efe4468..17beff24d7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -32,14 +32,15 @@ import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link TemplateAvailabilityProviders}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class TemplateAvailabilityProvidersTests { @@ -76,7 +77,7 @@ class TemplateAvailabilityProvidersTests { given(applicationContext.getClassLoader()).willReturn(this.classLoader); TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders(applicationContext); assertThat(providers.getProviders()).isNotEmpty(); - verify(applicationContext).getClassLoader(); + then(applicationContext).should().getClassLoader(); } @Test @@ -145,7 +146,8 @@ class TemplateAvailabilityProvidersTests { TemplateAvailabilityProvider found = this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); assertThat(found).isNull(); - verify(this.provider).isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader); + then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader, + this.resourceLoader); } @Test @@ -164,7 +166,7 @@ class TemplateAvailabilityProvidersTests { .willReturn(true); this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); - verify(this.provider, times(1)).isTemplateAvailable(this.view, this.environment, this.classLoader, + then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader); } @@ -172,7 +174,7 @@ class TemplateAvailabilityProvidersTests { void getProviderShouldCacheNoMatchResult() { this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); - verify(this.provider, times(1)).isTemplateAvailable(this.view, this.environment, this.classLoader, + then(this.provider).should().isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader); } @@ -183,7 +185,7 @@ class TemplateAvailabilityProvidersTests { this.environment.setProperty("spring.template.provider.cache", "false"); this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); this.providers.getProvider(this.view, this.environment, this.classLoader, this.resourceLoader); - verify(this.provider, times(2)).isTemplateAvailable(this.view, this.environment, this.classLoader, + then(this.provider).should(times(2)).isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java index ba698845ee..0804cbc291 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java @@ -33,16 +33,16 @@ import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ValidatorAdapter}. * * @author Stephane Nicoll * @author Madhura Bhave + * @author Yanming Zhou */ class ValidatorAdapterTests { @@ -63,11 +63,11 @@ class ValidatorAdapterTests { void wrapperInvokesCallbackOnNonManagedBean() { this.contextRunner.withUserConfiguration(NonManagedBeanConfig.class).run((context) -> { LocalValidatorFactoryBean validator = context.getBean(NonManagedBeanConfig.class).validator; - verify(validator, times(1)).setApplicationContext(any(ApplicationContext.class)); - verify(validator, times(1)).afterPropertiesSet(); - verify(validator, never()).destroy(); + then(validator).should().setApplicationContext(any(ApplicationContext.class)); + then(validator).should().afterPropertiesSet(); + then(validator).should(never()).destroy(); context.close(); - verify(validator, times(1)).destroy(); + then(validator).should().destroy(); }); } @@ -75,11 +75,11 @@ class ValidatorAdapterTests { void wrapperDoesNotInvokeCallbackOnManagedBean() { this.contextRunner.withUserConfiguration(ManagedBeanConfig.class).run((context) -> { LocalValidatorFactoryBean validator = context.getBean(ManagedBeanConfig.class).validator; - verify(validator, never()).setApplicationContext(any(ApplicationContext.class)); - verify(validator, never()).afterPropertiesSet(); - verify(validator, never()).destroy(); + then(validator).should(never()).setApplicationContext(any(ApplicationContext.class)); + then(validator).should(never()).afterPropertiesSet(); + then(validator).should(never()).destroy(); context.close(); - verify(validator, never()).destroy(); + then(validator).should(never()).destroy(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java index ed5767c4e5..381479cac9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -44,15 +44,15 @@ import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link RestTemplateAutoConfiguration} * * @author Stephane Nicoll * @author Phillip Webb + * @author Yaming Zhou */ class RestTemplateAutoConfigurationTests { @@ -115,7 +115,7 @@ class RestTemplateAutoConfigurationTests { assertThat(context).hasSingleBean(RestTemplate.class); RestTemplate restTemplate = context.getBean(RestTemplate.class); RestTemplateCustomizer customizer = context.getBean(RestTemplateCustomizer.class); - verify(customizer).customize(restTemplate); + then(customizer).should().customize(restTemplate); }); } @@ -128,7 +128,7 @@ class RestTemplateAutoConfigurationTests { assertThat(restTemplate.getMessageConverters()).hasSize(1); assertThat(restTemplate.getMessageConverters().get(0)) .isInstanceOf(CustomHttpMessageConverter.class); - verifyNoInteractions(context.getBean(RestTemplateCustomizer.class)); + then(context.getBean(RestTemplateCustomizer.class)).shouldHaveNoInteractions(); }); } @@ -143,7 +143,7 @@ class RestTemplateAutoConfigurationTests { assertThat(restTemplate.getMessageConverters().get(0)) .isInstanceOf(CustomHttpMessageConverter.class); RestTemplateCustomizer customizer = context.getBean(RestTemplateCustomizer.class); - verify(customizer).customize(restTemplate); + then(customizer).should().customize(restTemplate); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java index 04330276d6..2728a5a3f6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java @@ -54,8 +54,8 @@ import org.springframework.test.context.support.TestPropertySourceUtils; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link JettyWebServerFactoryCustomizer}. @@ -63,6 +63,7 @@ import static org.mockito.Mockito.verify; * @author Brian Clozel * @author Phillip Webb * @author HaiTao Zhang + * @author Yanming Zhou */ class JettyWebServerFactoryCustomizerTests { @@ -85,14 +86,14 @@ class JettyWebServerFactoryCustomizerTests { this.environment.setProperty("DYNO", "-"); ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test void defaultUseForwardHeaders() { ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } @Test @@ -100,7 +101,7 @@ class JettyWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE); ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test @@ -109,7 +110,7 @@ class JettyWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE); ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } @Test @@ -256,7 +257,7 @@ class JettyWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ForwardHeadersStrategy.NATIVE); ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java index 7bd0e43703..91e14df400 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java @@ -39,10 +39,10 @@ import org.springframework.util.unit.DataSize; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link NettyWebServerFactoryCustomizer}. @@ -75,14 +75,14 @@ class NettyWebServerFactoryCustomizerTests { this.environment.setProperty("DYNO", "-"); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test void defaultUseForwardHeaders() { NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } @Test @@ -90,7 +90,7 @@ class NettyWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test @@ -99,7 +99,7 @@ class NettyWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } @Test @@ -120,7 +120,7 @@ class NettyWebServerFactoryCustomizerTests { nettyProperties.setMaxInitialLineLength(DataSize.ofKilobytes(32)); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); - verify(factory, times(1)).addServerCustomizers(this.customizerCaptor.capture()); + then(factory).should().addServerCustomizers(this.customizerCaptor.capture()); NettyServerCustomizer serverCustomizer = this.customizerCaptor.getValue(); HttpServer httpServer = serverCustomizer.apply(HttpServer.create()); HttpRequestDecoderSpec decoder = httpServer.configuration().decoder(); @@ -133,10 +133,10 @@ class NettyWebServerFactoryCustomizerTests { private void verifyConnectionTimeout(NettyReactiveWebServerFactory factory, Integer expected) { if (expected == null) { - verify(factory, never()).addServerCustomizers(any(NettyServerCustomizer.class)); + then(factory).should(never()).addServerCustomizers(any(NettyServerCustomizer.class)); return; } - verify(factory, times(2)).addServerCustomizers(this.customizerCaptor.capture()); + then(factory).should(times(2)).addServerCustomizers(this.customizerCaptor.capture()); NettyServerCustomizer serverCustomizer = this.customizerCaptor.getAllValues().get(0); HttpServer httpServer = serverCustomizer.apply(HttpServer.create()); Map, ?> options = httpServer.configuration().options(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java index 956868162b..08882af77b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -41,9 +41,9 @@ import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willAnswer; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link UndertowWebServerFactoryCustomizer}. @@ -53,6 +53,7 @@ import static org.mockito.Mockito.verify; * @author Artsiom Yudovin * @author Rafiullah Hamedy * @author HaiTao Zhang + * @author Yanming Zhou */ class UndertowWebServerFactoryCustomizerTests { @@ -77,12 +78,12 @@ class UndertowWebServerFactoryCustomizerTests { "server.undertow.accesslog.dir=test-logs", "server.undertow.accesslog.rotate=false"); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setAccessLogEnabled(true); - verify(factory).setAccessLogPattern("foo"); - verify(factory).setAccessLogPrefix("test_log"); - verify(factory).setAccessLogSuffix("txt"); - verify(factory).setAccessLogDirectory(new File("test-logs")); - verify(factory).setAccessLogRotate(false); + then(factory).should().setAccessLogEnabled(true); + then(factory).should().setAccessLogPattern("foo"); + then(factory).should().setAccessLogPrefix("test_log"); + then(factory).should().setAccessLogSuffix("txt"); + then(factory).should().setAccessLogDirectory(new File("test-logs")); + then(factory).should().setAccessLogRotate(false); } @Test @@ -138,7 +139,7 @@ class UndertowWebServerFactoryCustomizerTests { bind("server.undertow.threads.io=4"); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setIoThreads(4); + then(factory).should().setIoThreads(4); } @Test @@ -146,7 +147,7 @@ class UndertowWebServerFactoryCustomizerTests { bind("server.undertow.threads.worker=10"); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setWorkerThreads(10); + then(factory).should().setWorkerThreads(10); } @Test @@ -202,14 +203,14 @@ class UndertowWebServerFactoryCustomizerTests { this.environment.setProperty("DYNO", "-"); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test void defaultUseForwardHeaders() { ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } @Test @@ -217,7 +218,7 @@ class UndertowWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NATIVE); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(true); + then(factory).should().setUseForwardHeaders(true); } @Test @@ -226,7 +227,7 @@ class UndertowWebServerFactoryCustomizerTests { this.serverProperties.setForwardHeadersStrategy(ServerProperties.ForwardHeadersStrategy.NONE); ConfigurableUndertowWebServerFactory factory = mock(ConfigurableUndertowWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setUseForwardHeaders(false); + then(factory).should().setUseForwardHeaders(false); } private T boundServerOption(Option option) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java index e41159b4d5..8cbc42be71 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -53,9 +53,8 @@ import org.springframework.web.server.adapter.ForwardedHeaderTransformer; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ReactiveWebServerFactoryAutoConfiguration}. @@ -63,6 +62,7 @@ import static org.mockito.Mockito.verify; * @author Brian Clozel * @author Raheela Aslam * @author Madhura Bhave + * @author Yanming Zhou */ class ReactiveWebServerFactoryAutoConfigurationTests { @@ -128,7 +128,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class); assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Connector.class)); + then(customizer).should().customize(any(Connector.class)); }); } @@ -145,7 +145,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class); assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Connector.class)); + then(customizer).should().customize(any(Connector.class)); }); } @@ -161,7 +161,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class); TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class); assertThat(factory.getTomcatContextCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Context.class)); + then(customizer).should().customize(any(Context.class)); }); } @@ -177,7 +177,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class); TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class); assertThat(factory.getTomcatContextCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Context.class)); + then(customizer).should().customize(any(Context.class)); }); } @@ -194,7 +194,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatProtocolHandlerCustomizer customizer = context.getBean("protocolHandlerCustomizer", TomcatProtocolHandlerCustomizer.class); assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any()); + then(customizer).should().customize(any()); }); } @@ -211,7 +211,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { TomcatProtocolHandlerCustomizer customizer = context.getBean("protocolHandlerCustomizer", TomcatProtocolHandlerCustomizer.class); assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any()); + then(customizer).should().customize(any()); }); } @@ -238,7 +238,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { JettyReactiveWebServerFactory factory = context.getBean(JettyReactiveWebServerFactory.class); JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class); assertThat(factory.getServerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Server.class)); + then(customizer).should().customize(any(Server.class)); }); } @@ -266,7 +266,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer", UndertowBuilderCustomizer.class); assertThat(factory.getBuilderCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Builder.class)); + then(customizer).should().customize(any(Builder.class)); }); } @@ -293,7 +293,7 @@ class ReactiveWebServerFactoryAutoConfigurationTests { NettyReactiveWebServerFactory factory = context.getBean(NettyReactiveWebServerFactory.class); NettyServerCustomizer customizer = context.getBean("serverCustomizer", NettyServerCustomizer.class); assertThat(factory.getServerCustomizers()).contains(customizer); - verify(customizer, times(1)).apply(any(HttpServer.class)); + then(customizer).should().apply(any(HttpServer.class)); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java index dba8b407f1..68e7a5d801 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -28,14 +28,15 @@ import org.springframework.boot.web.server.Shutdown; import org.springframework.boot.web.server.Ssl; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ReactiveWebServerFactoryCustomizer}. * * @author Brian Clozel * @author Yunkun Huang + * @author Yanming Zhou */ class ReactiveWebServerFactoryCustomizerTests { @@ -53,7 +54,7 @@ class ReactiveWebServerFactoryCustomizerTests { ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class); this.properties.setPort(9000); this.customizer.customize(factory); - verify(factory).setPort(9000); + then(factory).should().setPort(9000); } @Test @@ -62,7 +63,7 @@ class ReactiveWebServerFactoryCustomizerTests { InetAddress address = mock(InetAddress.class); this.properties.setAddress(address); this.customizer.customize(factory); - verify(factory).setAddress(address); + then(factory).should().setAddress(address); } @Test @@ -71,7 +72,7 @@ class ReactiveWebServerFactoryCustomizerTests { Ssl ssl = mock(Ssl.class); this.properties.setSsl(ssl); this.customizer.customize(factory); - verify(factory).setSsl(ssl); + then(factory).should().setSsl(ssl); } @Test @@ -80,7 +81,7 @@ class ReactiveWebServerFactoryCustomizerTests { ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class); this.customizer.customize(factory); ArgumentCaptor shutdownCaptor = ArgumentCaptor.forClass(Shutdown.class); - verify(factory).setShutdown(shutdownCaptor.capture()); + then(factory).should().setShutdown(shutdownCaptor.capture()); assertThat(shutdownCaptor.getValue()).isEqualTo(Shutdown.GRACEFUL); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index 2821f85ab4..8499883a0c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -92,8 +92,8 @@ import org.springframework.web.util.pattern.PathPattern; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link WebFluxAutoConfiguration}. @@ -101,6 +101,7 @@ import static org.mockito.Mockito.verify; * @author Brian Clozel * @author Andy Wilkinson * @author Artsiom Yudovin + * @author Yanming Zhou */ class WebFluxAutoConfigurationTests { @@ -148,7 +149,7 @@ class WebFluxAutoConfigurationTests { this.contextRunner.withUserConfiguration(CustomCodecCustomizers.class).run((context) -> { CodecCustomizer codecCustomizer = context.getBean("firstCodecCustomizer", CodecCustomizer.class); assertThat(codecCustomizer).isNotNull(); - verify(codecCustomizer).customize(any(ServerCodecConfigurer.class)); + then(codecCustomizer).should().customize(any(ServerCodecConfigurer.class)); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java index 4826257c9b..bc89ad0a9b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java @@ -34,14 +34,14 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ClientHttpConnectorAutoConfiguration} * * @author Brian Clozel + * @author Yanming Zhou */ class ClientHttpConnectorAutoConfigurationTests { @@ -94,7 +94,7 @@ class ClientHttpConnectorAutoConfigurationTests { WebClientCustomizer clientCustomizer = context.getBean(WebClientCustomizer.class); WebClient.Builder builder = mock(WebClient.Builder.class); clientCustomizer.customize(builder); - verify(builder, times(1)).clientConnector(any(ReactorClientHttpConnector.class)); + then(builder).should().clientConnector(any(ReactorClientHttpConnector.class)); }); } @@ -106,7 +106,7 @@ class ClientHttpConnectorAutoConfigurationTests { WebClientCustomizer clientCustomizer = context.getBean(WebClientCustomizer.class); WebClient.Builder builder = mock(WebClient.Builder.class); clientCustomizer.customize(builder); - verify(builder, times(1)).clientConnector(any(ClientHttpConnector.class)); + then(builder).should().clientConnector(any(ClientHttpConnector.class)); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java index 98e6081a65..6e5c7adc52 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -40,14 +40,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link WebClientAutoConfiguration} * * @author Brian Clozel + * @author Yanming Zhou */ class WebClientAutoConfigurationTests { @@ -71,7 +72,7 @@ class WebClientAutoConfigurationTests { WebClientCodecCustomizer clientCustomizer = context.getBean(WebClientCodecCustomizer.class); builder.build(); assertThat(clientCustomizer).isNotNull(); - verify(codecCustomizer).customize(any(CodecConfigurer.class)); + then(codecCustomizer).should().customize(any(CodecConfigurer.class)); }); } @@ -81,7 +82,7 @@ class WebClientAutoConfigurationTests { WebClient.Builder builder = context.getBean(WebClient.Builder.class); WebClientCustomizer customizer = context.getBean("webClientCustomizer", WebClientCustomizer.class); builder.build(); - verify(customizer).customize(any(WebClient.Builder.class)); + then(customizer).should().customize(any(WebClient.Builder.class)); }); } @@ -102,11 +103,12 @@ class WebClientAutoConfigurationTests { assertThat(firstBuilder).isNotEqualTo(secondBuilder); firstBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30)); secondBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30)); - verify(firstConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")), any()); - verify(secondConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")), + then(firstConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")), + any()); + then(secondConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")), any()); WebClientCustomizer customizer = context.getBean("webClientCustomizer", WebClientCustomizer.class); - verify(customizer, times(2)).customize(any(WebClient.Builder.class)); + then(customizer).should(times(2)).customize(any(WebClient.Builder.class)); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java index 046ab5d402..442477a056 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java @@ -63,9 +63,8 @@ import org.springframework.web.servlet.FrameworkServlet; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletWebServerFactoryAutoConfiguration}. @@ -75,6 +74,7 @@ import static org.mockito.Mockito.verify; * @author Stephane Nicoll * @author Raheela Aslam * @author Madhura Bhave + * @author Yanming Zhou */ class ServletWebServerFactoryAutoConfigurationTests { @@ -176,7 +176,7 @@ class ServletWebServerFactoryAutoConfigurationTests { JettyServletWebServerFactory factory = context.getBean(JettyServletWebServerFactory.class); JettyServerCustomizer customizer = context.getBean("serverCustomizer", JettyServerCustomizer.class); assertThat(factory.getServerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Server.class)); + then(customizer).should().customize(any(Server.class)); }); } @@ -207,7 +207,7 @@ class ServletWebServerFactoryAutoConfigurationTests { UndertowDeploymentInfoCustomizer customizer = context.getBean("deploymentInfoCustomizer", UndertowDeploymentInfoCustomizer.class); assertThat(factory.getDeploymentInfoCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(DeploymentInfo.class)); + then(customizer).should().customize(any(DeploymentInfo.class)); }); } @@ -224,7 +224,7 @@ class ServletWebServerFactoryAutoConfigurationTests { UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer", UndertowBuilderCustomizer.class); assertThat(factory.getBuilderCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Builder.class)); + then(customizer).should().customize(any(Builder.class)); }); } @@ -265,7 +265,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class); assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Connector.class)); + then(customizer).should().customize(any(Connector.class)); }); } @@ -281,7 +281,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatConnectorCustomizer customizer = context.getBean("connectorCustomizer", TomcatConnectorCustomizer.class); assertThat(factory.getTomcatConnectorCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Connector.class)); + then(customizer).should().customize(any(Connector.class)); }); } @@ -296,7 +296,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class); TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class); assertThat(factory.getTomcatContextCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Context.class)); + then(customizer).should().customize(any(Context.class)); }); } @@ -311,7 +311,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class); TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class); assertThat(factory.getTomcatContextCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any(Context.class)); + then(customizer).should().customize(any(Context.class)); }); } @@ -327,7 +327,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatProtocolHandlerCustomizer customizer = context.getBean("protocolHandlerCustomizer", TomcatProtocolHandlerCustomizer.class); assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any()); + then(customizer).should().customize(any()); }); } @@ -343,7 +343,7 @@ class ServletWebServerFactoryAutoConfigurationTests { TomcatProtocolHandlerCustomizer customizer = context.getBean("protocolHandlerCustomizer", TomcatProtocolHandlerCustomizer.class); assertThat(factory.getTomcatProtocolHandlerCustomizers()).contains(customizer); - verify(customizer, times(1)).customize(any()); + then(customizer).should().customize(any()); }); } @@ -377,7 +377,7 @@ class ServletWebServerFactoryAutoConfigurationTests { MockServletWebServerFactory factory = context.getBean(MockServletWebServerFactory.class); Servlet servlet = context.getBean(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME, Servlet.class); - verify(factory.getServletContext()).addServlet("dispatcherServlet", servlet); + then(factory.getServletContext()).should().addServlet("dispatcherServlet", servlet); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java index f48db359c6..3ae32e93dd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java @@ -38,14 +38,15 @@ import org.springframework.boot.web.servlet.server.Session.Cookie; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletWebServerFactoryCustomizer}. * * @author Brian Clozel * @author Yunkun Huang + * @author Yanming Zhou */ class ServletWebServerFactoryCustomizerTests { @@ -62,7 +63,7 @@ class ServletWebServerFactoryCustomizerTests { void testDefaultDisplayName() { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setDisplayName("application"); + then(factory).should().setDisplayName("application"); } @Test @@ -70,7 +71,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.properties.getServlet().setApplicationDisplayName("TestName"); this.customizer.customize(factory); - verify(factory).setDisplayName("TestName"); + then(factory).should().setDisplayName("TestName"); } @Test @@ -78,7 +79,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.properties.getServlet().setRegisterDefaultServlet(false); this.customizer.customize(factory); - verify(factory).setRegisterDefaultServlet(false); + then(factory).should().setRegisterDefaultServlet(false); } @Test @@ -87,14 +88,14 @@ class ServletWebServerFactoryCustomizerTests { Ssl ssl = mock(Ssl.class); this.properties.setSsl(ssl); this.customizer.customize(factory); - verify(factory).setSsl(ssl); + then(factory).should().setSsl(ssl); } @Test void testCustomizeJsp() { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setJsp(any(Jsp.class)); + then(factory).should().setJsp(any(Jsp.class)); } @Test @@ -113,7 +114,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); ArgumentCaptor sessionCaptor = ArgumentCaptor.forClass(Session.class); - verify(factory).setSession(sessionCaptor.capture()); + then(factory).should().setSession(sessionCaptor.capture()); assertThat(sessionCaptor.getValue().getTimeout()).hasSeconds(123); Cookie cookie = sessionCaptor.getValue().getCookie(); assertThat(cookie.getName()).isEqualTo("testname"); @@ -130,7 +131,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.properties.setPort(8080); this.customizer.customize(factory); - verify(factory).setPort(8080); + then(factory).should().setPort(8080); } @Test @@ -140,7 +141,7 @@ class ServletWebServerFactoryCustomizerTests { bindProperties(map); ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); - verify(factory).setDisplayName("MyBootApp"); + then(factory).should().setDisplayName("MyBootApp"); } @Test @@ -159,7 +160,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); ArgumentCaptor sessionCaptor = ArgumentCaptor.forClass(Session.class); - verify(factory).setSession(sessionCaptor.capture()); + then(factory).should().setSession(sessionCaptor.capture()); assertThat(sessionCaptor.getValue().getStoreDir()).isEqualTo(new File("mydirectory")); } @@ -171,7 +172,7 @@ class ServletWebServerFactoryCustomizerTests { ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); this.customizer.customize(factory); ArgumentCaptor shutdownCaptor = ArgumentCaptor.forClass(Shutdown.class); - verify(factory).setShutdown(shutdownCaptor.capture()); + then(factory).should().setShutdown(shutdownCaptor.capture()); assertThat(shutdownCaptor.getValue()).isEqualTo(Shutdown.GRACEFUL); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java index b40d7557c7..625f32f806 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java @@ -32,13 +32,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link WebServer}s driving {@link ServletContextListener}s correctly * * @author Andy Wilkinson + * @author Yanming Zhou */ class ServletWebServerServletContextListenerTests { @@ -77,7 +78,7 @@ class ServletWebServerServletContextListenerTests { ServletContextListenerBeanConfiguration.class, configuration); ServletContextListener servletContextListener = context.getBean("servletContextListener", ServletContextListener.class); - verify(servletContextListener).contextInitialized(any(ServletContextEvent.class)); + then(servletContextListener).should().contextInitialized(any(ServletContextEvent.class)); context.close(); } @@ -86,7 +87,7 @@ class ServletWebServerServletContextListenerTests { ServletListenerRegistrationBeanConfiguration.class, configuration); ServletContextListener servletContextListener = (ServletContextListener) context .getBean("registration", ServletListenerRegistrationBean.class).getListener(); - verify(servletContextListener).contextInitialized(any(ServletContextEvent.class)); + then(servletContextListener).should().contextInitialized(any(ServletContextEvent.class)); context.close(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java index 98781dc002..8d37f3c0b6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java @@ -47,15 +47,15 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link DefaultErrorViewResolver}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DefaultErrorViewResolverTests { @@ -108,9 +108,9 @@ class DefaultErrorViewResolverTests { ModelAndView resolved = this.resolver.resolveErrorView(this.request, HttpStatus.NOT_FOUND, this.model); assertThat(resolved).isNotNull(); assertThat(resolved.getViewName()).isEqualTo("error/404"); - verify(this.templateAvailabilityProvider).isTemplateAvailable(eq("error/404"), any(Environment.class), + then(this.templateAvailabilityProvider).should().isTemplateAvailable(eq("error/404"), any(Environment.class), any(ClassLoader.class), any(ResourceLoader.class)); - verifyNoMoreInteractions(this.templateAvailabilityProvider); + then(this.templateAvailabilityProvider).shouldHaveNoMoreInteractions(); } @Test @@ -177,7 +177,7 @@ class DefaultErrorViewResolverTests { 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); + then(this.templateAvailabilityProvider).shouldHaveNoMoreInteractions(); MockHttpServletResponse response = render(resolved); assertThat(response.getContentAsString().trim()).isEqualTo("exact/404"); assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_HTML_VALUE); diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java index 88ba197774..2b86c2c11e 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java @@ -31,15 +31,16 @@ import org.springframework.boot.cli.command.core.HintCommand; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.verify; /** * Tests for {@link CommandRunner}. * * @author Phillip Webb * @author Dave Syer + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CommandRunnerTests { @@ -101,7 +102,7 @@ class CommandRunnerTests { @Test void runCommand() throws Exception { this.commandRunner.run("command", "--arg1", "arg2"); - verify(this.regularCommand).run("--arg1", "arg2"); + then(this.regularCommand).should().run("--arg1", "arg2"); } @Test @@ -112,7 +113,7 @@ class CommandRunnerTests { @Test void appArguments() throws Exception { this.commandRunner.runAndHandleErrors("command", "--", "--debug", "bar"); - verify(this.regularCommand).run("--", "--debug", "bar"); + then(this.regularCommand).should().run("--", "--debug", "bar"); // When handled by the command itself it shouldn't cause the system property to be // set assertThat(System.getProperty("debug")).isNull(); @@ -166,7 +167,7 @@ class CommandRunnerTests { @Test void help() throws Exception { this.commandRunner.run("help", "command"); - verify(this.regularCommand).getHelp(); + then(this.regularCommand).should().getHelp(); } @Test diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java index dbe11c77c7..c247e7eb95 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -31,12 +31,13 @@ import org.springframework.security.crypto.factory.PasswordEncoderFactories; import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link EncodePasswordCommand}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class EncodePasswordCommandTests { @@ -60,7 +61,7 @@ class EncodePasswordCommandTests { void encodeWithNoAlgorithmShouldUseBcrypt() throws Exception { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("boot"); - verify(this.log).info(this.message.capture()); + then(this.log).should().info(this.message.capture()); assertThat(this.message.getValue()).startsWith("{bcrypt}"); assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder().matches("boot", this.message.getValue())) .isTrue(); @@ -71,7 +72,7 @@ class EncodePasswordCommandTests { void encodeWithBCryptShouldUseBCrypt() throws Exception { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("-a", "bcrypt", "boot"); - verify(this.log).info(this.message.capture()); + then(this.log).should().info(this.message.capture()); assertThat(this.message.getValue()).doesNotStartWith("{"); assertThat(new BCryptPasswordEncoder().matches("boot", this.message.getValue())).isTrue(); assertThat(status).isEqualTo(ExitStatus.OK); @@ -81,7 +82,7 @@ class EncodePasswordCommandTests { void encodeWithPbkdf2ShouldUsePbkdf2() throws Exception { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("-a", "pbkdf2", "boot"); - verify(this.log).info(this.message.capture()); + then(this.log).should().info(this.message.capture()); assertThat(this.message.getValue()).doesNotStartWith("{"); assertThat(new Pbkdf2PasswordEncoder().matches("boot", this.message.getValue())).isTrue(); assertThat(status).isEqualTo(ExitStatus.OK); @@ -91,7 +92,7 @@ class EncodePasswordCommandTests { void encodeWithUnknownAlgorithmShouldExitWithError() throws Exception { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("--algorithm", "bad", "boot"); - verify(this.log).error("Unknown algorithm, valid options are: default,bcrypt,pbkdf2"); + then(this.log).should().error("Unknown algorithm, valid options are: default,bcrypt,pbkdf2"); assertThat(status).isEqualTo(ExitStatus.ERROR); } diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java index cbdfb1664f..8fb9800be6 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java @@ -37,7 +37,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.cli.command.status.ExitStatus; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link InitCommand} @@ -340,7 +340,7 @@ class InitCommandTests extends AbstractHttpClientMockTests { @Test void userAgent() throws Exception { this.command.run("--list", "--target=https://fake-service"); - verify(this.http).execute(this.requestCaptor.capture()); + then(this.http).should().execute(this.requestCaptor.capture()); Header agent = this.requestCaptor.getValue().getHeaders("User-Agent")[0]; assertThat(agent.getValue()).startsWith("SpringBootCli/"); } diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java index b47e18ff27..ae817deff5 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -22,15 +22,16 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link DependencyManagementArtifactCoordinatesResolver}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ class DependencyManagementArtifactCoordinatesResolverTests { @@ -49,7 +50,7 @@ class DependencyManagementArtifactCoordinatesResolverTests { @Test void getGroupIdForBootArtifact() { assertThat(this.resolver.getGroupId("spring-boot-something")).isEqualTo("org.springframework.boot"); - verify(this.dependencyManagement, never()).find(anyString()); + then(this.dependencyManagement).should(never()).find(anyString()); } @Test diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java index 9c2125181b..1743e7f6cf 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,14 +35,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link GrapeRootRepositorySystemSessionAutoConfiguration} * * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class GrapeRootRepositorySystemSessionAutoConfigurationTests { @@ -55,7 +55,8 @@ class GrapeRootRepositorySystemSessionAutoConfigurationTests { @Test void noLocalRepositoryWhenNoGrapeRoot() { new GrapeRootRepositorySystemSessionAutoConfiguration().apply(this.session, this.repositorySystem); - verify(this.repositorySystem, never()).newLocalRepositoryManager(eq(this.session), any(LocalRepository.class)); + then(this.repositorySystem).should(never()).newLocalRepositoryManager(eq(this.session), + any(LocalRepository.class)); assertThat(this.session.getLocalRepository()).isNull(); } @@ -72,7 +73,7 @@ class GrapeRootRepositorySystemSessionAutoConfigurationTests { System.clearProperty("grape.root"); } - verify(this.repositorySystem, times(1)).newLocalRepositoryManager(eq(this.session), any(LocalRepository.class)); + then(this.repositorySystem).should().newLocalRepositoryManager(eq(this.session), any(LocalRepository.class)); assertThat(this.session.getLocalRepository()).isNotNull(); assertThat(this.session.getLocalRepository().getBasedir().getAbsolutePath()) diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java index d2f94d484d..8141f4668d 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java @@ -36,16 +36,17 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doReturn; +import static org.mockito.BDDMockito.then; +import static org.mockito.BDDMockito.willReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Base class for tests for {@link DevToolsDataSourceAutoConfiguration}. * * @author Andy Wilkinson + * @author Yanming Zhou */ abstract class AbstractDevToolsDataSourceAutoConfigurationTests { @@ -54,7 +55,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests { ConfigurableApplicationContext context = getContext(() -> createContext(SingleDataSourceConfiguration.class)); DataSource dataSource = context.getBean(DataSource.class); Statement statement = configureDataSourceBehavior(dataSource); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } @Test @@ -64,7 +65,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests { Collection dataSources = context.getBeansOfType(DataSource.class).values(); for (DataSource dataSource : dataSources) { Statement statement = configureDataSourceBehavior(dataSource); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } } @@ -82,7 +83,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests { protected final Statement configureDataSourceBehavior(DataSource dataSource) throws SQLException { Connection connection = mock(Connection.class); Statement statement = mock(Statement.class); - doReturn(connection).when(dataSource).getConnection(); + willReturn(connection).given(dataSource).getConnection(); given(connection.createStatement()).willReturn(statement); return statement; } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java index 60dab61010..9c56694d03 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.context.ConfigurableApplicationContext; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link DevToolsDataSourceAutoConfiguration} with an embedded data source. * * @author Andy Wilkinson + * @author Yanming Zhou */ @ClassPathExclusions("HikariCP-*.jar") class DevToolsEmbeddedDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests { @@ -44,7 +45,7 @@ class DevToolsEmbeddedDataSourceAutoConfigurationTests extends AbstractDevToolsD DataSourceSpyConfiguration.class); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java index 74f0b29e2e..d6cfa4145b 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java @@ -39,14 +39,14 @@ import org.springframework.jdbc.core.JdbcTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link DevToolsDataSourceAutoConfiguration} with a pooled data source. * * @author Andy Wilkinson + * @author Yanming Zhou */ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests { @@ -66,7 +66,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat () -> createContext(DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement).execute("SHUTDOWN"); + then(statement).should().execute("SHUTDOWN"); } @Test @@ -75,7 +75,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } @Test @@ -84,7 +84,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat "jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } @Test @@ -93,7 +93,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, times(1)).execute("SHUTDOWN"); + then(statement).should().execute("SHUTDOWN"); } @Test @@ -102,7 +102,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat "jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } @Test @@ -111,7 +111,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat "jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, times(1)).execute("SHUTDOWN"); + then(statement).should().execute("SHUTDOWN"); } @Test @@ -120,7 +120,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat "jdbc:derby://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class)); Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class)); context.close(); - verify(statement, never()).execute("SHUTDOWN"); + then(statement).should(never()).execute("SHUTDOWN"); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java index ac606b8852..a63bbdc213 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java @@ -59,10 +59,10 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; /** * Tests for {@link LocalDevToolsAutoConfiguration}. @@ -70,6 +70,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Andy Wilkinson * @author Vladimir Tsanev + * @author Yanming Zhou */ @ExtendWith(MockRestarter.class) class LocalDevToolsAutoConfigurationTests { @@ -134,7 +135,7 @@ class LocalDevToolsAutoConfigurationTests { LiveReloadServer server = this.context.getBean(LiveReloadServer.class); reset(server); this.context.publishEvent(new ContextRefreshedEvent(this.context)); - verify(server).triggerReload(); + then(server).should().triggerReload(); } @Test @@ -144,7 +145,7 @@ class LocalDevToolsAutoConfigurationTests { reset(server); ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false); this.context.publishEvent(event); - verify(server).triggerReload(); + then(server).should().triggerReload(); } @Test @@ -154,7 +155,7 @@ class LocalDevToolsAutoConfigurationTests { reset(server); ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true); this.context.publishEvent(event); - verify(server, never()).triggerReload(); + then(server).should(never()).triggerReload(); } @Test @@ -171,7 +172,7 @@ class LocalDevToolsAutoConfigurationTests { this.context = getContext(() -> initializeAndRun(Config.class)); ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true); this.context.publishEvent(event); - verify(restarter).restart(any(FailureHandler.class)); + then(restarter).should().restart(any(FailureHandler.class)); } @Test @@ -179,7 +180,7 @@ class LocalDevToolsAutoConfigurationTests { this.context = getContext(() -> initializeAndRun(Config.class)); ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false); this.context.publishEvent(event); - verify(restarter, never()).restart(); + then(restarter).should(never()).restart(); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java index ffc91b262e..553effb50e 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,15 +20,16 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.devtools.livereload.LiveReloadServer; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link OptionalLiveReloadServer}. * * @author Phillip Webb + * @author Yanming Zhou */ class OptionalLiveReloadServerTests { @@ -46,7 +47,7 @@ class OptionalLiveReloadServerTests { willThrow(new RuntimeException("Error")).given(delegate).start(); server.startServer(); server.triggerReload(); - verify(delegate, never()).triggerReload(); + then(delegate).should(never()).triggerReload(); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java index bb465eb5c1..1b56a237ce 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -37,13 +37,14 @@ import org.springframework.context.ApplicationEventPublisher; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link ClassPathFileChangeListener}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ClassPathFileChangeListenerTests { @@ -77,13 +78,13 @@ class ClassPathFileChangeListenerTests { @Test void sendsEventWithoutRestart() { testSendsEvent(false); - verify(this.fileSystemWatcher, never()).stop(); + then(this.fileSystemWatcher).should(never()).stop(); } @Test void sendsEventWithRestart() { testSendsEvent(true); - verify(this.fileSystemWatcher).stop(); + then(this.fileSystemWatcher).should().stop(); } private void testSendsEvent(boolean restart) { @@ -102,7 +103,7 @@ class ClassPathFileChangeListenerTests { given(this.restartStrategy.isRestartRequired(file2)).willReturn(true); } listener.onChange(changeSet); - verify(this.eventPublisher).publishEvent(this.eventCaptor.capture()); + then(this.eventPublisher).should().publishEvent(this.eventCaptor.capture()); ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor.getValue(); assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet); assertThat(actualEvent.isRestartRequired()).isEqualTo(restart); diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java index e4a663daf2..87254e7720 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,13 +23,14 @@ import java.io.OutputStream; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ConnectionOutputStream}. * * @author Phillip Webb + * @author Yanming Zhou */ @SuppressWarnings("resource") class ConnectionOutputStreamTests { @@ -40,7 +41,7 @@ class ConnectionOutputStreamTests { ConnectionOutputStream outputStream = new ConnectionOutputStream(out); byte[] b = new byte[100]; outputStream.write(b, 1, 2); - verify(out).write(b, 1, 2); + then(out).should().write(b, 1, 2); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java index 45e986ba59..f6df319665 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java @@ -35,13 +35,14 @@ import org.springframework.http.client.ClientHttpResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link DelayedLiveReloadTrigger}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DelayedLiveReloadTriggerTests { @@ -113,7 +114,7 @@ class DelayedLiveReloadTriggerTests { this.trigger.setTimings(10, 200, 30000); this.trigger.run(); assertThat(System.currentTimeMillis() - startTime).isGreaterThan(300L); - verify(this.liveReloadServer).triggerReload(); + then(this.liveReloadServer).should().triggerReload(); } @Test @@ -121,7 +122,7 @@ class DelayedLiveReloadTriggerTests { given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET)).willThrow(new IOException()); this.trigger.setTimings(10, 0, 10); this.trigger.run(); - verify(this.liveReloadServer, never()).triggerReload(); + then(this.liveReloadServer).should(never()).triggerReload(); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java index 64dbdb80ed..81e9b78fd1 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java @@ -52,13 +52,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link RemoteClientConfiguration}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockRestarter.class }) class RemoteClientConfigurationTests { @@ -108,7 +109,7 @@ class RemoteClientConfigurationTests { ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false); this.clientContext.publishEvent(event); LiveReloadServer server = this.clientContext.getBean(LiveReloadServer.class); - Awaitility.await().atMost(Duration.ofMinutes(1)).untilAsserted(() -> verify(server).triggerReload()); + Awaitility.await().atMost(Duration.ofMinutes(1)).untilAsserted(() -> then(server).should().triggerReload()); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java index 03826f5b4a..c6b162a555 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java @@ -40,10 +40,9 @@ import org.springframework.mock.web.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link DispatcherFilter}. @@ -83,8 +82,8 @@ class DispatcherFilterTests { ServletRequest request = mock(ServletRequest.class); ServletResponse response = mock(ServletResponse.class); this.filter.doFilter(request, response, this.chain); - verifyNoInteractions(this.dispatcher); - verify(this.chain).doFilter(request, response); + then(this.dispatcher).shouldHaveNoInteractions(); + then(this.chain).should().doFilter(request, response); } @Test @@ -92,7 +91,7 @@ class DispatcherFilterTests { HttpServletRequest request = new MockHttpServletRequest("GET", "/hello"); HttpServletResponse response = new MockHttpServletResponse(); this.filter.doFilter(request, response, this.chain); - verify(this.chain).doFilter(request, response); + then(this.chain).should().doFilter(request, response); } @Test @@ -101,8 +100,8 @@ class DispatcherFilterTests { HttpServletResponse response = new MockHttpServletResponse(); willReturn(true).given(this.dispatcher).handle(any(ServerHttpRequest.class), any(ServerHttpResponse.class)); this.filter.doFilter(request, response, this.chain); - verifyNoInteractions(this.chain); - verify(this.dispatcher).handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture()); + then(this.chain).shouldHaveNoInteractions(); + then(this.dispatcher).should().handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture()); ServerHttpRequest dispatcherRequest = this.serverRequestCaptor.getValue(); ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest; ServerHttpResponse dispatcherResponse = this.serverResponseCaptor.getValue(); diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java index 57289906f8..063bd426ba 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -38,16 +38,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.withSettings; /** * Tests for {@link Dispatcher}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DispatcherTests { @@ -81,7 +81,7 @@ class DispatcherTests { given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler); Dispatcher dispatcher = new Dispatcher(this.accessManager, Collections.singleton(mapper)); dispatcher.handle(this.serverRequest, this.serverResponse); - verifyNoInteractions(handler); + then(handler).shouldHaveNoInteractions(); assertThat(this.response.getStatus()).isEqualTo(403); } @@ -93,7 +93,7 @@ class DispatcherTests { given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler); Dispatcher dispatcher = new Dispatcher(this.accessManager, Collections.singleton(mapper)); dispatcher.handle(this.serverRequest, this.serverResponse); - verify(handler).handle(this.serverRequest, this.serverResponse); + then(handler).should().handle(this.serverRequest, this.serverResponse); } @Test @@ -106,8 +106,8 @@ class DispatcherTests { Dispatcher dispatcher = new Dispatcher(AccessManager.PERMIT_ALL, mappers); dispatcher.handle(this.serverRequest, this.serverResponse); InOrder inOrder = inOrder(mapper1, mapper2); - inOrder.verify(mapper1).getHandler(this.serverRequest); - inOrder.verify(mapper2).getHandler(this.serverRequest); + then(mapper1).should(inOrder).getHandler(this.serverRequest); + then(mapper2).should(inOrder).getHandler(this.serverRequest); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java index b0171fa44a..70b618fdaf 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -41,8 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ClassLoaderFilesResourcePatternResolver}. @@ -50,6 +50,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Andy Wilkinson * @author Stephane Nicoll + * @author Yanming Zhou */ class ClassLoaderFilesResourcePatternResolverTests { @@ -112,7 +113,7 @@ class ClassLoaderFilesResourcePatternResolverTests { context.setResourceLoader(resourceLoader); this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files); this.resolver.getResource("foo.txt"); - verify(resourceLoader).getResource("foo.txt"); + then(resourceLoader).should().getResource("foo.txt"); } @Test @@ -124,7 +125,7 @@ class ClassLoaderFilesResourcePatternResolverTests { this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files); Resource actual = this.resolver.getResource("foo:some-file.txt"); assertThat(actual).isSameAs(resource); - verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); + then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); } @Test @@ -136,7 +137,7 @@ class ClassLoaderFilesResourcePatternResolverTests { context.addProtocolResolver(resolver); Resource actual = this.resolver.getResource("foo:some-file.txt"); assertThat(actual).isSameAs(resource); - verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); + then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); } @Test @@ -146,7 +147,7 @@ class ClassLoaderFilesResourcePatternResolverTests { context.setResourceLoader(resourceLoader); this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files); this.resolver.getResource("foo.txt"); - verify(resourceLoader).getResource("foo.txt"); + then(resourceLoader).should().getResource("foo.txt"); } @Test @@ -158,7 +159,7 @@ class ClassLoaderFilesResourcePatternResolverTests { this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files); Resource actual = this.resolver.getResource("foo:some-file.txt"); assertThat(actual).isSameAs(resource); - verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); + then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); } @Test @@ -170,7 +171,7 @@ class ClassLoaderFilesResourcePatternResolverTests { context.addProtocolResolver(resolver); Resource actual = this.resolver.getResource("foo:some-file.txt"); assertThat(actual).isSameAs(resource); - verify(resolver).resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); + then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class)); } private ProtocolResolver mockProtocolResolver(String path, Resource resource) { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java index 1f45b017f3..dbef473663 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java @@ -49,14 +49,15 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link Restarter}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class RestarterTests { @@ -140,7 +141,7 @@ class RestarterTests { ObjectFactory objectFactory = mock(ObjectFactory.class); Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory); assertThat(attribute).isEqualTo("abc"); - verifyNoInteractions(objectFactory); + then(objectFactory).shouldHaveNoInteractions(); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java index 6bb4fbd0a7..a4d623fda2 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -22,13 +22,14 @@ import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link HttpRestartServerHandler}. * * @author Phillip Webb + * @author Yanming Zhou */ class HttpRestartServerHandlerTests { @@ -45,7 +46,7 @@ class HttpRestartServerHandlerTests { ServerHttpRequest request = mock(ServerHttpRequest.class); ServerHttpResponse response = mock(ServerHttpResponse.class); handler.handle(request, response); - verify(server).handle(request, response); + then(server).should().handle(request, response); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java index b85fe3627f..d931cb8192 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -38,13 +38,13 @@ import org.springframework.mock.web.MockHttpServletResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.BDDMockito.then; /** * Tests for {@link HttpRestartServer}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpRestartServerTests { @@ -83,7 +83,7 @@ class HttpRestartServerTests { byte[] bytes = serialize(files); request.setContent(bytes); this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response)); - verify(this.delegate).updateAndRestart(this.filesCaptor.capture()); + then(this.delegate).should().updateAndRestart(this.filesCaptor.capture()); assertThat(this.filesCaptor.getValue().getFile("name")).isNotNull(); assertThat(response.getStatus()).isEqualTo(200); } @@ -93,7 +93,7 @@ class HttpRestartServerTests { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response)); - verifyNoInteractions(this.delegate); + then(this.delegate).shouldHaveNoInteractions(); assertThat(response.getStatus()).isEqualTo(500); } @@ -104,7 +104,7 @@ class HttpRestartServerTests { MockHttpServletResponse response = new MockHttpServletResponse(); request.setContent(new byte[] { 0, 0, 0 }); this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response)); - verifyNoInteractions(this.delegate); + then(this.delegate).shouldHaveNoInteractions(); assertThat(response.getStatus()).isEqualTo(500); } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java index e24580493d..49792448a8 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -39,9 +39,8 @@ import org.springframework.http.HttpStatus; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link HttpTunnelConnection}. @@ -49,6 +48,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Rob Winch * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class }) class HttpTunnelConnectionTests { @@ -109,10 +109,10 @@ class HttpTunnelConnectionTests { void closeTunnelCallsCloseableOnce() throws Exception { this.requestFactory.willRespondAfterDelay(1000, HttpStatus.GONE); WritableByteChannel channel = openTunnel(false); - verify(this.closeable, never()).close(); + then(this.closeable).should(never()).close(); channel.close(); channel.close(); - verify(this.closeable, times(1)).close(); + then(this.closeable).should().close(); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java index c2c0a0ae71..c281643cdf 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -22,13 +22,14 @@ import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link HttpTunnelServerHandler}. * * @author Phillip Webb + * @author Yanming Zhou */ class HttpTunnelServerHandlerTests { @@ -45,7 +46,7 @@ class HttpTunnelServerHandlerTests { ServerHttpRequest request = mock(ServerHttpRequest.class); ServerHttpResponse response = mock(ServerHttpResponse.class); handler.handle(request, response); - verify(server).handle(request, response); + then(server).should().handle(request, response); } } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java index 85676b0966..d3019f1606 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java @@ -50,15 +50,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link HttpTunnelServer}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpTunnelServerTests { @@ -105,10 +105,10 @@ class HttpTunnelServerTests { @Test void serverConnectedOnFirstRequest() throws Exception { - verify(this.serverConnection, never()).open(anyInt()); + then(this.serverConnection).should(never()).open(anyInt()); givenServerConnectionOpenWillAnswerWithServerChannel(); this.server.handle(this.request, this.response); - verify(this.serverConnection, times(1)).open(DEFAULT_LONG_POLL_TIMEOUT); + then(this.serverConnection).should().open(DEFAULT_LONG_POLL_TIMEOUT); } @Test @@ -116,7 +116,7 @@ class HttpTunnelServerTests { givenServerConnectionOpenWillAnswerWithServerChannel(); this.server.setLongPollTimeout(800); this.server.handle(this.request, this.response); - verify(this.serverConnection, times(1)).open(800); + then(this.serverConnection).should().open(800); } @Test @@ -294,9 +294,9 @@ class HttpTunnelServerTests { given(request.getAsyncRequestControl(this.response)).willReturn(async); HttpConnection connection = new HttpConnection(request, this.response); connection.waitForResponse(); - verify(async).start(); + then(async).should().start(); connection.respond(HttpStatus.NO_CONTENT); - verify(async).complete(); + then(async).should().complete(); } @Test diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java index 330f27b3a1..294c99557f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link TestEntityManager}. @@ -72,7 +72,7 @@ class TestEntityManagerTests { given(this.entityManagerFactory.getPersistenceUnitUtil()).willReturn(this.persistenceUnitUtil); given(this.persistenceUnitUtil.getIdentifier(entity)).willReturn(123); Object result = this.testEntityManager.persistAndGetId(entity); - verify(this.entityManager).persist(entity); + then(this.entityManager).should().persist(entity); assertThat(result).isEqualTo(123); } @@ -83,7 +83,7 @@ class TestEntityManagerTests { given(this.entityManagerFactory.getPersistenceUnitUtil()).willReturn(this.persistenceUnitUtil); given(this.persistenceUnitUtil.getIdentifier(entity)).willReturn(123); Integer result = this.testEntityManager.persistAndGetId(entity, Integer.class); - verify(this.entityManager).persist(entity); + then(this.entityManager).should().persist(entity); assertThat(result).isEqualTo(123); } @@ -92,7 +92,7 @@ class TestEntityManagerTests { bindEntityManager(); TestEntity entity = new TestEntity(); TestEntity result = this.testEntityManager.persist(entity); - verify(this.entityManager).persist(entity); + then(this.entityManager).should().persist(entity); assertThat(result).isSameAs(entity); } @@ -101,8 +101,8 @@ class TestEntityManagerTests { bindEntityManager(); TestEntity entity = new TestEntity(); TestEntity result = this.testEntityManager.persistAndFlush(entity); - verify(this.entityManager).persist(entity); - verify(this.entityManager).flush(); + then(this.entityManager).should().persist(entity); + then(this.entityManager).should().flush(); assertThat(result).isSameAs(entity); } @@ -115,8 +115,8 @@ class TestEntityManagerTests { given(this.persistenceUnitUtil.getIdentifier(entity)).willReturn(123); given(this.entityManager.find(TestEntity.class, 123)).willReturn(found); TestEntity result = this.testEntityManager.persistFlushFind(entity); - verify(this.entityManager).persist(entity); - verify(this.entityManager).flush(); + then(this.entityManager).should().persist(entity); + then(this.entityManager).should().flush(); assertThat(result).isSameAs(found); } @@ -126,7 +126,7 @@ class TestEntityManagerTests { TestEntity entity = new TestEntity(); given(this.entityManager.merge(entity)).willReturn(entity); TestEntity result = this.testEntityManager.merge(entity); - verify(this.entityManager).merge(entity); + then(this.entityManager).should().merge(entity); assertThat(result).isSameAs(entity); } @@ -135,7 +135,7 @@ class TestEntityManagerTests { bindEntityManager(); TestEntity entity = new TestEntity(); this.testEntityManager.remove(entity); - verify(this.entityManager).remove(entity); + then(this.entityManager).should().remove(entity); } @Test @@ -151,7 +151,7 @@ class TestEntityManagerTests { void flushShouldFlush() { bindEntityManager(); this.testEntityManager.flush(); - verify(this.entityManager).flush(); + then(this.entityManager).should().flush(); } @Test @@ -159,14 +159,14 @@ class TestEntityManagerTests { bindEntityManager(); TestEntity entity = new TestEntity(); this.testEntityManager.refresh(entity); - verify(this.entityManager).refresh(entity); + then(this.entityManager).should().refresh(entity); } @Test void clearShouldClear() { bindEntityManager(); this.testEntityManager.clear(); - verify(this.entityManager).clear(); + then(this.entityManager).should().clear(); } @Test @@ -174,7 +174,7 @@ class TestEntityManagerTests { bindEntityManager(); TestEntity entity = new TestEntity(); this.testEntityManager.detach(entity); - verify(this.entityManager).detach(entity); + then(this.entityManager).should().detach(entity); } @Test diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java index a2d5197ae0..463193855f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -32,13 +32,14 @@ import org.springframework.test.context.ContextCustomizer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link PropertyMappingContextCustomizerFactory}. * * @author Phillip Webb + * @author Yanming Zhou */ class PropertyMappingContextCustomizerFactoryTests { @@ -53,7 +54,7 @@ class PropertyMappingContextCustomizerFactoryTests { given(context.getEnvironment()).willReturn(environment); given(context.getBeanFactory()).willReturn(beanFactory); customizer.customizeContext(context, null); - verifyNoInteractions(environment); + then(environment).shouldHaveNoInteractions(); } @Test diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java index 61be82c7d2..5f200d3c7c 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -38,14 +38,15 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link WebTestClientAutoConfiguration} * * @author Brian Clozel * @author Stephane Nicoll + * @author Yanming Zhou */ class WebTestClientAutoConfigurationTests { @@ -65,7 +66,7 @@ class WebTestClientAutoConfigurationTests { this.contextRunner.withUserConfiguration(CodecConfiguration.class).run((context) -> { assertThat(context).hasSingleBean(WebTestClient.class); assertThat(context).hasSingleBean(CodecCustomizer.class); - verify(context.getBean(CodecCustomizer.class)).customize(any(CodecConfigurer.class)); + then(context.getBean(CodecCustomizer.class)).should().customize(any(CodecConfigurer.class)); }); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java index 2af669ae2a..f31713e430 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java @@ -24,6 +24,9 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.web.servlet.DispatcherServlet; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.mock; /** * Tests for {@link MockMvcAutoConfiguration}. diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java index 7e84cc6a04..8d0f51f972 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -31,13 +31,14 @@ import org.springframework.context.support.StaticApplicationContext; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link ApplicationContextAssertProvider} and * {@link AssertProviderApplicationContextInvocationHandler}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ApplicationContextAssertProviderTests { @@ -102,7 +103,7 @@ class ApplicationContextAssertProviderTests { ApplicationContextAssertProvider context = get(this.mockContextSupplier); assertThat((Object) context).isNotNull(); context.getBean("foo"); - verify(this.mockContext).getBean("foo"); + then(this.mockContext).should().getBean("foo"); } @Test @@ -186,7 +187,7 @@ class ApplicationContextAssertProviderTests { void closeShouldCloseContext() { ApplicationContextAssertProvider context = get(this.mockContextSupplier); context.close(); - verify(this.mockContext).close(); + then(this.mockContext).should().close(); } private ApplicationContextAssertProvider get(Supplier contextSupplier) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java index 528a8ae355..940e456396 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -28,14 +28,15 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.stereotype.Component; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for nested test configuration when the configuration is inherited from the * enclosing class (the default behaviour). * * @author Andy Wilkinson + * @author Yanming Zhou */ @SpringBootTest(classes = AppConfiguration.class) @Import(ActionPerformer.class) @@ -50,14 +51,14 @@ class InheritedNestedTestConfigurationTests { @Test void mockWasInvokedOnce() { this.performer.run(); - verify(this.action, times(1)).perform(); + then(this.action).should().perform(); } @Test void mockWasInvokedTwice() { this.performer.run(); this.performer.run(); - verify(this.action, times(2)).perform(); + then(this.action).should(times(2)).perform(); } @Nested @@ -66,14 +67,14 @@ class InheritedNestedTestConfigurationTests { @Test void mockWasInvokedOnce() { InheritedNestedTestConfigurationTests.this.performer.run(); - verify(InheritedNestedTestConfigurationTests.this.action, times(1)).perform(); + then(InheritedNestedTestConfigurationTests.this.action).should().perform(); } @Test void mockWasInvokedTwice() { InheritedNestedTestConfigurationTests.this.performer.run(); InheritedNestedTestConfigurationTests.this.performer.run(); - verify(InheritedNestedTestConfigurationTests.this.action, times(2)).perform(); + then(InheritedNestedTestConfigurationTests.this.action).should(times(2)).perform(); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java index f86d587772..97bc12ddbe 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link MockBean @MockBean} on a test class field can be used to replace existing @@ -39,6 +39,7 @@ import static org.mockito.Mockito.verify; * * @author Stephane Nicoll * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { @@ -56,7 +57,7 @@ class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { @Test void testMocking() { this.caller.sayGreeting(); - verify(this.service).greeting(); + then(this.service).should().greeting(); } @Test diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java index cb9d4d16d1..a88cbdc2b2 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -37,8 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Test {@link MockBean @MockBean} when mixed with Spring AOP. @@ -60,9 +60,9 @@ class MockBeanWithAopProxyTests { given(this.dateService.getDate(false)).willReturn(2L); Long d2 = this.dateService.getDate(false); assertThat(d2).isEqualTo(2L); - verify(this.dateService, times(2)).getDate(false); - verify(this.dateService, times(2)).getDate(eq(false)); - verify(this.dateService, times(2)).getDate(anyBoolean()); + then(this.dateService).should(times(2)).getDate(false); + then(this.dateService).should(times(2)).getDate(eq(false)); + then(this.dateService).should(times(2)).getDate(anyBoolean()); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java index 40b9762c55..66d9ecbe1d 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -34,14 +34,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link MockitoTestExecutionListener}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class MockitoTestExecutionListenerTests { @@ -72,14 +72,14 @@ class MockitoTestExecutionListenerTests { TestContext testContext = mockTestContext(instance); given(testContext.getApplicationContext()).willReturn(this.applicationContext); this.listener.prepareTestInstance(testContext); - verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class)); + then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class)); assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean"); } @Test void beforeTestMethodShouldDoNothingWhenDirtiesContextAttributeIsNotSet() throws Exception { this.listener.beforeTestMethod(mock(TestContext.class)); - verifyNoMoreInteractions(this.postProcessor); + then(this.postProcessor).shouldHaveNoMoreInteractions(); } @Test @@ -91,7 +91,7 @@ class MockitoTestExecutionListenerTests { given(mockTestContext.getAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE)) .willReturn(Boolean.TRUE); this.listener.beforeTestMethod(mockTestContext); - verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class)); + then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class)); assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean"); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java index 2d7abb01a6..7d9fdd3ed5 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -36,12 +36,13 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link QualifierDefinition}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class QualifierDefinitionTests { @@ -81,7 +82,7 @@ class QualifierDefinitionTests { Field field = ReflectionUtils.findField(ConfigA.class, "directQualifier"); QualifierDefinition qualifierDefinition = QualifierDefinition.forElement(field); qualifierDefinition.matches(this.beanFactory, "bean"); - verify(this.beanFactory).isAutowireCandidate(eq("bean"), this.descriptorCaptor.capture()); + then(this.beanFactory).should().isAutowireCandidate(eq("bean"), this.descriptorCaptor.capture()); assertThat(this.descriptorCaptor.getValue().getAnnotatedElement()).isEqualTo(field); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java index 924a39b7cf..a8cb09c6d3 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a configuration class can be used to spy existing * beans. * * @author Phillip Webb + * @author Yanming ZHou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests { @@ -44,7 +45,7 @@ class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java index 312de6761c..8e41b68a15 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a configuration class can be used to inject new spy * instances. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationClassForNewBeanIntegrationTests { @@ -44,7 +45,7 @@ class SpyBeanOnConfigurationClassForNewBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java index bab4a63935..79b1984125 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -28,13 +28,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a field on a {@code @Configuration} class can be used * to replace existing beans. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests { @@ -48,7 +49,7 @@ class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.config.exampleService).greeting(); + then(this.config.exampleService).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java index 4faca40b21..23fd2a6169 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a field on a {@code @Configuration} class can be used * to inject new spy instances. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests { @@ -47,7 +48,7 @@ class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.config.exampleService).greeting(); + then(this.config.exampleService).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java index 702d6b642c..0b71decbac 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,12 +27,13 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class can be used to replace existing beans. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @SpyBean(SimpleExampleService.class) @@ -44,7 +45,7 @@ class SpyBeanOnTestClassForExistingBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java index 1e73eb2982..a467a8deb1 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,12 +27,13 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class can be used to inject new spy instances. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @SpyBean(SimpleExampleService.class) @@ -44,7 +45,7 @@ class SpyBeanOnTestClassForNewBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java index 83392ea4b5..4de3793bca 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -26,7 +26,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing @@ -35,6 +35,7 @@ import static org.mockito.Mockito.verify; * application context caching. * * @author Phillip Webb + * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanIntegrationTests */ @ExtendWith(SpringExtension.class) @@ -50,7 +51,7 @@ class SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java index e66f351809..5c8f718d1f 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -26,13 +26,14 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing * beans. * * @author Phillip Webb + * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests */ @ExtendWith(SpringExtension.class) @@ -48,7 +49,7 @@ class SpyBeanOnTestFieldForExistingBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java index 8470a405bc..a9b56ce267 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -31,13 +31,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing * bean while preserving qualifiers. * * @author Andreas Neiser + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { @@ -55,7 +56,7 @@ class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { @Test void testMocking() throws Exception { this.caller.sayGreeting(); - verify(this.service).greeting(); + then(this.service).should().greeting(); } @Test diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java index c656bc13f8..197254514c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -30,13 +30,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing * beans. * * @author Phillip Webb + * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests */ @ExtendWith(SpringExtension.class) @@ -53,7 +54,7 @@ class SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say 123 simple"); - verify(this.exampleService).greeting(); + then(this.exampleService).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java index 83276bb8f1..2c8b3b362c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -30,13 +30,14 @@ import org.springframework.context.annotation.Primary; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to inject a spy * instance when there are multiple candidates and one is primary. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests { @@ -52,7 +53,7 @@ class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests { assertThat(this.caller.sayGreeting()).isEqualTo("I say two"); assertThat(Mockito.mockingDetails(this.spy).getMockCreationSettings().getMockName().toString()) .isEqualTo("two"); - verify(this.spy).greeting(); + then(this.spy).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java index 91a1b8f59c..872abba16c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -27,13 +27,14 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} on a test class field can be used to inject new spy * instances. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForNewBeanIntegrationTests { @@ -47,7 +48,7 @@ class SpyBeanOnTestFieldForNewBeanIntegrationTests { @Test void testSpying() { assertThat(this.caller.sayGreeting()).isEqualTo("I say simple"); - verify(this.caller.getService()).greeting(); + then(this.caller.getService()).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java index 8b67ebbf9c..6440e5e53e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -35,14 +35,14 @@ import org.springframework.stereotype.Service; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Test {@link SpyBean @SpyBean} when mixed with Spring AOP. * * @author Phillip Webb + * @author Yanming Zhou * @see 5837 */ @ExtendWith(SpringExtension.class) @@ -54,7 +54,7 @@ class SpyBeanWithAopProxyAndNotProxyTargetAwareTests { @Test void verifyShouldUseProxyTarget() { this.dateService.getDate(false); - verify(this.dateService, times(1)).getDate(false); + then(this.dateService).should().getDate(false); assertThatExceptionOfType(UnfinishedVerificationException.class).isThrownBy(() -> reset(this.dateService)); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java index 14dfacc187..e773997513 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -36,13 +36,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Test {@link SpyBean @SpyBean} when mixed with Spring AOP. * * @author Phillip Webb + * @author Yanming Zhou * @see 5837 */ @ExtendWith(SpringExtension.class) @@ -57,9 +57,9 @@ class SpyBeanWithAopProxyTests { Thread.sleep(200); Long d2 = this.dateService.getDate(false); assertThat(d1).isEqualTo(d2); - verify(this.dateService, times(1)).getDate(false); - verify(this.dateService, times(1)).getDate(eq(false)); - verify(this.dateService, times(1)).getDate(anyBoolean()); + then(this.dateService).should().getDate(false); + then(this.dateService).should().getDate(eq(false)); + then(this.dateService).should().getDate(anyBoolean()); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java index d141dcbf42..ecb71dfe3e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -28,13 +28,14 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.junit.jupiter.SpringExtension; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Integration tests for using {@link SpyBean @SpyBean} with * {@link DirtiesContext @DirtiesContext} and {@link ClassMode#BEFORE_EACH_TEST_METHOD}. * * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) @@ -49,7 +50,7 @@ class SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests { @Test void testSpying() throws Exception { this.caller.sayGreeting(); - verify(this.exampleService).greeting(); + then(this.exampleService).should().greeting(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java index c096396116..be4a007dc6 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java @@ -30,12 +30,13 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link SpyBean @SpyBean} with a JDK proxy. * * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanWithJdkProxyTests { @@ -50,7 +51,7 @@ class SpyBeanWithJdkProxyTests { void jdkProxyCanBeSpied() throws Exception { Example example = this.service.find("id"); assertThat(example.id).isEqualTo("id"); - verify(this.repository).find("id"); + then(this.repository).should().find("id"); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java index 68e2c5ba5d..a9f110b0ce 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -22,13 +22,14 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ApplicationContextTestUtils}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class ApplicationContextTestUtilsTests { @@ -50,10 +51,10 @@ class ApplicationContextTestUtilsTests { given(mock.getParent()).willReturn(parent); given(parent.getParent()).willReturn(null); ApplicationContextTestUtils.closeAll(mock); - verify(mock).getParent(); - verify(mock).close(); - verify(parent).getParent(); - verify(parent).close(); + then(mock).should().getParent(); + then(mock).should().close(); + then(parent).should().getParent(); + then(parent).should().close(); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java index ad1f67f2eb..e0ff595c31 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -28,8 +28,8 @@ import org.springframework.web.util.UriTemplateHandler; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link LocalHostUriTemplateHandler}. @@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Andy Wilkinson * @author Eddú Meléndez + * @author Yanming Zhou */ class LocalHostUriTemplateHandlerTests { @@ -99,7 +100,7 @@ class LocalHostUriTemplateHandlerTests { given(uriTemplateHandler.expand("https://localhost:8080/", uriVariables)).willReturn(uri); LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment, "https", uriTemplateHandler); assertThat(handler.expand("/", uriVariables)).isEqualTo(uri); - verify(uriTemplateHandler).expand("https://localhost:8080/", uriVariables); + then(uriTemplateHandler).should().expand("https://localhost:8080/", uriVariables); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java index 5402ecc069..26b2740beb 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @@ -49,6 +49,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * Tests for {@link RootUriRequestExpectationManager}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RootUriRequestExpectationManagerTests { @@ -85,7 +86,7 @@ class RootUriRequestExpectationManagerTests { ExpectedCount count = ExpectedCount.once(); RequestMatcher requestMatcher = mock(RequestMatcher.class); this.manager.expectRequest(count, requestMatcher); - verify(this.delegate).expectRequest(count, requestMatcher); + then(this.delegate).should().expectRequest(count, requestMatcher); } @Test @@ -93,7 +94,7 @@ class RootUriRequestExpectationManagerTests { ClientHttpRequest request = mock(ClientHttpRequest.class); given(request.getURI()).willReturn(new URI("https://spring.io/test")); this.manager.validateRequest(request); - verify(this.delegate).validateRequest(request); + then(this.delegate).should().validateRequest(request); } @Test @@ -101,7 +102,7 @@ class RootUriRequestExpectationManagerTests { ClientHttpRequest request = mock(ClientHttpRequest.class); given(request.getURI()).willReturn(new URI(this.uri + "/hello")); this.manager.validateRequest(request); - verify(this.delegate).validateRequest(this.requestCaptor.capture()); + then(this.delegate).should().validateRequest(this.requestCaptor.capture()); HttpRequestWrapper actual = (HttpRequestWrapper) this.requestCaptor.getValue(); assertThat(actual.getRequest()).isSameAs(request); assertThat(actual.getURI()).isEqualTo(new URI("/hello")); @@ -120,7 +121,7 @@ class RootUriRequestExpectationManagerTests { @Test void resetRequestShouldDelegateToExpectationManager() { this.manager.reset(); - verify(this.delegate).reset(); + then(this.delegate).should().reset(); } @Test diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 974065672d..630bde66cb 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -56,8 +56,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link TestRestTemplate}. @@ -67,6 +67,7 @@ import static org.mockito.Mockito.verify; * @author Stephane Nicoll * @author Andy Wilkinson * @author Kristine Jetzke + * @author Yanming Zhou */ class TestRestTemplateTests { @@ -246,7 +247,7 @@ class TestRestTemplateTests { LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment()); template.setUriTemplateHandler(uriTemplateHandler); template.exchange(entity, String.class); - verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET)); + then(requestFactory).should().createRequest(eq(absoluteUri), eq(HttpMethod.GET)); } @Test @@ -260,7 +261,7 @@ class TestRestTemplateTests { given(requestFactory.createRequest(eq(absoluteUri), eq(HttpMethod.GET))).willReturn(request); template.getRestTemplate().setRequestFactory(requestFactory); template.exchange(entity, String.class); - verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET)); + then(requestFactory).should().createRequest(eq(absoluteUri), eq(HttpMethod.GET)); } @Test @@ -362,7 +363,7 @@ class TestRestTemplateTests { LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment()); template.setUriTemplateHandler(uriTemplateHandler); callback.doWithTestRestTemplate(template, URI.create("/a/b/c.txt?param=%7Bsomething%7D")); - verify(requestFactory).createRequest(eq(absoluteUri), any(HttpMethod.class)); + then(requestFactory).should().createRequest(eq(absoluteUri), any(HttpMethod.class)); } private void assertBasicAuthorizationCredentials(TestRestTemplate testRestTemplate, String username, diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java index 9d81260b5b..b000787bcd 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -36,13 +36,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link LocalHostWebClient}. * * @author Phillip Webb + * @author Yanming Zhou */ @SuppressWarnings("resource") @ExtendWith(MockitoExtension.class) @@ -64,7 +65,7 @@ class LocalHostWebClientTests { WebConnection connection = mockConnection(); client.setWebConnection(connection); client.getPage("/test"); - verify(connection).getResponse(this.requestCaptor.capture()); + then(connection).should().getResponse(this.requestCaptor.capture()); assertThat(this.requestCaptor.getValue().getUrl()).isEqualTo(new URL("http://localhost:8080/test")); } @@ -76,7 +77,7 @@ class LocalHostWebClientTests { WebConnection connection = mockConnection(); client.setWebConnection(connection); client.getPage("/test"); - verify(connection).getResponse(this.requestCaptor.capture()); + then(connection).should().getResponse(this.requestCaptor.capture()); assertThat(this.requestCaptor.getValue().getUrl()).isEqualTo(new URL("http://localhost:8181/test")); } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java index 9272668202..933e9718f8 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java @@ -38,13 +38,14 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link LocalHostWebConnectionHtmlUnitDriver}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class LocalHostWebConnectionHtmlUnitDriverTests { @@ -91,7 +92,7 @@ class LocalHostWebConnectionHtmlUnitDriverTests { MockEnvironment environment = new MockEnvironment(); LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment); driver.get("/test"); - verify(this.webClient).getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8080/test"))); + then(this.webClient).should().getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8080/test"))); } @Test @@ -100,7 +101,7 @@ class LocalHostWebConnectionHtmlUnitDriverTests { environment.setProperty("local.server.port", "8181"); LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment); driver.get("/test"); - verify(this.webClient).getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8181/test"))); + then(this.webClient).should().getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8181/test"))); } private WebRequest requestToUrl(URL url) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java index e616464908..34af6e8dbb 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -36,13 +36,14 @@ import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.reactive.server.WebTestClient.Builder; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Integration test for {@link WebTestClientContextCustomizer}. * * @author Phillip Webb + * @author Yanming Zhou */ @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=reactive") @DirtiesContext @@ -56,7 +57,7 @@ class WebTestClientContextCustomizerIntegrationTests { @Test void test() { - verify(this.clientBuilderCustomizer).customize(any(Builder.class)); + then(this.clientBuilderCustomizer).should().customize(any(Builder.class)); this.webTestClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello"); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java index 8e17071958..dc5b68e353 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java @@ -47,17 +47,17 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link Builder}. * * @author Phillip Webb * @author Scott Frederick + * @author Rafael Ceccone */ class BuilderTests { @@ -96,11 +96,13 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()); - verify(docker.image()).pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); - verifyNoMoreInteractions(docker.image()); + then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), + isNull()); + then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), + isNull()); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); + then(docker.image()).shouldHaveNoMoreInteractions(); } @Test @@ -124,15 +126,15 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), + then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())); - verify(docker.image()).pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), + then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())); - verify(docker.image()).push(eq(request.getName()), any(), + then(docker.image()).should().push(eq(request.getName()), any(), eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader())); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); - verifyNoMoreInteractions(docker.image()); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); + then(docker.image()).shouldHaveNoMoreInteractions(); } @Test @@ -151,8 +153,8 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); } @Test @@ -172,8 +174,8 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); } @Test @@ -192,8 +194,8 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); } @Test @@ -216,10 +218,10 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); - verify(docker.image(), never()).pull(any(), any()); - verify(docker.image(), times(2)).inspect(any()); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); + then(docker.image()).should(never()).pull(any(), any()); + then(docker.image()).should(times(2)).inspect(any()); } @Test @@ -242,10 +244,10 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); - verify(docker.image(), times(2)).pull(any(), any(), isNull()); - verify(docker.image(), never()).inspect(any()); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); + then(docker.image()).should(times(2)).pull(any(), any(), isNull()); + then(docker.image()).should(never()).inspect(any()); } @Test @@ -270,10 +272,10 @@ class BuilderTests { assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); - verify(docker.image()).load(archive.capture(), any()); - verify(docker.image()).remove(archive.getValue().getTag(), true); - verify(docker.image(), times(2)).inspect(any()); - verify(docker.image(), times(2)).pull(any(), any(), isNull()); + then(docker.image()).should().load(archive.capture(), any()); + then(docker.image()).should().remove(archive.getValue().getTag(), true); + then(docker.image()).should(times(2)).inspect(any()); + then(docker.image()).should(times(2)).pull(any(), any(), isNull()); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java index 8e5b26187c..430536e3f6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java @@ -54,8 +54,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link Lifecycle}. @@ -149,7 +149,7 @@ class LifecycleTests { createLifecycle(request).execute(); assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-clean-cache.json")); VolumeName name = VolumeName.of("pack-cache-b35197ac41ea.build"); - verify(this.docker.volume()).delete(name, true); + then(this.docker.volume()).should().delete(name, true); } @Test @@ -184,8 +184,8 @@ class LifecycleTests { @Test void closeClearsVolumes() throws Exception { createLifecycle().close(); - verify(this.docker.volume()).delete(VolumeName.of("pack-layers-aaaaaaaaaa"), true); - verify(this.docker.volume()).delete(VolumeName.of("pack-app-aaaaaaaaaa"), true); + then(this.docker.volume()).should().delete(VolumeName.of("pack-layers-aaaaaaaaaa"), true); + then(this.docker.volume()).should().delete(VolumeName.of("pack-app-aaaaaaaaaa"), true); } private DockerApi mockDockerApi() { @@ -256,9 +256,9 @@ class LifecycleTests { private void assertPhaseWasRun(String name, IOConsumer configConsumer) throws IOException { ContainerReference containerReference = ContainerReference.of("cnb-lifecycle-" + name); - verify(this.docker.container()).start(containerReference); - verify(this.docker.container()).logs(eq(containerReference), any()); - verify(this.docker.container()).remove(containerReference, true); + then(this.docker.container()).should().start(containerReference); + then(this.docker.container()).should().logs(eq(containerReference), any()); + then(this.docker.container()).should().remove(containerReference, true); configConsumer.accept(this.configs.get(containerReference.toString())); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java index ffddb46448..87f89faaf0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java @@ -23,9 +23,8 @@ import org.springframework.boot.buildpack.platform.docker.type.ContainerConfig.U import org.springframework.boot.buildpack.platform.docker.type.VolumeName; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link Phase}. @@ -54,9 +53,9 @@ class PhaseTests { Phase phase = new Phase("test", false); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test", NO_ARGS); - verify(update).withLabel("author", "spring-boot"); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test", NO_ARGS); + then(update).should().withLabel("author", "spring-boot"); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -65,11 +64,11 @@ class PhaseTests { phase.withDaemonAccess(); Update update = mock(Update.class); phase.apply(update); - verify(update).withUser("root"); - verify(update).withBinding(Binding.from("/var/run/docker.sock", "/var/run/docker.sock")); - verify(update).withCommand("/cnb/lifecycle/test", NO_ARGS); - verify(update).withLabel("author", "spring-boot"); - verifyNoMoreInteractions(update); + then(update).should().withUser("root"); + then(update).should().withBinding(Binding.from("/var/run/docker.sock", "/var/run/docker.sock")); + then(update).should().withCommand("/cnb/lifecycle/test", NO_ARGS); + then(update).should().withLabel("author", "spring-boot"); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -78,9 +77,9 @@ class PhaseTests { phase.withLogLevelArg(); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test", "-log-level", "debug"); - verify(update).withLabel("author", "spring-boot"); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test", "-log-level", "debug"); + then(update).should().withLabel("author", "spring-boot"); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -89,9 +88,9 @@ class PhaseTests { phase.withLogLevelArg(); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test"); - verify(update).withLabel("author", "spring-boot"); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test"); + then(update).should().withLabel("author", "spring-boot"); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -100,9 +99,9 @@ class PhaseTests { phase.withArgs("a", "b", "c"); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test", "a", "b", "c"); - verify(update).withLabel("author", "spring-boot"); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test", "a", "b", "c"); + then(update).should().withLabel("author", "spring-boot"); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -112,10 +111,10 @@ class PhaseTests { phase.withBinding(Binding.from(volumeName, "/test")); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test"); - verify(update).withLabel("author", "spring-boot"); - verify(update).withBinding(Binding.from(volumeName, "/test")); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test"); + then(update).should().withLabel("author", "spring-boot"); + then(update).should().withBinding(Binding.from(volumeName, "/test")); + then(update).shouldHaveNoMoreInteractions(); } @Test @@ -125,11 +124,11 @@ class PhaseTests { phase.withEnv("name2", "value2"); Update update = mock(Update.class); phase.apply(update); - verify(update).withCommand("/cnb/lifecycle/test"); - verify(update).withLabel("author", "spring-boot"); - verify(update).withEnv("name1", "value1"); - verify(update).withEnv("name2", "value2"); - verifyNoMoreInteractions(update); + then(update).should().withCommand("/cnb/lifecycle/test"); + then(update).should().withLabel("author", "spring-boot"); + then(update).should().withEnv("name1", "value1"); + then(update).should().withEnv("name2", "value2"); + then(update).shouldHaveNoMoreInteractions(); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java index 912d5af975..8ac72bdc10 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java @@ -61,10 +61,10 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link DockerApi}. @@ -260,7 +260,7 @@ class DockerApiTests { ordered.verify(this.loadListener).onStart(); ordered.verify(this.loadListener).onUpdate(any()); ordered.verify(this.loadListener).onFinish(); - verify(http()).post(any(), any(), this.writer.capture()); + then(http()).should().post(any(), any(), this.writer.capture()); ByteArrayOutputStream out = new ByteArrayOutputStream(); this.writer.getValue().accept(out); assertThat(out.toByteArray()).hasSizeGreaterThan(21000); @@ -280,7 +280,7 @@ class DockerApiTests { + "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.remove(reference, false); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } @Test @@ -291,7 +291,7 @@ class DockerApiTests { + "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d?force=1"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.remove(reference, true); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } @Test @@ -381,7 +381,7 @@ class DockerApiTests { .willReturn(responseOf("create-container-response.json")); ContainerReference containerReference = this.api.create(config); assertThat(containerReference.toString()).isEqualTo("e90e34656806"); - verify(http()).post(any(), any(), this.writer.capture()); + then(http()).should().post(any(), any(), this.writer.capture()); ByteArrayOutputStream out = new ByteArrayOutputStream(); this.writer.getValue().accept(out); assertThat(out.toByteArray().length).isEqualTo(config.toString().length()); @@ -403,11 +403,11 @@ class DockerApiTests { given(http().put(eq(uploadUri), eq("application/x-tar"), any())).willReturn(emptyResponse()); ContainerReference containerReference = this.api.create(config, content); assertThat(containerReference.toString()).isEqualTo("e90e34656806"); - verify(http()).post(any(), any(), this.writer.capture()); + then(http()).should().post(any(), any(), this.writer.capture()); ByteArrayOutputStream out = new ByteArrayOutputStream(); this.writer.getValue().accept(out); assertThat(out.toByteArray().length).isEqualTo(config.toString().length()); - verify(http()).put(any(), any(), this.writer.capture()); + then(http()).should().put(any(), any(), this.writer.capture()); this.writer.getValue().accept(out); assertThat(out.toByteArray()).hasSizeGreaterThan(2000); } @@ -424,7 +424,7 @@ class DockerApiTests { URI startContainerUri = new URI(CONTAINERS_URL + "/e90e34656806/start"); given(http().post(startContainerUri)).willReturn(emptyResponse()); this.api.start(reference); - verify(http()).post(startContainerUri); + then(http()).should().post(startContainerUri); } @Test @@ -479,7 +479,7 @@ class DockerApiTests { URI removeUri = new URI(CONTAINERS_URL + "/e90e34656806"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.remove(reference, false); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } @Test @@ -488,7 +488,7 @@ class DockerApiTests { URI removeUri = new URI(CONTAINERS_URL + "/e90e34656806?force=1"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.remove(reference, true); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } } @@ -515,7 +515,7 @@ class DockerApiTests { URI removeUri = new URI(VOLUMES_URL + "/test"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.delete(name, false); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } @Test @@ -524,7 +524,7 @@ class DockerApiTests { URI removeUri = new URI(VOLUMES_URL + "/test?force=1"); given(http().delete(removeUri)).willReturn(emptyResponse()); this.api.delete(name, true); - verify(http()).delete(removeUri); + then(http()).should().delete(removeUri); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java index 13587e1351..7ce4bffe05 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link HttpClientTransport}. @@ -58,6 +58,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Mike Smithson * @author Scott Frederick + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpClientTransportTests { @@ -103,7 +104,7 @@ class HttpClientTransportTests { given(this.entity.getContent()).willReturn(this.content); given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.get(this.uri); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); assertThat(request).isInstanceOf(HttpGet.class); assertThat(request.getURI()).isEqualTo(this.uri); @@ -117,7 +118,7 @@ class HttpClientTransportTests { given(this.entity.getContent()).willReturn(this.content); given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.post(this.uri); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); assertThat(request).isInstanceOf(HttpPost.class); assertThat(request.getURI()).isEqualTo(this.uri); @@ -132,7 +133,7 @@ class HttpClientTransportTests { given(this.entity.getContent()).willReturn(this.content); given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.post(this.uri, "auth token"); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); assertThat(request).isInstanceOf(HttpPost.class); assertThat(request.getURI()).isEqualTo(this.uri); @@ -147,7 +148,7 @@ class HttpClientTransportTests { given(this.entity.getContent()).willReturn(this.content); given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.post(this.uri, ""); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); assertThat(request).isInstanceOf(HttpPost.class); assertThat(request.getURI()).isEqualTo(this.uri); @@ -164,7 +165,7 @@ class HttpClientTransportTests { given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.post(this.uri, APPLICATION_JSON, (out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out)); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); assertThat(request).isInstanceOf(HttpPost.class); @@ -186,7 +187,7 @@ class HttpClientTransportTests { given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.post(this.uri, APPLICATION_X_TAR, (out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out)); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); assertThat(request).isInstanceOf(HttpPost.class); @@ -208,7 +209,7 @@ class HttpClientTransportTests { given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.put(this.uri, APPLICATION_JSON, (out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out)); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); assertThat(request).isInstanceOf(HttpPut.class); @@ -230,7 +231,7 @@ class HttpClientTransportTests { given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.put(this.uri, APPLICATION_X_TAR, (out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out)); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); assertThat(request).isInstanceOf(HttpPut.class); @@ -250,7 +251,7 @@ class HttpClientTransportTests { given(this.entity.getContent()).willReturn(this.content); given(this.statusLine.getStatusCode()).willReturn(200); Response response = this.http.delete(this.uri); - verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture()); + then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture()); HttpUriRequest request = this.requestCaptor.getValue(); assertThat(request).isInstanceOf(HttpDelete.class); assertThat(request.getURI()).isEqualTo(this.uri); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index d57eed273c..ce3b9917aa 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -64,8 +64,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIOException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link JarFile}. @@ -74,6 +74,7 @@ import static org.mockito.Mockito.verify; * @author Martin Lau * @author Andy Wilkinson * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(JarUrlProtocolHandler.class) class JarFileTests { @@ -243,7 +244,7 @@ class JarFileTests { RandomAccessDataFile randomAccessDataFile = spy(new RandomAccessDataFile(this.rootJarFile)); JarFile jarFile = new JarFile(randomAccessDataFile); jarFile.close(); - verify(randomAccessDataFile).close(); + then(randomAccessDataFile).should().close(); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java index bc8cd7bb1a..0f72578ac4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java @@ -42,14 +42,15 @@ import org.springframework.boot.loader.tools.LibraryScope; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ArtifactsLibraries}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ArtifactsLibrariesTests { @@ -85,7 +86,7 @@ class ArtifactsLibrariesTests { given(this.artifact.getArtifactHandler()).willReturn(this.artifactHandler); given(this.artifact.getScope()).willReturn("compile"); this.libs.doWithLibraries(this.callback); - verify(this.callback).library(this.libraryCaptor.capture()); + then(this.callback).should().library(this.libraryCaptor.capture()); Library library = this.libraryCaptor.getValue(); assertThat(library.getFile()).isEqualTo(this.file); assertThat(library.getScope()).isEqualTo(LibraryScope.COMPILE); @@ -105,7 +106,7 @@ class ArtifactsLibrariesTests { this.libs = new ArtifactsLibraries(this.artifacts, Collections.emptyList(), Collections.singleton(unpack), mock(Log.class)); this.libs.doWithLibraries(this.callback); - verify(this.callback).library(this.libraryCaptor.capture()); + then(this.callback).should().library(this.libraryCaptor.capture()); assertThat(this.libraryCaptor.getValue().isUnpackRequired()).isTrue(); } @@ -128,7 +129,7 @@ class ArtifactsLibrariesTests { this.artifacts = new LinkedHashSet<>(Arrays.asList(artifact1, artifact2)); this.libs = new ArtifactsLibraries(this.artifacts, Collections.emptyList(), null, mock(Log.class)); this.libs.doWithLibraries(this.callback); - verify(this.callback, times(2)).library(this.libraryCaptor.capture()); + then(this.callback).should(times(2)).library(this.libraryCaptor.capture()); assertThat(this.libraryCaptor.getAllValues().get(0).getName()).isEqualTo("g1-artifact-1.0.jar"); assertThat(this.libraryCaptor.getAllValues().get(1).getName()).isEqualTo("g2-artifact-1.0.jar"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java index fe4d18a7f8..74a0edb6ba 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,9 +35,9 @@ import org.springframework.core.env.Environment; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; /** * Tests for {@link Banner} and its usage by {@link SpringApplication}. @@ -45,6 +45,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Michael Stummvoll * @author Michael Simons + * @author Yanming Zhou */ @ExtendWith({ MockitoExtension.class, OutputCaptureExtension.class }) class BannerTests { @@ -98,10 +99,11 @@ class BannerTests { this.context = application.run(); Banner printedBanner = (Banner) this.context.getBean("springBootBanner"); assertThat(printedBanner).hasFieldOrPropertyWithValue("banner", banner); - verify(banner).printBanner(any(Environment.class), this.sourceClassCaptor.capture(), any(PrintStream.class)); + then(banner).should().printBanner(any(Environment.class), this.sourceClassCaptor.capture(), + any(PrintStream.class)); reset(banner); printedBanner.printBanner(this.context.getEnvironment(), null, System.out); - verify(banner).printBanner(any(Environment.class), eq(this.sourceClassCaptor.getValue()), + then(banner).should().printBanner(any(Environment.class), eq(this.sourceClassCaptor.getValue()), any(PrintStream.class)); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java index 32a9492cfc..d50a21bc3a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java @@ -33,14 +33,14 @@ import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.BDDMockito.then; /** * Tests for {@link DefaultPropertiesPropertySource}. * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DefaultPropertiesPropertySourceTests { @@ -84,19 +84,19 @@ class DefaultPropertiesPropertySourceTests { @Test void ifNotEmptyWhenNullDoesNotCallAction() { DefaultPropertiesPropertySource.ifNotEmpty(null, this.action); - verifyNoInteractions(this.action); + then(this.action).shouldHaveNoInteractions(); } @Test void ifNotEmptyWhenEmptyDoesNotCallAction() { DefaultPropertiesPropertySource.ifNotEmpty(Collections.emptyMap(), this.action); - verifyNoInteractions(this.action); + then(this.action).shouldHaveNoInteractions(); } @Test void ifNotEmptyHasValueCallsAction() { DefaultPropertiesPropertySource.ifNotEmpty(Collections.singletonMap("spring", "boot"), this.action); - verify(this.action).accept(this.captor.capture()); + then(this.action).should().accept(this.captor.capture()); assertThat(this.captor.getValue().getProperty("spring")).isEqualTo("boot"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 7d88270f19..3be1f7ceff 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -122,14 +122,13 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockingDetails; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link SpringApplication}. @@ -267,7 +266,7 @@ class SpringApplicationTests { SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); application.setWebApplicationType(WebApplicationType.NONE); this.context = application.run("--spring.main.banner-mode=log"); - verify(application, atLeastOnce()).setBannerMode(Banner.Mode.LOG); + then(application).should(atLeastOnce()).setBannerMode(Banner.Mode.LOG); assertThat(output).contains("o.s.b.SpringApplication"); } @@ -434,15 +433,16 @@ class SpringApplicationTests { application.addListeners(listener); this.context = application.run(); InOrder inOrder = Mockito.inOrder(listener); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationStartingEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationEnvironmentPreparedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationContextInitializedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationPreparedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ContextRefreshedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationStartedEvent.class)); - inOrder.verify(listener).onApplicationEvent(argThat(isAvailabilityChangeEventWithState(LivenessState.CORRECT))); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); - inOrder.verify(listener) + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationStartingEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationEnvironmentPreparedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationContextInitializedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationPreparedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ContextRefreshedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationStartedEvent.class)); + then(listener).should(inOrder) + .onApplicationEvent(argThat(isAvailabilityChangeEventWithState(LivenessState.CORRECT))); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should(inOrder) .onApplicationEvent(argThat(isAvailabilityChangeEventWithState(ReadinessState.ACCEPTING_TRAFFIC))); inOrder.verifyNoMoreInteractions(); } @@ -494,7 +494,7 @@ class SpringApplicationTests { ConfigurableEnvironment environment = new StandardEnvironment(); application.setEnvironment(environment); this.context = application.run(); - verify(application.getLoader()).setEnvironment(environment); + then(application.getLoader()).should().setEnvironment(environment); } @Test @@ -504,7 +504,7 @@ class SpringApplicationTests { ResourceLoader resourceLoader = new DefaultResourceLoader(); application.setResourceLoader(resourceLoader); this.context = application.run(); - verify(application.getLoader()).setResourceLoader(resourceLoader); + then(application.getLoader()).should().setResourceLoader(resourceLoader); } @Test @@ -512,7 +512,7 @@ class SpringApplicationTests { ResourceLoader resourceLoader = new DefaultResourceLoader(); TestSpringApplication application = new TestSpringApplication(resourceLoader, ExampleWebConfig.class); this.context = application.run(); - verify(application.getLoader()).setResourceLoader(resourceLoader); + then(application.getLoader()).should().setResourceLoader(resourceLoader); } @Test @@ -521,7 +521,7 @@ class SpringApplicationTests { BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator(); application.setBeanNameGenerator(beanNameGenerator); this.context = application.run(); - verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator); + then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator); Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR); assertThat(actualGenerator).isSameAs(beanNameGenerator); } @@ -533,7 +533,7 @@ class SpringApplicationTests { BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator(); application.setBeanNameGenerator(beanNameGenerator); this.context = application.run(); - verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator); + then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator); Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR); assertThat(actualGenerator).isSameAs(beanNameGenerator); } @@ -710,9 +710,9 @@ class SpringApplicationTests { willThrow(failure).given(runner).run(isA(ApplicationArguments.class)); application.addInitializers((context) -> context.getBeanFactory().registerSingleton("runner", runner)); assertThatIllegalStateException().isThrownBy(application::run).withCause(failure); - verify(listener).onApplicationEvent(isA(ApplicationStartedEvent.class)); - verify(listener).onApplicationEvent(isA(ApplicationFailedEvent.class)); - verify(listener, never()).onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationStartedEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).should(never()).onApplicationEvent(isA(ApplicationReadyEvent.class)); } @Test @@ -727,9 +727,9 @@ class SpringApplicationTests { willThrow(failure).given(runner).run(); application.addInitializers((context) -> context.getBeanFactory().registerSingleton("runner", runner)); assertThatIllegalStateException().isThrownBy(application::run).withCause(failure); - verify(listener).onApplicationEvent(isA(ApplicationStartedEvent.class)); - verify(listener).onApplicationEvent(isA(ApplicationFailedEvent.class)); - verify(listener, never()).onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationStartedEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).should(never()).onApplicationEvent(isA(ApplicationReadyEvent.class)); } @Test @@ -742,8 +742,8 @@ class SpringApplicationTests { RuntimeException failure = new RuntimeException(); willThrow(failure).given(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); assertThatExceptionOfType(RuntimeException.class).isThrownBy(application::run).isEqualTo(failure); - verify(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); - verify(listener, never()).onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should(never()).onApplicationEvent(isA(ApplicationFailedEvent.class)); } @Test @@ -758,8 +758,8 @@ class SpringApplicationTests { ExitStatusException failure = new ExitStatusException(); willThrow(failure).given(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); assertThatExceptionOfType(RuntimeException.class).isThrownBy(application::run); - verify(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); - verify(listener, never()).onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).should().onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should(never()).onApplicationEvent(isA(ApplicationFailedEvent.class)); assertThat(exitCodeListener.getExitCode()).isEqualTo(11); assertThat(output).contains("Application run failed"); } @@ -832,7 +832,7 @@ class SpringApplicationTests { application.addListeners(listener); application.setWebApplicationType(WebApplicationType.NONE); assertThatIllegalStateException().isThrownBy(application::run); - verify(handler).registerExitCode(11); + then(handler).should().registerExitCode(11); assertThat(listener.getExitCode()).isEqualTo(11); } @@ -851,7 +851,7 @@ class SpringApplicationTests { application.addListeners(listener); application.setWebApplicationType(WebApplicationType.NONE); assertThatIllegalStateException().isThrownBy(application::run); - verify(handler).registerExitCode(11); + then(handler).should().registerExitCode(11); assertThat(listener.getExitCode()).isEqualTo(11); } @@ -871,7 +871,7 @@ class SpringApplicationTests { application.setWebApplicationType(WebApplicationType.NONE); assertThatExceptionOfType(RuntimeException.class).isThrownBy(application::run); ArgumentCaptor exceptionCaptor = ArgumentCaptor.forClass(RuntimeException.class); - verify(handler).registerLoggedException(exceptionCaptor.capture()); + then(handler).should().registerLoggedException(exceptionCaptor.capture()); assertThat(exceptionCaptor.getValue()).hasCauseInstanceOf(RefreshFailureException.class); assertThat(output).doesNotContain("NullPointerException"); } @@ -955,11 +955,12 @@ class SpringApplicationTests { ApplicationListener listener = this.context.getBean("testApplicationListener", ApplicationListener.class); InOrder inOrder = Mockito.inOrder(listener); - inOrder.verify(listener).onApplicationEvent(isA(ContextRefreshedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationStartedEvent.class)); - inOrder.verify(listener).onApplicationEvent(argThat(isAvailabilityChangeEventWithState(LivenessState.CORRECT))); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationReadyEvent.class)); - inOrder.verify(listener) + then(listener).should(inOrder).onApplicationEvent(isA(ContextRefreshedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationStartedEvent.class)); + then(listener).should(inOrder) + .onApplicationEvent(argThat(isAvailabilityChangeEventWithState(LivenessState.CORRECT))); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationReadyEvent.class)); + then(listener).should(inOrder) .onApplicationEvent(argThat(isAvailabilityChangeEventWithState(ReadinessState.ACCEPTING_TRAFFIC))); inOrder.verifyNoMoreInteractions(); } @@ -987,11 +988,11 @@ class SpringApplicationTests { private void verifyRegisteredListenerFailedFromApplicationEvents(ApplicationListener listener) { InOrder inOrder = Mockito.inOrder(listener); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationStartingEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationEnvironmentPreparedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationContextInitializedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationPreparedEvent.class)); - inOrder.verify(listener).onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationStartingEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationEnvironmentPreparedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationContextInitializedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationPreparedEvent.class)); + then(listener).should(inOrder).onApplicationEvent(isA(ApplicationFailedEvent.class)); inOrder.verifyNoMoreInteractions(); } @@ -1002,8 +1003,8 @@ class SpringApplicationTests { SpringApplication application = new SpringApplication(ExampleConfig.class); application.addInitializers((applicationContext) -> applicationContext.addApplicationListener(listener)); assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(application::run); - verify(listener).onApplicationEvent(isA(ApplicationFailedEvent.class)); - verifyNoMoreInteractions(listener); + then(listener).should().onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).shouldHaveNoMoreInteractions(); } @SuppressWarnings("unchecked") @@ -1014,8 +1015,8 @@ class SpringApplicationTests { application.setWebApplicationType(WebApplicationType.NONE); application.addInitializers((applicationContext) -> applicationContext.addApplicationListener(listener)); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(application::run); - verify(listener).onApplicationEvent(isA(ApplicationFailedEvent.class)); - verifyNoMoreInteractions(listener); + then(listener).should().onApplicationEvent(isA(ApplicationFailedEvent.class)); + then(listener).shouldHaveNoMoreInteractions(); } @Test @@ -1181,12 +1182,12 @@ class SpringApplicationTests { application.setApplicationStartup(applicationStartup); this.context = application.run(); assertThat(this.context.getBean(ApplicationStartup.class)).isEqualTo(applicationStartup); - verify(applicationStartup).start("spring.boot.application.starting"); - verify(applicationStartup).start("spring.boot.application.environment-prepared"); - verify(applicationStartup).start("spring.boot.application.context-prepared"); - verify(applicationStartup).start("spring.boot.application.context-loaded"); - verify(applicationStartup).start("spring.boot.application.started"); - verify(applicationStartup).start("spring.boot.application.running"); + then(applicationStartup).should().start("spring.boot.application.starting"); + then(applicationStartup).should().start("spring.boot.application.environment-prepared"); + then(applicationStartup).should().start("spring.boot.application.context-prepared"); + then(applicationStartup).should().start("spring.boot.application.context-loaded"); + then(applicationStartup).should().start("spring.boot.application.started"); + then(applicationStartup).should().start("spring.boot.application.running"); long startCount = mockingDetails(applicationStartup).getInvocations().stream() .filter((invocation) -> invocation.getMethod().toString().contains("start(")).count(); long endCount = mockingDetails(startupStep).getInvocations().stream() @@ -1205,9 +1206,9 @@ class SpringApplicationTests { application.setWebApplicationType(WebApplicationType.NONE); application.setApplicationStartup(applicationStartup); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(application::run); - verify(applicationStartup).start("spring.boot.application.starting"); - verify(applicationStartup).start("spring.boot.application.environment-prepared"); - verify(applicationStartup).start("spring.boot.application.failed"); + then(applicationStartup).should().start("spring.boot.application.starting"); + then(applicationStartup).should().start("spring.boot.application.environment-prepared"); + then(applicationStartup).should().start("spring.boot.application.failed"); long startCount = mockingDetails(applicationStartup).getInvocations().stream() .filter((invocation) -> invocation.getMethod().toString().contains("start(")).count(); long endCount = mockingDetails(startupStep).getInvocations().stream() diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java index bd7a202a32..adac04d96c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,15 +21,15 @@ import java.lang.reflect.InvocationTargetException; import org.junit.jupiter.api.Test; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link SpringBootExceptionHandler}. * * @author Henri Tremblay * @author Andy Wilkinson + * @author Yanming Zhou */ class SpringBootExceptionHandlerTests { @@ -43,7 +43,7 @@ class SpringBootExceptionHandlerTests { Exception ex = new Exception(); this.handler.registerLoggedException(ex); this.handler.uncaughtException(thread, ex); - verifyNoInteractions(this.parent); + then(this.parent).shouldHaveNoInteractions(); } @Test @@ -52,7 +52,7 @@ class SpringBootExceptionHandlerTests { Exception ex = new Exception("[stuff] Logback configuration error detected [stuff]"); this.handler.registerLoggedException(ex); this.handler.uncaughtException(thread, ex); - verify(this.parent).uncaughtException(thread, ex); + then(this.parent).should().uncaughtException(thread, ex); } @Test @@ -62,7 +62,7 @@ class SpringBootExceptionHandlerTests { new Exception("[stuff] Logback configuration error detected [stuff]", new Exception())); this.handler.registerLoggedException(ex); this.handler.uncaughtException(thread, ex); - verify(this.parent).uncaughtException(thread, ex); + then(this.parent).should().uncaughtException(thread, ex); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java index 7649697704..9fde84fbf9 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java @@ -28,14 +28,15 @@ import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link StartupInfoLogger}. * * @author Dave Syer * @author Andy Wilkinson + * @author Yanming Zhou */ class StartupInfoLoggerTests { @@ -46,7 +47,7 @@ class StartupInfoLoggerTests { given(this.log.isInfoEnabled()).willReturn(true); new StartupInfoLogger(getClass()).logStarting(this.log); ArgumentCaptor captor = ArgumentCaptor.forClass(Object.class); - verify(this.log).info(captor.capture()); + then(this.log).should().info(captor.capture()); assertThat(captor.getValue().toString()).contains("Starting " + getClass().getSimpleName() + " using Java " + System.getProperty("java.version") + " on " + InetAddress.getLocalHost().getHostName() + " with PID " + new ApplicationPid() + " (started by " + System.getProperty("user.name") + " in " @@ -61,7 +62,7 @@ class StartupInfoLoggerTests { stopWatch.stop(); new StartupInfoLogger(getClass()).logStarted(this.log, stopWatch); ArgumentCaptor captor = ArgumentCaptor.forClass(Object.class); - verify(this.log).info(captor.capture()); + then(this.log).should().info(captor.capture()); assertThat(captor.getValue().toString()).matches("Started " + getClass().getSimpleName() + " in \\d+\\.\\d{1,3} seconds \\(JVM running for \\d+\\.\\d{1,3}\\)"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java index feaa35d17a..c370c236db 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -28,13 +28,14 @@ import org.springframework.core.ResolvableType; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link AvailabilityChangeEvent}. * * @author Phillip Webb + * @author Yanming Zhou */ class AvailabilityChangeEventTests { @@ -77,7 +78,7 @@ class AvailabilityChangeEventTests { AvailabilityState state = LivenessState.CORRECT; AvailabilityChangeEvent.publish(context, state); ArgumentCaptor captor = ArgumentCaptor.forClass(ApplicationEvent.class); - verify(context).publishEvent(captor.capture()); + then(context).should().publishEvent(captor.capture()); AvailabilityChangeEvent event = (AvailabilityChangeEvent) captor.getValue(); assertThat(event.getSource()).isEqualTo(context); assertThat(event.getState()).isEqualTo(state); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java index c571779449..dacd712cff 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java @@ -41,13 +41,14 @@ import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link SpringApplicationBuilder}. * * @author Dave Syer + * @author Yanming Zhou */ class SpringApplicationBuilderTests { @@ -133,7 +134,8 @@ class SpringApplicationBuilderTests { .contextFactory(ApplicationContextFactory.ofContextClass(SpyApplicationContext.class)); application.parent(ExampleConfig.class); this.context = application.run("foo.bar=baz"); - verify(((SpyApplicationContext) this.context).getApplicationContext()).setParent(any(ApplicationContext.class)); + then(((SpyApplicationContext) this.context).getApplicationContext()).should() + .setParent(any(ApplicationContext.class)); assertThat(SpringApplicationShutdownHookInstance.get()).didNotRegisterApplicationContext(this.context); assertThat(this.context.getParent().getBean(ApplicationArguments.class).getNonOptionArgs()) .contains("foo.bar=baz"); @@ -146,7 +148,8 @@ class SpringApplicationBuilderTests { .contextFactory(ApplicationContextFactory.ofContextClass(SpyApplicationContext.class)); application.parent(ExampleConfig.class); this.context = application.build("a=alpha").run("b=bravo"); - verify(((SpyApplicationContext) this.context).getApplicationContext()).setParent(any(ApplicationContext.class)); + then(((SpyApplicationContext) this.context).getApplicationContext()).should() + .setParent(any(ApplicationContext.class)); assertThat(SpringApplicationShutdownHookInstance.get()).didNotRegisterApplicationContext(this.context); assertThat(this.context.getParent().getBean(ApplicationArguments.class).getNonOptionArgs()).contains("a=alpha"); assertThat(this.context.getBean(ApplicationArguments.class).getNonOptionArgs()).contains("b=bravo"); @@ -159,7 +162,8 @@ class SpringApplicationBuilderTests { .registerShutdownHook(true); application.parent(ExampleConfig.class); this.context = application.run(); - verify(((SpyApplicationContext) this.context).getApplicationContext()).setParent(any(ApplicationContext.class)); + then(((SpyApplicationContext) this.context).getApplicationContext()).should() + .setParent(any(ApplicationContext.class)); assertThat(SpringApplicationShutdownHookInstance.get()).registeredApplicationContext(this.context); } @@ -190,7 +194,8 @@ class SpringApplicationBuilderTests { .child(ChildConfig.class); application.contextFactory(ApplicationContextFactory.ofContextClass(SpyApplicationContext.class)); this.context = application.run(); - verify(((SpyApplicationContext) this.context).getApplicationContext()).setParent(any(ApplicationContext.class)); + then(((SpyApplicationContext) this.context).getApplicationContext()).should() + .setParent(any(ApplicationContext.class)); assertThat(SpringApplicationShutdownHookInstance.get()).didNotRegisterApplicationContext(this.context); } @@ -247,7 +252,8 @@ class SpringApplicationBuilderTests { application.parent(ExampleConfig.class); application.contextFactory(ApplicationContextFactory.ofContextClass(SpyApplicationContext.class)); this.context = application.run(); - verify(((SpyApplicationContext) this.context).getApplicationContext()).setParent(any(ApplicationContext.class)); + then(((SpyApplicationContext) this.context).getApplicationContext()).should() + .setParent(any(ApplicationContext.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java index 0b9eb4402b..f07becdc72 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java @@ -47,14 +47,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ConfigDataEnvironmentContributors}. * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ConfigDataEnvironmentContributorsTests { @@ -185,7 +186,7 @@ class ConfigDataEnvironmentContributorsTests { ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory, this.bootstrapContext, Arrays.asList(existingContributor, contributor)); contributors.withProcessedImports(this.importer, this.activationContext); - verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any()); + then(this.importer).should().resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any()); ConfigDataLocationResolverContext context = this.locationResolverContext.getValue(); assertThat(context.getBinder().bind("test", String.class).get()).isEqualTo("springboot"); } @@ -212,7 +213,8 @@ class ConfigDataEnvironmentContributorsTests { ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory, this.bootstrapContext, Arrays.asList(contributor)); contributors.withProcessedImports(this.importer, this.activationContext); - verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), eq(secondLocations)); + then(this.importer).should().resolveAndLoad(any(), this.locationResolverContext.capture(), any(), + eq(secondLocations)); ConfigDataLocationResolverContext context = this.locationResolverContext.getValue(); assertThat(context.getParent()).hasToString("a"); } @@ -235,7 +237,7 @@ class ConfigDataEnvironmentContributorsTests { ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory, this.bootstrapContext, Arrays.asList(existingContributor, contributor)); contributors.withProcessedImports(this.importer, this.activationContext); - verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any()); + then(this.importer).should().resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any()); ConfigDataLocationResolverContext context = this.locationResolverContext.getValue(); assertThat(context.getBootstrapContext()).isSameAs(this.bootstrapContext); } @@ -258,7 +260,7 @@ class ConfigDataEnvironmentContributorsTests { ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory, this.bootstrapContext, Arrays.asList(existingContributor, contributor)); contributors.withProcessedImports(this.importer, this.activationContext); - verify(this.importer).resolveAndLoad(any(), any(), this.loaderContext.capture(), any()); + then(this.importer).should().resolveAndLoad(any(), any(), this.loaderContext.capture(), any()); ConfigDataLoaderContext context = this.loaderContext.getValue(); assertThat(context.getBootstrapContext()).isSameAs(this.bootstrapContext); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java index 9fead93f55..7b79b13758 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java @@ -37,10 +37,10 @@ import org.springframework.core.io.ResourceLoader; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willReturn; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; /** @@ -49,6 +49,7 @@ import static org.mockito.Mockito.verifyNoInteractions; * @author Phillip Webb * @author Madhura Bhave * @author Nguyen Bao Sach + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ConfigDataEnvironmentPostProcessorTests { @@ -80,8 +81,8 @@ class ConfigDataEnvironmentPostProcessorTests { void postProcessEnvironmentWhenNoLoaderCreatesDefaultLoaderInstance() { willReturn(this.configDataEnvironment).given(this.postProcessor).getConfigDataEnvironment(any(), any(), any()); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verify(this.postProcessor).getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); - verify(this.configDataEnvironment).processAndApply(); + then(this.postProcessor).should().getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); + then(this.configDataEnvironment).should().processAndApply(); assertThat(this.resourceLoaderCaptor.getValue()).isInstanceOf(DefaultResourceLoader.class); } @@ -91,8 +92,8 @@ class ConfigDataEnvironmentPostProcessorTests { this.application.setResourceLoader(resourceLoader); willReturn(this.configDataEnvironment).given(this.postProcessor).getConfigDataEnvironment(any(), any(), any()); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verify(this.postProcessor).getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); - verify(this.configDataEnvironment).processAndApply(); + then(this.postProcessor).should().getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); + then(this.configDataEnvironment).should().processAndApply(); assertThat(this.resourceLoaderCaptor.getValue()).isSameAs(resourceLoader); } @@ -101,8 +102,9 @@ class ConfigDataEnvironmentPostProcessorTests { this.application.setAdditionalProfiles("dev"); willReturn(this.configDataEnvironment).given(this.postProcessor).getConfigDataEnvironment(any(), any(), any()); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verify(this.postProcessor).getConfigDataEnvironment(any(), any(), this.additionalProfilesCaptor.capture()); - verify(this.configDataEnvironment).processAndApply(); + then(this.postProcessor).should().getConfigDataEnvironment(any(), any(), + this.additionalProfilesCaptor.capture()); + then(this.configDataEnvironment).should().processAndApply(); assertThat(this.additionalProfilesCaptor.getValue()).containsExactly("dev"); } @@ -110,8 +112,8 @@ class ConfigDataEnvironmentPostProcessorTests { void postProcessEnvironmentWhenNoActiveProfiles() { willReturn(this.configDataEnvironment).given(this.postProcessor).getConfigDataEnvironment(any(), any(), any()); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verify(this.postProcessor).getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); - verify(this.configDataEnvironment).processAndApply(); + then(this.postProcessor).should().getConfigDataEnvironment(any(), this.resourceLoaderCaptor.capture(), any()); + then(this.configDataEnvironment).should().processAndApply(); assertThat(this.environment.getActiveProfiles()).isEmpty(); } @@ -124,7 +126,7 @@ class ConfigDataEnvironmentPostProcessorTests { willReturn(legacyListener).given(this.postProcessor).getLegacyListener(); this.postProcessor.postProcessEnvironment(this.environment, this.application); verifyNoInteractions(this.configDataEnvironment); - verify(legacyListener).addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); + then(legacyListener).should().addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); assertThat(this.environment.getActiveProfiles()).isEmpty(); } @@ -138,7 +140,7 @@ class ConfigDataEnvironmentPostProcessorTests { willReturn(legacyListener).given(this.postProcessor).getLegacyListener(); this.postProcessor.postProcessEnvironment(this.environment, this.application); verifyNoInteractions(this.configDataEnvironment); - verify(legacyListener).addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); + then(legacyListener).should().addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); assertThat(this.environment.getActiveProfiles()).containsExactly("dev"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java index 2f3cafd149..17c22da3c0 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java @@ -30,14 +30,15 @@ import org.springframework.mock.env.MockPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link InvalidConfigDataPropertyException}. * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ class InvalidConfigDataPropertyExceptionTests { @@ -162,7 +163,7 @@ class InvalidConfigDataPropertyExceptionTests { propertySource.setProperty("spring.profiles", "a"); ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofExisting(propertySource); InvalidConfigDataPropertyException.throwOrWarn(this.logger, contributor); - verify(this.logger).warn("Property 'spring.profiles' is invalid and should be replaced with " + then(this.logger).should().warn("Property 'spring.profiles' is invalid and should be replaced with " + "'spring.config.activate.on-profile' [origin: \"spring.profiles\" from property source \"mockProperties\"]"); } @@ -172,7 +173,7 @@ class InvalidConfigDataPropertyExceptionTests { propertySource.setProperty("spring.profiles[0]", "a"); ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofExisting(propertySource); InvalidConfigDataPropertyException.throwOrWarn(this.logger, contributor); - verify(this.logger).warn("Property 'spring.profiles[0]' is invalid and should be replaced with " + then(this.logger).should().warn("Property 'spring.profiles[0]' is invalid and should be replaced with " + "'spring.config.activate.on-profile' [origin: \"spring.profiles[0]\" from property source \"mockProperties\"]"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index 07dd481234..2ff92dc927 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -105,8 +105,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link ConfigurationProperties @ConfigurationProperties}-annotated beans. @@ -120,6 +120,7 @@ import static org.mockito.Mockito.verify; * @author Stephane Nicoll * @author Madhura Bhave * @author Vladislav Kisel + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class ConfigurationPropertiesTests { @@ -620,7 +621,7 @@ class ConfigurationPropertiesTests { this.context.addProtocolResolver(protocolResolver); this.context.register(PropertiesWithResource.class); this.context.refresh(); - verify(protocolResolver).resolve(eq("application.properties"), any(ResourceLoader.class)); + then(protocolResolver).should().resolve(eq("application.properties"), any(ResourceLoader.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java index 4fde563278..c5fe03b0a8 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java @@ -28,15 +28,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link EnableConfigurationPropertiesRegistrar}. * * @author Madhura Bhave * @author Stephane Nicoll + * @author Yanming Zhou */ class EnableConfigurationPropertiesRegistrarTests { @@ -85,7 +85,7 @@ class EnableConfigurationPropertiesRegistrarTests { void registrationWithDuplicatedTypeShouldRegisterSingleBeanDefinition() { register(DuplicateConfiguration.class); String name = "foo-" + getClass().getName() + "$FooProperties"; - verify(this.beanFactory, times(1)).registerBeanDefinition(eq(name), any()); + then(this.beanFactory).should().registerBeanDefinition(eq(name), any()); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java index 7115c31c32..81ca3e72a4 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java @@ -41,13 +41,14 @@ import org.springframework.core.convert.support.GenericConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link BindConverter}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BindConverterTests { @@ -63,7 +64,7 @@ class BindConverterTests { @Test void createWhenPropertyEditorInitializerIsNotNullShouldUseToInitialize() { BindConverter.get(null, this.propertyEditorInitializer); - verify(this.propertyEditorInitializer).accept(any(PropertyEditorRegistry.class)); + then(this.propertyEditorInitializer).should().accept(any(PropertyEditorRegistry.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java index 46784450c2..67f58045bb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIOException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.BDDMockito.then; /** * Tests for {@link BindResult}. * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BindResultTests { @@ -89,14 +89,14 @@ class BindResultTests { void ifBoundWhenHasValueShouldCallConsumer() { BindResult result = BindResult.of("foo"); result.ifBound(this.consumer); - verify(this.consumer).accept("foo"); + then(this.consumer).should().accept("foo"); } @Test void ifBoundWhenHasNoValueShouldNotCallConsumer() { BindResult result = BindResult.of(null); result.ifBound(this.consumer); - verifyNoInteractions(this.consumer); + then(this.consumer).shouldHaveNoInteractions(); } @Test @@ -117,7 +117,7 @@ class BindResultTests { void mapWhenHasNoValueShouldNotCallMapper() { BindResult result = BindResult.of(null); result.map(this.mapper); - verifyNoInteractions(this.mapper); + then(this.mapper).shouldHaveNoInteractions(); } @Test @@ -136,7 +136,7 @@ class BindResultTests { void orElseGetWhenHasValueShouldReturnValue() { BindResult result = BindResult.of("foo"); assertThat(result.orElseGet(this.supplier)).isEqualTo("foo"); - verifyNoInteractions(this.supplier); + then(this.supplier).shouldHaveNoInteractions(); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java index 6716785908..b741a2c83e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java @@ -31,14 +31,14 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyS import org.springframework.boot.context.properties.source.MockConfigurationPropertySource; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link BoundPropertiesTrackingBindHandler}. * * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BoundPropertiesTrackingBindHandlerTests { @@ -62,8 +62,8 @@ class BoundPropertiesTrackingBindHandlerTests { void handlerShouldCallRecordBindingIfConfigurationPropertyIsNotNull() { this.sources.add(new MockConfigurationPropertySource("foo.age", 4)); this.binder.bind("foo", Bindable.of(ExampleBean.class), this.handler); - verify(this.consumer, times(1)).accept(any(ConfigurationProperty.class)); - verify(this.consumer, never()).accept(null); + then(this.consumer).should().accept(any(ConfigurationProperty.class)); + then(this.consumer).should(never()).accept(null); } static class ExampleBean { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java index 73aff6f7b4..6da2daaaa6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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,14 +24,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.withSettings; /** * Tests for {@link ConfigurationPropertySourcesCaching}. * * @author Phillip Webb + * @author Yanming Zhou */ class ConfigurationPropertySourcesCachingTests { @@ -62,8 +63,8 @@ class ConfigurationPropertySourcesCachingTests { @Test void enableDelegatesToCachingConfigurationPropertySources() { this.caching.enable(); - verify(getCaching(0)).enable(); - verify(getCaching(2)).enable(); + then(getCaching(0)).should().enable(); + then(getCaching(2)).should().enable(); } @Test @@ -74,8 +75,8 @@ class ConfigurationPropertySourcesCachingTests { @Test void disableDelegatesToCachingConfigurationPropertySources() { this.caching.disable(); - verify(getCaching(0)).disable(); - verify(getCaching(2)).disable(); + then(getCaching(0)).should().disable(); + then(getCaching(2)).should().disable(); } @Test @@ -87,8 +88,8 @@ class ConfigurationPropertySourcesCachingTests { void setTimeToLiveDelegatesToCachingConfigurationPropertySources() { Duration ttl = Duration.ofDays(1); this.caching.setTimeToLive(ttl); - verify(getCaching(0)).setTimeToLive(ttl); - verify(getCaching(2)).setTimeToLive(ttl); + then(getCaching(0)).should().setTimeToLive(ttl); + then(getCaching(2)).should().setTimeToLive(ttl); } @Test @@ -99,8 +100,8 @@ class ConfigurationPropertySourcesCachingTests { @Test void clearDelegatesToCachingConfigurationPropertySources() { this.caching.clear(); - verify(getCaching(0)).clear(); - verify(getCaching(2)).clear(); + then(getCaching(0)).should().clear(); + then(getCaching(2)).should().clear(); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java index 1599587f95..4644fd1eb7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java @@ -36,14 +36,14 @@ import org.springframework.format.Printer; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link ApplicationConversionService}. * * @author Phillip Webb + * @author Yanming Zhou */ class ApplicationConversionServiceTests { @@ -54,8 +54,8 @@ class ApplicationConversionServiceTests { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ExampleGenericConverter.class)) { ApplicationConversionService.addBeans(this.registry, context); - verify(this.registry).addConverter(context.getBean(ExampleGenericConverter.class)); - verifyNoMoreInteractions(this.registry); + then(this.registry).should().addConverter(context.getBean(ExampleGenericConverter.class)); + then(this.registry).shouldHaveNoMoreInteractions(); } } @@ -63,8 +63,8 @@ class ApplicationConversionServiceTests { void addBeansWhenHasConverterBeanAddConverter() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExampleConverter.class)) { ApplicationConversionService.addBeans(this.registry, context); - verify(this.registry).addConverter(context.getBean(ExampleConverter.class)); - verifyNoMoreInteractions(this.registry); + then(this.registry).should().addConverter(context.getBean(ExampleConverter.class)); + then(this.registry).shouldHaveNoMoreInteractions(); } } @@ -72,8 +72,8 @@ class ApplicationConversionServiceTests { void addBeansWhenHasFormatterBeanAddsOnlyFormatter() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExampleFormatter.class)) { ApplicationConversionService.addBeans(this.registry, context); - verify(this.registry).addFormatter(context.getBean(ExampleFormatter.class)); - verifyNoMoreInteractions(this.registry); + then(this.registry).should().addFormatter(context.getBean(ExampleFormatter.class)); + then(this.registry).shouldHaveNoMoreInteractions(); } } @@ -81,8 +81,8 @@ class ApplicationConversionServiceTests { void addBeansWhenHasPrinterBeanAddPrinter() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExamplePrinter.class)) { ApplicationConversionService.addBeans(this.registry, context); - verify(this.registry).addPrinter(context.getBean(ExamplePrinter.class)); - verifyNoMoreInteractions(this.registry); + then(this.registry).should().addPrinter(context.getBean(ExamplePrinter.class)); + then(this.registry).shouldHaveNoMoreInteractions(); } } @@ -90,8 +90,8 @@ class ApplicationConversionServiceTests { void addBeansWhenHasParserBeanAddParser() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExampleParser.class)) { ApplicationConversionService.addBeans(this.registry, context); - verify(this.registry).addParser(context.getBean(ExampleParser.class)); - verifyNoMoreInteractions(this.registry); + then(this.registry).should().addParser(context.getBean(ExampleParser.class)); + then(this.registry).shouldHaveNoMoreInteractions(); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java index 458f61629d..a82633ed1f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java @@ -30,15 +30,16 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.core.env.Environment; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link FailureAnalyzers}. * * @author Andy Wilkinson * @author Stephane Nicoll + * @author Yanming Zhou */ class FailureAnalyzersTests { @@ -53,42 +54,42 @@ class FailureAnalyzersTests { void analyzersAreLoadedAndCalled() { RuntimeException failure = new RuntimeException(); analyzeAndReport("basic.factories", failure); - verify(failureAnalyzer, times(2)).analyze(failure); + then(failureAnalyzer).should(times(2)).analyze(failure); } @Test void beanFactoryIsInjectedIntoBeanFactoryAwareFailureAnalyzers() { RuntimeException failure = new RuntimeException(); analyzeAndReport("basic.factories", failure); - verify(failureAnalyzer).setBeanFactory(any(BeanFactory.class)); + then(failureAnalyzer).should().setBeanFactory(any(BeanFactory.class)); } @Test void environmentIsInjectedIntoEnvironmentAwareFailureAnalyzers() { RuntimeException failure = new RuntimeException(); analyzeAndReport("basic.factories", failure); - verify(failureAnalyzer).setEnvironment(any(Environment.class)); + then(failureAnalyzer).should().setEnvironment(any(Environment.class)); } @Test void analyzerThatFailsDuringInitializationDoesNotPreventOtherAnalyzersFromBeingCalled() { RuntimeException failure = new RuntimeException(); analyzeAndReport("broken-initialization.factories", failure); - verify(failureAnalyzer, times(1)).analyze(failure); + then(failureAnalyzer).should().analyze(failure); } @Test void analyzerThatFailsDuringAnalysisDoesNotPreventOtherAnalyzersFromBeingCalled() { RuntimeException failure = new RuntimeException(); analyzeAndReport("broken-analysis.factories", failure); - verify(failureAnalyzer, times(1)).analyze(failure); + then(failureAnalyzer).should().analyze(failure); } @Test void createWithNullContextSkipsAwareAnalyzers() { RuntimeException failure = new RuntimeException(); analyzeAndReport("basic.factories", failure, null); - verify(failureAnalyzer, times(1)).analyze(failure); + then(failureAnalyzer).should().analyze(failure); } private void analyzeAndReport(String factoriesName, Throwable failure) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java index 2d2db32616..7ccbfc1b07 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java @@ -34,14 +34,15 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link EnvironmentPostProcessorApplicationListener}. * * @author Phillip Webb + * @author Yanming Zhou */ class EnvironmentPostProcessorApplicationListenerTests { @@ -105,7 +106,7 @@ class EnvironmentPostProcessorApplicationListenerTests { ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class); ApplicationPreparedEvent event = new ApplicationPreparedEvent(application, new String[0], context); this.listener.onApplicationEvent(event); - verify(this.deferredLogs).switchOverAll(); + then(this.deferredLogs).should().switchOverAll(); } @Test @@ -115,7 +116,7 @@ class EnvironmentPostProcessorApplicationListenerTests { ApplicationFailedEvent event = new ApplicationFailedEvent(application, new String[0], context, new RuntimeException()); this.listener.onApplicationEvent(event); - verify(this.deferredLogs).switchOverAll(); + then(this.deferredLogs).should().switchOverAll(); } static class TestEnvironmentPostProcessor implements EnvironmentPostProcessor { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java index c2173351e9..04f327474b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java @@ -33,14 +33,14 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource; import org.springframework.jdbc.datasource.SmartDataSource; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link DataSourceUnwrapper}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class DataSourceUnwrapperTests { @@ -102,15 +102,15 @@ class DataSourceUnwrapperTests { void unwrappingIsNotAttemptedWhenTargetIsNotAnInterface() { DataSource dataSource = mock(DataSource.class); assertThat(DataSourceUnwrapper.unwrap(dataSource, HikariDataSource.class)).isNull(); - verifyNoMoreInteractions(dataSource); + then(dataSource).shouldHaveNoMoreInteractions(); } @Test void unwrappingIsNotAttemptedWhenDataSourceIsNotWrapperForTarget() throws SQLException { DataSource dataSource = mock(DataSource.class); assertThat(DataSourceUnwrapper.unwrap(dataSource, Consumer.class)).isNull(); - verify(dataSource).isWrapperFor(Consumer.class); - verifyNoMoreInteractions(dataSource); + then(dataSource).should().isWrapperFor(Consumer.class); + then(dataSource).shouldHaveNoMoreInteractions(); } private DataSource wrapInProxy(DataSource dataSource) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java index f7d5af24e6..2b5099800b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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,14 +24,15 @@ import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link JacksonJsonParser}. * * @author Dave Syer * @author Stephane Nicoll + * @author Yanming Zhou */ class JacksonJsonParserTests extends AbstractJsonParserTests { @@ -45,7 +46,7 @@ class JacksonJsonParserTests extends AbstractJsonParserTests { void instanceWithSpecificObjectMapper() throws IOException { ObjectMapper objectMapper = spy(new ObjectMapper()); new JacksonJsonParser(objectMapper).parseMap("{}"); - verify(objectMapper).readValue(eq("{}"), any(TypeReference.class)); + then(objectMapper).should().readValue(eq("{}"), any(TypeReference.class)); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java index 64f75ad501..c032c594e4 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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,15 +23,14 @@ import org.springframework.boot.logging.DeferredLog.Lines; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link DeferredLog}. * * @author Phillip Webb + * @author Yanming Zhou */ class DeferredLogTests { @@ -77,84 +76,84 @@ class DeferredLogTests { void trace() { this.deferredLog.trace(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).trace(this.message, null); + then(this.log).should().trace(this.message, null); } @Test void traceWithThrowable() { this.deferredLog.trace(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).trace(this.message, this.throwable); + then(this.log).should().trace(this.message, this.throwable); } @Test void debug() { this.deferredLog.debug(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).debug(this.message, null); + then(this.log).should().debug(this.message, null); } @Test void debugWithThrowable() { this.deferredLog.debug(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).debug(this.message, this.throwable); + then(this.log).should().debug(this.message, this.throwable); } @Test void info() { this.deferredLog.info(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).info(this.message, null); + then(this.log).should().info(this.message, null); } @Test void infoWithThrowable() { this.deferredLog.info(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).info(this.message, this.throwable); + then(this.log).should().info(this.message, this.throwable); } @Test void warn() { this.deferredLog.warn(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).warn(this.message, null); + then(this.log).should().warn(this.message, null); } @Test void warnWithThrowable() { this.deferredLog.warn(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).warn(this.message, this.throwable); + then(this.log).should().warn(this.message, this.throwable); } @Test void error() { this.deferredLog.error(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).error(this.message, null); + then(this.log).should().error(this.message, null); } @Test void errorWithThrowable() { this.deferredLog.error(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).error(this.message, this.throwable); + then(this.log).should().error(this.message, this.throwable); } @Test void fatal() { this.deferredLog.fatal(this.message); this.deferredLog.replayTo(this.log); - verify(this.log).fatal(this.message, null); + then(this.log).should().fatal(this.message, null); } @Test void fatalWithThrowable() { this.deferredLog.fatal(this.message, this.throwable); this.deferredLog.replayTo(this.log); - verify(this.log).fatal(this.message, this.throwable); + then(this.log).should().fatal(this.message, this.throwable); } @Test @@ -164,10 +163,10 @@ class DeferredLogTests { Log log2 = mock(Log.class); this.deferredLog.replayTo(this.log); this.deferredLog.replayTo(log2); - verify(this.log).info("1", null); - verify(this.log).fatal("2", null); - verifyNoMoreInteractions(this.log); - verifyNoInteractions(log2); + then(this.log).should().info("1", null); + then(this.log).should().fatal("2", null); + then(this.log).shouldHaveNoMoreInteractions(); + then(log2).shouldHaveNoInteractions(); } @Test @@ -180,8 +179,8 @@ class DeferredLogTests { assertThat(lines).isEmpty(); this.deferredLog.info("Message2"); assertThat(lines).isEmpty(); - verify(this.log).error(this.message, this.throwable); - verify(this.log).info("Message2", null); + then(this.log).should().error(this.message, this.throwable); + then(this.log).should().info("Message2", null); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java index 6dc1d88a5b..278b5a588b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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,15 +20,15 @@ import org.apache.commons.logging.Log; import org.junit.jupiter.api.Test; import org.mockito.InOrder; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link DeferredLogs}. * * @author Phillip Webb + * @author Yanming Zhou */ class DeferredLogsTests { @@ -43,18 +43,20 @@ class DeferredLogsTests { dlog2.info("b"); dlog1.info("c"); dlog2.info("d"); - verifyNoInteractions(log1, log2); + then(log1).shouldHaveNoInteractions(); + then(log2).shouldHaveNoInteractions(); loggers.switchOverAll(); InOrder ordered = inOrder(log1, log2); - ordered.verify(log1).info("a", null); - ordered.verify(log2).info("b", null); - ordered.verify(log1).info("c", null); - ordered.verify(log2).info("d", null); - verifyNoMoreInteractions(log1, log2); + then(log1).should(ordered).info("a", null); + then(log2).should(ordered).info("b", null); + then(log1).should(ordered).info("c", null); + then(log2).should(ordered).info("d", null); + then(log1).shouldHaveNoMoreInteractions(); + then(log2).shouldHaveNoMoreInteractions(); dlog1.info("e"); dlog2.info("f"); - ordered.verify(log1).info("e", null); - ordered.verify(log2).info("f", null); + then(log1).should(ordered).info("e", null); + then(log2).should(ordered).info("f", null); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java index b683ea4796..8af76f78ba 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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,14 +23,14 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link DelegatingLoggingSystemFactory}. * * @author Phillip Webb + * @author Yanming Zhou */ class DelegatingLoggingSystemFactoryTests { @@ -58,9 +58,9 @@ class DelegatingLoggingSystemFactoryTests { given(delegates.get(1).getLoggingSystem(this.classLoader)).willReturn(result); DelegatingLoggingSystemFactory factory = new DelegatingLoggingSystemFactory((cl) -> delegates); assertThat(factory.getLoggingSystem(this.classLoader)).isSameAs(result); - verify(delegates.get(0)).getLoggingSystem(this.classLoader); - verify(delegates.get(1)).getLoggingSystem(this.classLoader); - verifyNoInteractions(delegates.get(2)); + then(delegates.get(0)).should().getLoggingSystem(this.classLoader); + then(delegates.get(1)).should().getLoggingSystem(this.classLoader); + then(delegates.get(2)).shouldHaveNoInteractions(); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index 2a96b0781f..41a8993635 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -57,9 +57,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.contentOf; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link Log4J2LoggingSystem}. @@ -69,6 +69,7 @@ import static org.mockito.Mockito.verify; * @author Andy Wilkinson * @author Ben Hale * @author Madhura Bhave + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { @@ -333,11 +334,11 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.initialize(null, null, null); this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(null, null, null); - verify(listener, times(2)).propertyChange(any(PropertyChangeEvent.class)); + then(listener).should(times(2)).propertyChange(any(PropertyChangeEvent.class)); this.loggingSystem.cleanUp(); this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(null, null, null); - verify(listener, times(4)).propertyChange(any(PropertyChangeEvent.class)); + then(listener).should(times(4)).propertyChange(any(PropertyChangeEvent.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 3b8fc3a13e..56076e2a9e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -67,9 +67,9 @@ import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.contentOf; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link LogbackLoggingSystem}. @@ -82,6 +82,7 @@ import static org.mockito.Mockito.verify; * @author Vedran Pavic * @author Robert Thornton * @author Eddú Meléndez + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { @@ -539,12 +540,12 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { initialize(this.initializationContext, null, null); this.loggingSystem.beforeInitialize(); initialize(this.initializationContext, null, null); - verify(listener, times(1)).onReset(loggerContext); + then(listener).should().onReset(loggerContext); this.loggingSystem.cleanUp(); loggerContext.addListener(listener); this.loggingSystem.beforeInitialize(); initialize(this.initializationContext, null, null); - verify(listener, times(2)).onReset(loggerContext); + then(listener).should(times(2)).onReset(loggerContext); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java index 3f1b66c83b..ca318c1af1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -34,13 +34,14 @@ import org.springframework.core.env.Profiles; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link SpringProfileAction}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class SpringProfileActionTests { @@ -64,7 +65,7 @@ class SpringProfileActionTests { given(this.attributes.getValue(Action.NAME_ATTRIBUTE)).willReturn("dev"); this.action.begin(this.interpretationContext, null, this.attributes); ArgumentCaptor profiles = ArgumentCaptor.forClass(Profiles.class); - verify(this.environment).acceptsProfiles(profiles.capture()); + then(this.environment).should().acceptsProfiles(profiles.capture()); List profileNames = new ArrayList<>(); profiles.getValue().matches((profile) -> { profileNames.add(profile); @@ -78,7 +79,7 @@ class SpringProfileActionTests { given(this.attributes.getValue(Action.NAME_ATTRIBUTE)).willReturn("dev,qa"); this.action.begin(this.interpretationContext, null, this.attributes); ArgumentCaptor profiles = ArgumentCaptor.forClass(Profiles.class); - verify(this.environment).acceptsProfiles(profiles.capture()); + then(this.environment).should().acceptsProfiles(profiles.capture()); List profileNames = new ArrayList<>(); profiles.getValue().matches((profile) -> { profileNames.add(profile); @@ -93,7 +94,7 @@ class SpringProfileActionTests { this.context.putProperty("profile", "dev"); this.action.begin(this.interpretationContext, null, this.attributes); ArgumentCaptor profiles = ArgumentCaptor.forClass(Profiles.class); - verify(this.environment).acceptsProfiles(profiles.capture()); + then(this.environment).should().acceptsProfiles(profiles.capture()); List profileNames = new ArrayList<>(); profiles.getValue().matches((profile) -> { profileNames.add(profile); @@ -110,7 +111,7 @@ class SpringProfileActionTests { this.context.putProperty("profile2", "qa"); this.action.begin(this.interpretationContext, null, this.attributes); ArgumentCaptor profiles = ArgumentCaptor.forClass(Profiles.class); - verify(this.environment).acceptsProfiles(profiles.capture()); + then(this.environment).should().acceptsProfiles(profiles.capture()); List profileNames = new ArrayList<>(); profiles.getValue().matches((profile) -> { profileNames.add(profile); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java index 7ebc7abd70..d3ff36e697 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java @@ -27,13 +27,14 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.WritableResource; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link OriginTrackedResource}. * * @author Phillip Webb + * @author Yanming Zhou */ class OriginTrackedResourceTests { @@ -53,91 +54,91 @@ class OriginTrackedResourceTests { @Test void getInputStreamDelegatesToResource() throws IOException { this.tracked.getInputStream(); - verify(this.resource).getInputStream(); + then(this.resource).should().getInputStream(); } @Test void existsDelegatesToResource() { this.tracked.exists(); - verify(this.resource).exists(); + then(this.resource).should().exists(); } @Test void isReadableDelegatesToResource() { this.tracked.isReadable(); - verify(this.resource).isReadable(); + then(this.resource).should().isReadable(); } @Test void isOpenDelegatesToResource() { this.tracked.isOpen(); - verify(this.resource).isOpen(); + then(this.resource).should().isOpen(); } @Test void isFileDelegatesToResource() { this.tracked.isFile(); - verify(this.resource).isFile(); + then(this.resource).should().isFile(); } @Test void getURLDelegatesToResource() throws IOException { this.tracked.getURL(); - verify(this.resource).getURL(); + then(this.resource).should().getURL(); } @Test void getURIDelegatesToResource() throws IOException { this.tracked.getURI(); - verify(this.resource).getURI(); + then(this.resource).should().getURI(); } @Test void getFileDelegatesToResource() throws IOException { this.tracked.getFile(); - verify(this.resource).getFile(); + then(this.resource).should().getFile(); } @Test void readableChannelDelegatesToResource() throws IOException { this.tracked.readableChannel(); - verify(this.resource).readableChannel(); + then(this.resource).should().readableChannel(); } @Test void contentLengthDelegatesToResource() throws IOException { this.tracked.contentLength(); - verify(this.resource).contentLength(); + then(this.resource).should().contentLength(); } @Test void lastModifiedDelegatesToResource() throws IOException { this.tracked.lastModified(); - verify(this.resource).lastModified(); + then(this.resource).should().lastModified(); } @Test void createRelativeDelegatesToResource() throws IOException { this.tracked.createRelative("path"); - verify(this.resource).createRelative("path"); + then(this.resource).should().createRelative("path"); } @Test void getFilenameDelegatesToResource() { this.tracked.getFilename(); - verify(this.resource).getFilename(); + then(this.resource).should().getFilename(); } @Test void getDescriptionDelegatesToResource() { this.tracked.getDescription(); - verify(this.resource).getDescription(); + then(this.resource).should().getDescription(); } @Test void getOutputStreamDelegatesToResource() throws IOException { this.tracked.getOutputStream(); - verify(this.resource).getOutputStream(); + then(this.resource).should().getOutputStream(); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java index a1fd70e83c..6490d2d716 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -28,14 +28,15 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link RSocketPortInfoApplicationContextInitializer}. * * @author Spencer Gibb * @author Andy Wilkinson + * @author Yanming Zhou */ class RSocketPortInfoApplicationContextInitializerTests { @@ -56,7 +57,7 @@ class RSocketPortInfoApplicationContextInitializerTests { context.getBean(RSocketPortInfoApplicationContextInitializer.class).initialize(context); RSocketServer server = mock(RSocketServer.class); context.publishEvent(new RSocketServerInitializedEvent(server)); - verify(server).address(); + then(server).should().address(); assertThat(context.getEnvironment().getProperty("local.rsocket.server.port")).isNull(); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java index 55427a21db..3be7af7be5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java @@ -53,15 +53,16 @@ import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; /** * Tests for {@link DatabaseInitializationDependencyConfigurer}. * * @author Andy Wilkinson * @author Phillip Webb + * @author Yanming Zhou */ class DatabaseInitializationDependencyConfigurerTests { @@ -132,7 +133,7 @@ class DatabaseInitializationDependencyConfigurerTests { assertThat(alpha.getAttribute(DatabaseInitializerDetector.class.getName())) .isEqualTo(MockDatabaseInitializerDetector.class.getName()); assertThat(bravo.getAttribute(DatabaseInitializerDetector.class.getName())).isNull(); - verify(MockDatabaseInitializerDetector.instance).detectionComplete(context.getBeanFactory(), + then(MockDatabaseInitializerDetector.instance).should().detectionComplete(context.getBeanFactory(), Collections.singleton("alpha")); assertThat(bravo.getDependsOn()).containsExactly("alpha"); }); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java index b3f35dbe20..2d8bb0da64 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -27,16 +27,16 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link TaskExecutorBuilder}. * * @author Stephane Nicoll * @author Filip Hrisafov + * @author Yanming Zhou */ class TaskExecutorBuilderTests { @@ -96,7 +96,7 @@ class TaskExecutorBuilderTests { void customizersShouldApply() { TaskExecutorCustomizer customizer = mock(TaskExecutorCustomizer.class); ThreadPoolTaskExecutor executor = this.builder.customizers(customizer).build(); - verify(customizer).customize(executor); + then(customizer).should().customize(executor); } @Test @@ -106,15 +106,15 @@ class TaskExecutorBuilderTests { this.builder.queueCapacity(10).corePoolSize(4).maxPoolSize(8).allowCoreThreadTimeOut(true) .keepAlive(Duration.ofMinutes(1)).awaitTermination(true).awaitTerminationPeriod(Duration.ofSeconds(30)) .threadNamePrefix("test-").taskDecorator(taskDecorator).additionalCustomizers((taskExecutor) -> { - verify(taskExecutor).setQueueCapacity(10); - verify(taskExecutor).setCorePoolSize(4); - verify(taskExecutor).setMaxPoolSize(8); - verify(taskExecutor).setAllowCoreThreadTimeOut(true); - verify(taskExecutor).setKeepAliveSeconds(60); - verify(taskExecutor).setWaitForTasksToCompleteOnShutdown(true); - verify(taskExecutor).setAwaitTerminationSeconds(30); - verify(taskExecutor).setThreadNamePrefix("test-"); - verify(taskExecutor).setTaskDecorator(taskDecorator); + then(taskExecutor).should().setQueueCapacity(10); + then(taskExecutor).should().setCorePoolSize(4); + then(taskExecutor).should().setMaxPoolSize(8); + then(taskExecutor).should().setAllowCoreThreadTimeOut(true); + then(taskExecutor).should().setKeepAliveSeconds(60); + then(taskExecutor).should().setWaitForTasksToCompleteOnShutdown(true); + then(taskExecutor).should().setAwaitTerminationSeconds(30); + then(taskExecutor).should().setThreadNamePrefix("test-"); + then(taskExecutor).should().setTaskDecorator(taskDecorator); }); this.builder.configure(executor); } @@ -125,8 +125,8 @@ class TaskExecutorBuilderTests { TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class); ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1) .customizers(Collections.singleton(customizer2)).build(); - verifyNoInteractions(customizer1); - verify(customizer2).customize(executor); + then(customizer1).shouldHaveNoInteractions(); + then(customizer2).should().customize(executor); } @Test @@ -149,8 +149,8 @@ class TaskExecutorBuilderTests { TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class); ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1).additionalCustomizers(customizer2) .build(); - verify(customizer1).customize(executor); - verify(customizer2).customize(executor); + then(customizer1).should().customize(executor); + then(customizer2).should().customize(executor); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java index 46bb185a10..fc849ee7e2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -26,15 +26,15 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link TaskSchedulerBuilder}. * * @author Stephane Nicoll + * @author Yanming Zhou */ class TaskSchedulerBuilderTests { @@ -83,15 +83,15 @@ class TaskSchedulerBuilderTests { void customizersShouldApply() { TaskSchedulerCustomizer customizer = mock(TaskSchedulerCustomizer.class); ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer).build(); - verify(customizer).customize(scheduler); + then(customizer).should().customize(scheduler); } @Test void customizersShouldBeAppliedLast() { ThreadPoolTaskScheduler scheduler = spy(new ThreadPoolTaskScheduler()); this.builder.poolSize(4).threadNamePrefix("test-").additionalCustomizers((taskScheduler) -> { - verify(taskScheduler).setPoolSize(4); - verify(taskScheduler).setThreadNamePrefix("test-"); + then(taskScheduler).should().setPoolSize(4); + then(taskScheduler).should().setThreadNamePrefix("test-"); }); this.builder.configure(scheduler); } @@ -102,8 +102,8 @@ class TaskSchedulerBuilderTests { TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class); ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1) .customizers(Collections.singleton(customizer2)).build(); - verifyNoInteractions(customizer1); - verify(customizer2).customize(scheduler); + then(customizer1).shouldHaveNoInteractions(); + then(customizer2).should().customize(scheduler); } @Test @@ -126,8 +126,8 @@ class TaskSchedulerBuilderTests { TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class); ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1).additionalCustomizers(customizer2) .build(); - verify(customizer1).customize(scheduler); - verify(customizer2).customize(scheduler); + then(customizer1).should().customize(scheduler); + then(customizer2).should().customize(scheduler); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java index 359a83c18f..8d79e95863 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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,15 +23,16 @@ import org.springframework.core.type.classreading.MetadataReader; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link ConcurrentReferenceCachingMetadataReaderFactory}. * * @author Phillip Webb + * @author Yanming Zhou */ class ConcurrentReferenceCachingMetadataReaderFactoryTests { @@ -42,7 +43,7 @@ class ConcurrentReferenceCachingMetadataReaderFactoryTests { MetadataReader metadataReader1 = factory.getMetadataReader(getClass().getName()); MetadataReader metadataReader2 = factory.getMetadataReader(getClass().getName()); assertThat(metadataReader1).isSameAs(metadataReader2); - verify(factory, times(1)).createMetadataReader(any(Resource.class)); + then(factory).should().createMetadataReader(any(Resource.class)); } @Test @@ -53,7 +54,7 @@ class ConcurrentReferenceCachingMetadataReaderFactoryTests { factory.clearCache(); MetadataReader metadataReader2 = factory.getMetadataReader(getClass().getName()); assertThat(metadataReader1).isNotSameAs(metadataReader2); - verify(factory, times(2)).createMetadataReader(any(Resource.class)); + then(factory).should(times(2)).createMetadataReader(any(Resource.class)); } static class TestConcurrentReferenceCachingMetadataReaderFactory diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java index 96c1c04042..96eb48feee 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -33,14 +33,14 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link LambdaSafe}. * * @author Phillip Webb + * @author Yanming Zhou */ class LambdaSafeTests { @@ -61,7 +61,7 @@ class LambdaSafeTests { NonGenericCallback callbackInstance = mock(NonGenericCallback.class); String argument = "foo"; LambdaSafe.callback(NonGenericCallback.class, callbackInstance, argument).invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -70,7 +70,7 @@ class LambdaSafeTests { StringCallback callbackInstance = mock(StringCallback.class); String argument = "foo"; LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -79,7 +79,7 @@ class LambdaSafeTests { StringBuilderCallback callbackInstance = mock(StringBuilderCallback.class); StringBuilder argument = new StringBuilder("foo"); LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -88,7 +88,7 @@ class LambdaSafeTests { GenericCallback callbackInstance = mock(StringBuilderCallback.class); String argument = "foo"; LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).invoke((c) -> c.handle(argument)); - verifyNoInteractions(callbackInstance); + then(callbackInstance).shouldHaveNoInteractions(); } @Test @@ -151,7 +151,7 @@ class LambdaSafeTests { given(callbackInstance.handle(any(StringBuilder.class))).willReturn(123); InvocationResult result = LambdaSafe.callback(GenericFactory.class, callbackInstance, argument) .invokeAnd((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); assertThat(result.hasResult()).isTrue(); assertThat(result.get()).isEqualTo(123); } @@ -164,7 +164,7 @@ class LambdaSafeTests { InvocationResult result = LambdaSafe.callback(GenericFactory.class, callbackInstance, argument) .invokeAnd((c) -> c.handle(argument)); assertThat(result.hasResult()).isFalse(); - verifyNoInteractions(callbackInstance); + then(callbackInstance).shouldHaveNoInteractions(); } @Test @@ -199,7 +199,7 @@ class LambdaSafeTests { String argument = "foo"; LambdaSafe.callbacks(NonGenericCallback.class, Collections.singleton(callbackInstance), argument) .invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -209,7 +209,7 @@ class LambdaSafeTests { String argument = "foo"; LambdaSafe.callbacks(GenericCallback.class, Collections.singleton(callbackInstance), argument) .invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -219,7 +219,7 @@ class LambdaSafeTests { StringBuilder argument = new StringBuilder("foo"); LambdaSafe.callbacks(GenericCallback.class, Collections.singleton(callbackInstance), argument) .invoke((c) -> c.handle(argument)); - verify(callbackInstance).handle(argument); + then(callbackInstance).should().handle(argument); } @Test @@ -229,7 +229,7 @@ class LambdaSafeTests { String argument = "foo"; LambdaSafe.callbacks(GenericCallback.class, Collections.singleton(callbackInstance), argument) .invoke((c) -> c.handle(null)); - verifyNoInteractions(callbackInstance); + then(callbackInstance).shouldHaveNoInteractions(); } @Test @@ -365,7 +365,7 @@ class LambdaSafeTests { String argument = "foo"; LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).withFilter(Filter.allowAll()) .invoke((c) -> c.handle(null)); - verify(callbackInstance).handle(null); + then(callbackInstance).should().handle(null); } @Test @@ -377,7 +377,8 @@ class LambdaSafeTests { String argument = "foo"; LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).withLogger(logger) .invoke((c) -> c.handle(argument)); - verify(logger).debug(contains("Non-matching CharSequence type for callback LambdaSafeTests.GenericCallback"), + then(logger).should().debug( + contains("Non-matching CharSequence type for callback LambdaSafeTests.GenericCallback"), any(Throwable.class)); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 7eac2c08f5..80d6cc2403 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -57,11 +57,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.entry; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @@ -74,6 +73,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Dmytro Nosan * @author Kevin Strijbos * @author Ilya Lukyanovich + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RestTemplateBuilderTests { @@ -97,7 +97,7 @@ class RestTemplateBuilderTests { void createWithCustomizersShouldApplyCustomizers() { RestTemplateCustomizer customizer = mock(RestTemplateCustomizer.class); RestTemplate template = new RestTemplateBuilder(customizer).build(); - verify(customizer).customize(template); + then(customizer).should().customize(template); } @Test @@ -129,7 +129,7 @@ class RestTemplateBuilderTests { UriTemplateHandler handler = template.getUriTemplateHandler(); handler.expand("/hello"); assertThat(handler).isInstanceOf(RootUriTemplateHandler.class); - verify(uriTemplateHandler).expand("https://example.com/hello"); + then(uriTemplateHandler).should().expand("https://example.com/hello"); } @Test @@ -369,14 +369,14 @@ class RestTemplateBuilderTests { void customizersShouldApply() { RestTemplateCustomizer customizer = mock(RestTemplateCustomizer.class); RestTemplate template = this.builder.customizers(customizer).build(); - verify(customizer).customize(template); + then(customizer).should().customize(template); } @Test void customizersShouldBeAppliedLast() { RestTemplate template = spy(new RestTemplate()); this.builder.additionalCustomizers( - (restTemplate) -> verify(restTemplate).setRequestFactory(any(ClientHttpRequestFactory.class))); + (restTemplate) -> then(restTemplate).should().setRequestFactory(any(ClientHttpRequestFactory.class))); this.builder.configure(template); } @@ -386,8 +386,8 @@ class RestTemplateBuilderTests { RestTemplateCustomizer customizer2 = mock(RestTemplateCustomizer.class); RestTemplate template = this.builder.customizers(customizer1).customizers(Collections.singleton(customizer2)) .build(); - verifyNoInteractions(customizer1); - verify(customizer2).customize(template); + then(customizer1).shouldHaveNoInteractions(); + then(customizer2).should().customize(template); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java index cb3ba8f7c3..f0de79fd7f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -35,12 +35,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link RootUriTemplateHandler}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RootUriTemplateHandlerTests { @@ -76,7 +77,7 @@ class RootUriTemplateHandlerTests { given(this.delegate.expand(anyString(), any(Map.class))).willReturn(this.uri); HashMap uriVariables = new HashMap<>(); URI expanded = this.handler.expand("/hello", uriVariables); - verify(this.delegate).expand("https://example.com/hello", uriVariables); + then(this.delegate).should().expand("https://example.com/hello", uriVariables); assertThat(expanded).isEqualTo(this.uri); } @@ -86,7 +87,7 @@ class RootUriTemplateHandlerTests { given(this.delegate.expand(anyString(), any(Map.class))).willReturn(this.uri); HashMap uriVariables = new HashMap<>(); URI expanded = this.handler.expand("https://spring.io/hello", uriVariables); - verify(this.delegate).expand("https://spring.io/hello", uriVariables); + then(this.delegate).should().expand("https://spring.io/hello", uriVariables); assertThat(expanded).isEqualTo(this.uri); } @@ -95,7 +96,7 @@ class RootUriTemplateHandlerTests { given(this.delegate.expand(anyString(), any(Object[].class))).willReturn(this.uri); Object[] uriVariables = new Object[0]; URI expanded = this.handler.expand("/hello", uriVariables); - verify(this.delegate).expand("https://example.com/hello", uriVariables); + then(this.delegate).should().expand("https://example.com/hello", uriVariables); assertThat(expanded).isEqualTo(this.uri); } @@ -104,7 +105,7 @@ class RootUriTemplateHandlerTests { given(this.delegate.expand(anyString(), any(Object[].class))).willReturn(this.uri); Object[] uriVariables = new Object[0]; URI expanded = this.handler.expand("https://spring.io/hello", uriVariables); - verify(this.delegate).expand("https://spring.io/hello", uriVariables); + then(this.delegate).should().expand("https://spring.io/hello", uriVariables); assertThat(expanded).isEqualTo(this.uri); } @@ -116,7 +117,7 @@ class RootUriTemplateHandlerTests { this.handler = RootUriTemplateHandler.addTo(restTemplate, "https://example.com"); Object[] uriVariables = new Object[0]; URI expanded = this.handler.expand("/hello", uriVariables); - verify(this.delegate).expand("https://example.com/hello", uriVariables); + then(this.delegate).should().expand("https://example.com/hello", uriVariables); assertThat(expanded).isEqualTo(this.uri); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java index 5b6ff84e7a..4b977763dc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java @@ -55,9 +55,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link TomcatReactiveWebServerFactory}. @@ -65,6 +65,7 @@ import static org.mockito.Mockito.verify; * @author Brian Clozel * @author Madhura Bhave * @author HaiTao Zhang + * @author Yanming Zhou */ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactoryTests { @@ -83,7 +84,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto this.webServer = factory.getWebServer(mock(HttpHandler.class)); InOrder ordered = inOrder((Object[]) customizers); for (TomcatContextCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(Context.class)); + then(customizer).should(ordered).customize(any(Context.class)); } } @@ -94,7 +95,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto factory.addContextCustomizers(customizer); this.webServer = factory.getWebServer(mock(HttpHandler.class)); ArgumentCaptor contextCaptor = ArgumentCaptor.forClass(Context.class); - verify(customizer).customize(contextCaptor.capture()); + then(customizer).should().customize(contextCaptor.capture()); assertThat(contextCaptor.getValue().getParent()).isNotNull(); } @@ -120,7 +121,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto this.webServer = factory.getWebServer(mock(HttpHandler.class)); InOrder ordered = inOrder((Object[]) listeners); for (LifecycleListener listener : listeners) { - ordered.verify(listener).lifecycleEvent(any(LifecycleEvent.class)); + then(listener).should(ordered).lifecycleEvent(any(LifecycleEvent.class)); } } @@ -165,7 +166,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto this.webServer = factory.getWebServer(handler); InOrder ordered = inOrder((Object[]) customizers); for (TomcatConnectorCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(Connector.class)); + then(customizer).should(ordered).customize(any(Connector.class)); } } @@ -181,7 +182,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto this.webServer = factory.getWebServer(handler); InOrder ordered = inOrder((Object[]) customizers); for (TomcatProtocolHandlerCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(ProtocolHandler.class)); + then(customizer).should(ordered).customize(any(ProtocolHandler.class)); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index 0a9b456e2b..8324669a3e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -94,9 +94,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link TomcatServletWebServerFactory}. @@ -104,6 +104,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Dave Syer * @author Stephane Nicoll + * @author Yanming Zhou */ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactoryTests { @@ -153,7 +154,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory this.webServer = factory.getWebServer(); InOrder ordered = inOrder((Object[]) listeners); for (LifecycleListener listener : listeners) { - ordered.verify(listener).lifecycleEvent(any(LifecycleEvent.class)); + then(listener).should(ordered).lifecycleEvent(any(LifecycleEvent.class)); } } @@ -167,7 +168,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory this.webServer = factory.getWebServer(); InOrder ordered = inOrder((Object[]) customizers); for (TomcatContextCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(Context.class)); + then(customizer).should(ordered).customize(any(Context.class)); } } @@ -178,7 +179,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory factory.addContextCustomizers(customizer); this.webServer = factory.getWebServer(); ArgumentCaptor contextCaptor = ArgumentCaptor.forClass(Context.class); - verify(customizer).customize(contextCaptor.capture()); + then(customizer).should().customize(contextCaptor.capture()); assertThat(contextCaptor.getValue().getParent()).isNotNull(); } @@ -192,7 +193,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory this.webServer = factory.getWebServer(); InOrder ordered = inOrder((Object[]) customizers); for (TomcatConnectorCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(Connector.class)); + then(customizer).should(ordered).customize(any(Connector.class)); } } @@ -207,7 +208,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory this.webServer = factory.getWebServer(); InOrder ordered = inOrder((Object[]) customizers); for (TomcatProtocolHandlerCustomizer customizer : customizers) { - ordered.verify(customizer).customize(any(ProtocolHandler.class)); + then(customizer).should(ordered).customize(any(ProtocolHandler.class)); } } @@ -268,7 +269,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory Valve valve = mock(Valve.class); factory.addContextValves(valve); this.webServer = factory.getWebServer(); - verify(valve).setNext(any(Valve.class)); + then(valve).should().setNext(any(Valve.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java index c16930732b..4a26a0f1be 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -41,12 +41,13 @@ import org.springframework.http.server.reactive.HttpHandler; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link ReactiveWebServerApplicationContext}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class ReactiveWebServerApplicationContextTests { @@ -123,7 +124,7 @@ class ReactiveWebServerApplicationContextTests { this.context.refresh(); MockReactiveWebServerFactory factory = this.context.getBean(MockReactiveWebServerFactory.class); this.context.close(); - verify(factory.getWebServer()).stop(); + then(factory.getWebServer()).should().stop(); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java index 77c9e95139..6c90a36df6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java @@ -38,13 +38,14 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Abstract base for {@link AbstractFilterRegistrationBean} tests. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) abstract class AbstractFilterRegistrationBeanTests { @@ -60,9 +61,9 @@ abstract class AbstractFilterRegistrationBeanTests { given(this.servletContext.addFilter(anyString(), any(Filter.class))).willReturn(this.registration); AbstractFilterRegistrationBean bean = createFilterRegistrationBean(); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter(eq("mockFilter"), getExpectedFilter()); - verify(this.registration).setAsyncSupported(true); - verify(this.registration).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); + then(this.servletContext).should().addFilter(eq("mockFilter"), getExpectedFilter()); + then(this.registration).should().setAsyncSupported(true); + then(this.registration).should().addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); } @Test @@ -81,15 +82,16 @@ abstract class AbstractFilterRegistrationBeanTests { bean.addServletRegistrationBeans(mockServletRegistration("s5")); bean.setMatchAfter(true); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter(eq("test"), getExpectedFilter()); - verify(this.registration).setAsyncSupported(false); + then(this.servletContext).should().addFilter(eq("test"), getExpectedFilter()); + then(this.registration).should().setAsyncSupported(false); Map expectedInitParameters = new HashMap<>(); expectedInitParameters.put("a", "b"); expectedInitParameters.put("c", "d"); - verify(this.registration).setInitParameters(expectedInitParameters); - verify(this.registration).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/a", "/b", "/c"); - verify(this.registration).addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "s4", "s5", "s1", - "s2", "s3"); + then(this.registration).should().setInitParameters(expectedInitParameters); + then(this.registration).should().addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/a", "/b", + "/c"); + then(this.registration).should().addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "s4", "s5", + "s1", "s2", "s3"); } @Test @@ -97,14 +99,14 @@ abstract class AbstractFilterRegistrationBeanTests { AbstractFilterRegistrationBean bean = createFilterRegistrationBean(); bean.setName("specificName"); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter(eq("specificName"), getExpectedFilter()); + then(this.servletContext).should().addFilter(eq("specificName"), getExpectedFilter()); } @Test void deducedName() throws Exception { AbstractFilterRegistrationBean bean = createFilterRegistrationBean(); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter(eq("mockFilter"), getExpectedFilter()); + then(this.servletContext).should().addFilter(eq("mockFilter"), getExpectedFilter()); } @Test @@ -112,7 +114,7 @@ abstract class AbstractFilterRegistrationBeanTests { AbstractFilterRegistrationBean bean = createFilterRegistrationBean(); bean.setEnabled(false); bean.onStartup(this.servletContext); - verify(this.servletContext, never()).addFilter(eq("mockFilter"), getExpectedFilter()); + then(this.servletContext).should(never()).addFilter(eq("mockFilter"), getExpectedFilter()); } @Test @@ -137,7 +139,7 @@ abstract class AbstractFilterRegistrationBeanTests { bean.setServletRegistrationBeans( new LinkedHashSet>(Collections.singletonList(mockServletRegistration("b")))); bean.onStartup(this.servletContext); - verify(this.registration).addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), false, "b"); + then(this.registration).should().addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), false, "b"); } @Test @@ -147,7 +149,7 @@ abstract class AbstractFilterRegistrationBeanTests { bean.addInitParameter("a", "b"); bean.getInitParameters().put("a", "c"); bean.onStartup(this.servletContext); - verify(this.registration).setInitParameters(Collections.singletonMap("a", "c")); + then(this.registration).should().setInitParameters(Collections.singletonMap("a", "c")); } @Test @@ -184,8 +186,8 @@ abstract class AbstractFilterRegistrationBeanTests { AbstractFilterRegistrationBean bean = createFilterRegistrationBean(); bean.setDispatcherTypes(DispatcherType.INCLUDE, DispatcherType.FORWARD); bean.onStartup(this.servletContext); - verify(this.registration).addMappingForUrlPatterns(EnumSet.of(DispatcherType.INCLUDE, DispatcherType.FORWARD), - false, "/*"); + then(this.registration).should() + .addMappingForUrlPatterns(EnumSet.of(DispatcherType.INCLUDE, DispatcherType.FORWARD), false, "/*"); } @Test @@ -195,7 +197,7 @@ abstract class AbstractFilterRegistrationBeanTests { EnumSet types = EnumSet.of(DispatcherType.INCLUDE, DispatcherType.FORWARD); bean.setDispatcherTypes(types); bean.onStartup(this.servletContext); - verify(this.registration).addMappingForUrlPatterns(types, false, "/*"); + then(this.registration).should().addMappingForUrlPatterns(types, false, "/*"); } protected abstract Filter getExpectedFilter(); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java index e36060d0a2..0416513cef 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java @@ -36,12 +36,13 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link FilterRegistrationBean}. * * @author Phillip Webb + * @author Yanming Zhou */ class FilterRegistrationBeanTests extends AbstractFilterRegistrationBeanTests { @@ -62,7 +63,7 @@ class FilterRegistrationBeanTests extends AbstractFilterRegistrationBeanTests { FilterRegistrationBean bean = new FilterRegistrationBean<>(); bean.setFilter(this.filter); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter("mockFilter", this.filter); + then(this.servletContext).should().addFilter("mockFilter", this.filter); } @Test @@ -90,9 +91,9 @@ class FilterRegistrationBeanTests extends AbstractFilterRegistrationBeanTests { given(this.servletContext.addFilter(anyString(), any(Filter.class))).willReturn(this.registration); FilterRegistrationBean bean = new FilterRegistrationBean<>(this.oncePerRequestFilter); bean.onStartup(this.servletContext); - verify(this.servletContext).addFilter(eq("oncePerRequestFilter"), eq(this.oncePerRequestFilter)); - verify(this.registration).setAsyncSupported(true); - verify(this.registration).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); + then(this.servletContext).should().addFilter(eq("oncePerRequestFilter"), eq(this.oncePerRequestFilter)); + then(this.registration).should().setAsyncSupported(true); + then(this.registration).should().addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java index ca1e9587a0..7695784b38 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java @@ -28,13 +28,14 @@ import org.mockito.junit.jupiter.MockitoExtension; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletListenerRegistrationBean}. * * @author Dave Syer + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletListenerRegistrationBeanTests { @@ -50,7 +51,7 @@ class ServletListenerRegistrationBeanTests { ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean<>( this.listener); bean.onStartup(this.servletContext); - verify(this.servletContext).addListener(this.listener); + then(this.servletContext).should().addListener(this.listener); } @Test @@ -59,7 +60,7 @@ class ServletListenerRegistrationBeanTests { this.listener); bean.setEnabled(false); bean.onStartup(this.servletContext); - verify(this.servletContext, never()).addListener(any(ServletContextListener.class)); + then(this.servletContext).should(never()).addListener(any(ServletContextListener.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java index d94ef06850..a5cf6ac78f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java @@ -38,13 +38,14 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletRegistrationBean}. * * @author Phillip Webb + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletRegistrationBeanTests { @@ -65,9 +66,9 @@ class ServletRegistrationBeanTests { given(this.servletContext.addServlet(anyString(), any(Servlet.class))).willReturn(this.registration); ServletRegistrationBean bean = new ServletRegistrationBean<>(this.servlet); bean.onStartup(this.servletContext); - verify(this.servletContext).addServlet("mockServlet", this.servlet); - verify(this.registration).setAsyncSupported(true); - verify(this.registration).addMapping("/*"); + then(this.servletContext).should().addServlet("mockServlet", this.servlet); + then(this.registration).should().setAsyncSupported(true); + then(this.registration).should().addMapping("/*"); } @Test @@ -75,8 +76,8 @@ class ServletRegistrationBeanTests { ServletRegistrationBean bean = new ServletRegistrationBean<>(this.servlet); given(this.servletContext.addServlet(anyString(), any(Servlet.class))).willReturn(null); bean.onStartup(this.servletContext); - verify(this.servletContext).addServlet("mockServlet", this.servlet); - verify(this.registration, never()).setAsyncSupported(true); + then(this.servletContext).should().addServlet("mockServlet", this.servlet); + then(this.registration).should(never()).setAsyncSupported(true); } @Test @@ -92,14 +93,14 @@ class ServletRegistrationBeanTests { bean.addUrlMappings("/c"); bean.setLoadOnStartup(10); bean.onStartup(this.servletContext); - verify(this.servletContext).addServlet("test", this.servlet); - verify(this.registration).setAsyncSupported(false); + then(this.servletContext).should().addServlet("test", this.servlet); + then(this.registration).should().setAsyncSupported(false); Map expectedInitParameters = new HashMap<>(); expectedInitParameters.put("a", "b"); expectedInitParameters.put("c", "d"); - verify(this.registration).setInitParameters(expectedInitParameters); - verify(this.registration).addMapping("/a", "/b", "/c"); - verify(this.registration).setLoadOnStartup(10); + then(this.registration).should().setInitParameters(expectedInitParameters); + then(this.registration).should().addMapping("/a", "/b", "/c"); + then(this.registration).should().setLoadOnStartup(10); } @Test @@ -108,7 +109,7 @@ class ServletRegistrationBeanTests { bean.setName("specificName"); bean.setServlet(this.servlet); bean.onStartup(this.servletContext); - verify(this.servletContext).addServlet("specificName", this.servlet); + then(this.servletContext).should().addServlet("specificName", this.servlet); } @Test @@ -116,7 +117,7 @@ class ServletRegistrationBeanTests { ServletRegistrationBean bean = new ServletRegistrationBean<>(); bean.setServlet(this.servlet); bean.onStartup(this.servletContext); - verify(this.servletContext).addServlet("mockServlet", this.servlet); + then(this.servletContext).should().addServlet("mockServlet", this.servlet); } @Test @@ -125,7 +126,7 @@ class ServletRegistrationBeanTests { bean.setServlet(this.servlet); bean.setEnabled(false); bean.onStartup(this.servletContext); - verify(this.servletContext, never()).addServlet("mockServlet", this.servlet); + then(this.servletContext).should(never()).addServlet("mockServlet", this.servlet); } @Test @@ -168,7 +169,7 @@ class ServletRegistrationBeanTests { ServletRegistrationBean bean = new ServletRegistrationBean<>(this.servlet, "/a", "/b"); bean.setUrlMappings(new LinkedHashSet<>(Arrays.asList("/c", "/d"))); bean.onStartup(this.servletContext); - verify(this.registration).addMapping("/c", "/d"); + then(this.registration).should().addMapping("/c", "/d"); } @Test @@ -178,14 +179,14 @@ class ServletRegistrationBeanTests { bean.addInitParameter("a", "b"); bean.getInitParameters().put("a", "c"); bean.onStartup(this.servletContext); - verify(this.registration).setInitParameters(Collections.singletonMap("a", "c")); + then(this.registration).should().setInitParameters(Collections.singletonMap("a", "c")); } @Test void withoutDefaultMappings() throws Exception { ServletRegistrationBean bean = new ServletRegistrationBean<>(this.servlet, false); bean.onStartup(this.servletContext); - verify(this.registration, never()).addMapping(any(String[].class)); + then(this.registration).should(never()).addMapping(any(String[].class)); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java index d4d78c1981..169b0a8b48 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java @@ -39,12 +39,13 @@ import org.springframework.web.context.ServletContextAware; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link AnnotationConfigServletWebServerApplicationContext}. * * @author Phillip Webb + * @author Yanming Zhou */ class AnnotationConfigServletWebServerApplicationContextTests { @@ -138,7 +139,7 @@ class AnnotationConfigServletWebServerApplicationContextTests { private void verifyContext() { MockServletWebServerFactory factory = this.context.getBean(MockServletWebServerFactory.class); Servlet servlet = this.context.getBean(Servlet.class); - verify(factory.getServletContext()).addServlet("servlet", servlet); + then(factory.getServletContext()).should().addServlet("servlet", servlet); } @Component diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java index 1ba3f1d3e0..55bc804aae 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java @@ -81,10 +81,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.withSettings; /** @@ -92,6 +92,7 @@ import static org.mockito.Mockito.withSettings; * * @author Phillip Webb * @author Stephane Nicoll + * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class }) class ServletWebServerApplicationContextTests { @@ -113,8 +114,8 @@ class ServletWebServerApplicationContextTests { MockServletWebServerFactory factory = getWebServerFactory(); // Ensure that the context has been setup assertThat(this.context.getServletContext()).isEqualTo(factory.getServletContext()); - verify(factory.getServletContext()).setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, - this.context); + then(factory.getServletContext()).should() + .setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); // Ensure WebApplicationContextUtils.registerWebApplicationScopes was called assertThat(this.context.getBeanFactory().getRegisteredScope(WebApplicationContext.SCOPE_SESSION)) .isInstanceOf(SessionScope.class); @@ -161,7 +162,7 @@ class ServletWebServerApplicationContextTests { this.context.refresh(); MockServletWebServerFactory factory = getWebServerFactory(); this.context.close(); - verify(factory.getWebServer()).stop(); + then(factory.getWebServer()).should().stop(); } @Test @@ -199,7 +200,7 @@ class ServletWebServerApplicationContextTests { ServletContextAware bean = mock(ServletContextAware.class); this.context.registerBeanDefinition("bean", beanDefinition(bean)); this.context.refresh(); - verify(bean).setServletContext(getWebServerFactory().getServletContext()); + then(bean).should().setServletContext(getWebServerFactory().getServletContext()); } @Test @@ -227,8 +228,8 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("servletBean", beanDefinition(servlet)); this.context.refresh(); MockServletWebServerFactory factory = getWebServerFactory(); - verify(factory.getServletContext()).addServlet("servletBean", servlet); - verify(factory.getRegisteredServlet(0).getRegistration()).addMapping("/"); + then(factory.getServletContext()).should().addServlet("servletBean", servlet); + then(factory.getRegisteredServlet(0).getRegistration()).should().addMapping("/"); } @Test @@ -242,8 +243,8 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("filterRegistrationBean", beanDefinition(registration)); this.context.refresh(); MockServletWebServerFactory factory = getWebServerFactory(); - verify(factory.getServletContext()).addFilter("filterBean", filter); - verify(factory.getServletContext()).addFilter("object", registration.getFilter()); + then(factory.getServletContext()).should().addFilter("filterBean", filter); + then(factory.getServletContext()).should().addFilter("object", registration.getFilter()); assertThat(factory.getRegisteredFilter(0).getFilter()).isEqualTo(filter); } @@ -260,10 +261,10 @@ class ServletWebServerApplicationContextTests { MockServletWebServerFactory factory = getWebServerFactory(); ServletContext servletContext = factory.getServletContext(); InOrder ordered = inOrder(servletContext); - ordered.verify(servletContext).addServlet("servletBean1", servlet1); - ordered.verify(servletContext).addServlet("servletBean2", servlet2); - verify(factory.getRegisteredServlet(0).getRegistration()).addMapping("/servletBean1/"); - verify(factory.getRegisteredServlet(1).getRegistration()).addMapping("/servletBean2/"); + then(servletContext).should(ordered).addServlet("servletBean1", servlet1); + then(servletContext).should(ordered).addServlet("servletBean2", servlet2); + then(factory.getRegisteredServlet(0).getRegistration()).should().addMapping("/servletBean1/"); + then(factory.getRegisteredServlet(1).getRegistration()).should().addMapping("/servletBean2/"); } @Test @@ -279,10 +280,10 @@ class ServletWebServerApplicationContextTests { MockServletWebServerFactory factory = getWebServerFactory(); ServletContext servletContext = factory.getServletContext(); InOrder ordered = inOrder(servletContext); - ordered.verify(servletContext).addServlet("dispatcherServlet", servlet1); - ordered.verify(servletContext).addServlet("servletBean2", servlet2); - verify(factory.getRegisteredServlet(0).getRegistration()).addMapping("/"); - verify(factory.getRegisteredServlet(1).getRegistration()).addMapping("/servletBean2/"); + then(servletContext).should(ordered).addServlet("dispatcherServlet", servlet1); + then(servletContext).should(ordered).addServlet("servletBean2", servlet2); + then(factory.getRegisteredServlet(0).getRegistration()).should().addMapping("/"); + then(factory.getRegisteredServlet(1).getRegistration()).should().addMapping("/servletBean2/"); } @Test @@ -300,13 +301,13 @@ class ServletWebServerApplicationContextTests { MockServletWebServerFactory factory = getWebServerFactory(); ServletContext servletContext = factory.getServletContext(); InOrder ordered = inOrder(servletContext); - verify(factory.getServletContext()).addServlet("servletBean", servlet); - verify(factory.getRegisteredServlet(0).getRegistration()).addMapping("/"); - ordered.verify(factory.getServletContext()).addFilter("filterBean1", filter1); - ordered.verify(factory.getServletContext()).addFilter("filterBean2", filter2); - verify(factory.getRegisteredFilter(0).getRegistration()) + then(factory.getServletContext()).should().addServlet("servletBean", servlet); + then(factory.getRegisteredServlet(0).getRegistration()).should().addMapping("/"); + then(factory.getServletContext()).should(ordered).addFilter("filterBean1", filter1); + then(factory.getServletContext()).should(ordered).addFilter("filterBean2", filter2); + then(factory.getRegisteredFilter(0).getRegistration()).should() .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); - verify(factory.getRegisteredFilter(1).getRegistration()) + then(factory.getRegisteredFilter(1).getRegistration()).should() .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); } @@ -324,8 +325,8 @@ class ServletWebServerApplicationContextTests { this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); InOrder ordered = inOrder(initializer1, initializer2); - ordered.verify(initializer1).onStartup(servletContext); - ordered.verify(initializer2).onStartup(servletContext); + then(initializer1).should(ordered).onStartup(servletContext); + then(initializer2).should(ordered).onStartup(servletContext); } @Test @@ -335,7 +336,7 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("initializerBean", beanDefinition(initializer)); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(servletContext).addListener(initializer); + then(servletContext).should().addListener(initializer); } @Test @@ -347,8 +348,8 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("initializerBean1", beanDefinition(initializer1)); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(initializer1).onStartup(servletContext); - verify(initializer2).onStartup(servletContext); + then(initializer1).should().onStartup(servletContext); + then(initializer2).should().onStartup(servletContext); } @Test @@ -362,9 +363,9 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("filterBean", beanDefinition(filter)); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(initializer).onStartup(servletContext); - verify(servletContext).addServlet(anyString(), any(Servlet.class)); - verify(servletContext).addFilter(anyString(), any(Filter.class)); + then(initializer).should().onStartup(servletContext); + then(servletContext).should().addServlet(anyString(), any(Servlet.class)); + then(servletContext).should().addFilter(anyString(), any(Filter.class)); } @Test @@ -378,8 +379,8 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("filterBean", beanDefinition(filter)); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(servletContext, atMost(1)).addServlet(anyString(), any(Servlet.class)); - verify(servletContext, atMost(1)).addFilter(anyString(), any(Filter.class)); + then(servletContext).should(atMost(1)).addServlet(anyString(), any(Servlet.class)); + then(servletContext).should(atMost(1)).addFilter(anyString(), any(Filter.class)); } @Test @@ -391,7 +392,7 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("filterBean", beanDefinition(filter)); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(servletContext, atMost(1)).addFilter(anyString(), any(Filter.class)); + then(servletContext).should(atMost(1)).addFilter(anyString(), any(Filter.class)); } @Test @@ -404,7 +405,7 @@ class ServletWebServerApplicationContextTests { this.context.registerBeanDefinition("filterBean", filterBeanDefinition); this.context.refresh(); ServletContext servletContext = getWebServerFactory().getServletContext(); - verify(servletContext, atMost(1)).addFilter(anyString(), this.filterCaptor.capture()); + then(servletContext).should(atMost(1)).addFilter(anyString(), this.filterCaptor.capture()); // Up to this point the filterBean should not have been created, calling // the delegate proxy will trigger creation and an exception assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java index 9b8fab137d..2f91e16bdb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java @@ -23,12 +23,13 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.web.servlet.server.MockServletWebServerFactory; import org.springframework.core.io.ClassPathResource; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; /** * Tests for {@link XmlServletWebServerApplicationContext}. * * @author Phillip Webb + * @author Yanming Zhou */ class XmlServletWebServerApplicationContextTests { @@ -84,7 +85,7 @@ class XmlServletWebServerApplicationContextTests { private void verifyContext() { MockServletWebServerFactory factory = this.context.getBean(MockServletWebServerFactory.class); Servlet servlet = this.context.getBean(Servlet.class); - verify(factory.getServletContext()).addServlet("servlet", servlet); + then(factory.getServletContext()).should().addServlet("servlet", servlet); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index d45071c253..5dbcaa9826 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -152,10 +152,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Base for testing classes that extends {@link AbstractServletWebServerFactory}. @@ -164,6 +164,7 @@ import static org.mockito.Mockito.verify; * @author Greg Turnquist * @author Andy Wilkinson * @author Raja Kolli + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) public abstract class AbstractServletWebServerFactoryTests { @@ -376,7 +377,7 @@ public abstract class AbstractServletWebServerFactoryTests { this.webServer.start(); InOrder ordered = inOrder((Object[]) initializers); for (ServletContextInitializer initializer : initializers) { - ordered.verify(initializer).onStartup(any(ServletContext.class)); + then(initializer).should(ordered).onStartup(any(ServletContext.class)); } } @@ -644,8 +645,8 @@ public abstract class AbstractServletWebServerFactoryTests { HttpClient httpClient = this.httpClientBuilder.get().setSSLSocketFactory(socketFactory).build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory)).isEqualTo("test"); - verify(sslStoreProvider, atLeastOnce()).getKeyStore(); - verify(sslStoreProvider, atLeastOnce()).getTrustStore(); + then(sslStoreProvider).should(atLeastOnce()).getKeyStore(); + then(sslStoreProvider).should(atLeastOnce()).getTrustStore(); } @Test @@ -1038,7 +1039,7 @@ public abstract class AbstractServletWebServerFactoryTests { this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener)); this.webServer.start(); this.webServer.stop(); - verify(listener).contextDestroyed(any(ServletContextEvent.class)); + then(listener).should().contextDestroyed(any(ServletContextEvent.class)); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java index e3110ab02c..42787a9993 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java @@ -52,15 +52,16 @@ import org.springframework.web.util.NestedServletException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link ErrorPageFilter}. * * @author Dave Syer * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class ErrorPageFilterTests { @@ -339,7 +340,7 @@ class ErrorPageFilterTests { given(committedResponse.isCommitted()).willReturn(true); given(committedResponse.getStatus()).willReturn(200); this.filter.doFilter(this.request, committedResponse, this.chain); - verify(committedResponse, never()).flushBuffer(); + then(committedResponse).should(never()).flushBuffer(); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java index 557ddeb9d2..e37ef9f21e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java @@ -23,14 +23,15 @@ import org.junit.jupiter.api.Test; import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.WebApplicationContext; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; /** * Tests for {@link ServletContextApplicationContextInitializer}. * * @author Andy Wilkinson + * @author Yanming Zhou */ class ServletContextApplicationContextInitializerTests { @@ -41,20 +42,20 @@ class ServletContextApplicationContextInitializerTests { @Test void servletContextIsSetOnTheApplicationContext() { new ServletContextApplicationContextInitializer(this.servletContext).initialize(this.applicationContext); - verify(this.applicationContext).setServletContext(this.servletContext); + then(this.applicationContext).should().setServletContext(this.servletContext); } @Test void applicationContextIsNotStoredInServletContextByDefault() { new ServletContextApplicationContextInitializer(this.servletContext).initialize(this.applicationContext); - verify(this.servletContext, never()).setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, - this.applicationContext); + then(this.servletContext).should(never()) + .setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.applicationContext); } @Test void applicationContextCanBeStoredInServletContext() { new ServletContextApplicationContextInitializer(this.servletContext, true).initialize(this.applicationContext); - verify(this.servletContext).setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, + then(this.servletContext).should().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.applicationContext); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java index eb4d3fa58a..1396c967c3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java @@ -57,14 +57,15 @@ import org.springframework.web.context.support.StandardServletEnvironment; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * Tests for {@link SpringBootServletInitializer}. * * @author Phillip Webb * @author Andy Wilkinson + * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class SpringBootServletInitializerTests { @@ -220,7 +221,7 @@ class SpringBootServletInitializerTests { }.onStartup(servletContext); ArgumentCaptor captor = ArgumentCaptor.forClass(ServletContextListener.class); - verify(servletContext).addListener(captor.capture()); + then(servletContext).should().addListener(captor.capture()); captor.getValue().contextDestroyed(new ServletContextEvent(servletContext)); assertThat(driversDeregistered).isTrue(); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java index 707e8e744b..b9c70aef6d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -44,16 +44,16 @@ import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link WebServiceTemplateBuilder}. * * @author Stephane Nicoll * @author Dmytro Nosan + * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class WebServiceTemplateBuilderTests { @@ -70,7 +70,7 @@ class WebServiceTemplateBuilderTests { void createWithCustomizersShouldApplyCustomizers() { WebServiceTemplateCustomizer customizer = mock(WebServiceTemplateCustomizer.class); WebServiceTemplate template = new WebServiceTemplateBuilder(customizer).build(); - verify(customizer).customize(template); + then(customizer).should().customize(template); } @Test @@ -220,14 +220,14 @@ class WebServiceTemplateBuilderTests { void customizersShouldApply() { WebServiceTemplateCustomizer customizer = mock(WebServiceTemplateCustomizer.class); WebServiceTemplate template = this.builder.customizers(customizer).build(); - verify(customizer).customize(template); + then(customizer).should().customize(template); } @Test void customizersShouldBeAppliedLast() { WebServiceTemplate template = spy(new WebServiceTemplate()); - this.builder - .additionalCustomizers(((webServiceTemplate) -> verify(webServiceTemplate).setMessageSenders(any()))); + this.builder.additionalCustomizers( + ((webServiceTemplate) -> then(webServiceTemplate).should().setMessageSenders(any()))); this.builder.configure(template); } @@ -237,8 +237,8 @@ class WebServiceTemplateBuilderTests { WebServiceTemplateCustomizer customizer2 = mock(WebServiceTemplateCustomizer.class); WebServiceTemplate template = this.builder.customizers(customizer1) .customizers(Collections.singleton(customizer2)).build(); - verifyNoInteractions(customizer1); - verify(customizer2).customize(template); + then(customizer1).shouldHaveNoInteractions(); + then(customizer2).should().customize(template); } @Test @@ -260,22 +260,22 @@ class WebServiceTemplateBuilderTests { WebServiceTemplateCustomizer customizer1 = mock(WebServiceTemplateCustomizer.class); WebServiceTemplateCustomizer customizer2 = mock(WebServiceTemplateCustomizer.class); WebServiceTemplate template = this.builder.customizers(customizer1).additionalCustomizers(customizer2).build(); - verify(customizer1).customize(template); - verify(customizer2).customize(template); + then(customizer1).should().customize(template); + then(customizer2).should().customize(template); } @Test void setCheckConnectionForFault() { WebServiceTemplate template = mock(WebServiceTemplate.class); this.builder.setCheckConnectionForFault(false).configure(template); - verify(template).setCheckConnectionForFault(false); + then(template).should().setCheckConnectionForFault(false); } @Test void setCheckConnectionForError() { WebServiceTemplate template = mock(WebServiceTemplate.class); this.builder.setCheckConnectionForError(false).configure(template); - verify(template).setCheckConnectionForError(false); + then(template).should().setCheckConnectionForError(false); } @@ -283,7 +283,7 @@ class WebServiceTemplateBuilderTests { void setTransformerFactoryClass() { WebServiceTemplate template = mock(WebServiceTemplate.class); this.builder.setTransformerFactoryClass(SAXTransformerFactory.class).configure(template); - verify(template).setTransformerFactoryClass(SAXTransformerFactory.class); + then(template).should().setTransformerFactoryClass(SAXTransformerFactory.class); } @Test diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java index 6e59ee92e4..ecc6305167 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java @@ -28,7 +28,7 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import static org.mockito.Mockito.verify; +import static org.mockito.BDDMockito.then; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -37,6 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for {@link SampleDataJpaApplication} that use {@link SpyBean @SpyBean}. * * @author Andy Wilkinson + * @author Yanming Zhou */ @SpringBootTest @AutoConfigureTestDatabase @@ -58,7 +59,7 @@ class SpyBeanSampleDataJpaApplicationTests { @Test void testHome() throws Exception { this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Bath")); - verify(this.repository).findByNameAndCountryAllIgnoringCase("Bath", "UK"); + then(this.repository).should().findByNameAndCountryAllIgnoringCase("Bath", "UK"); } } diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 8a0cf07b38..148febe43f 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -48,7 +48,7 @@ - + From 7f17f819a606d677a914210aefcaeb3ec02186de Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 1 Feb 2022 09:47:21 +0100 Subject: [PATCH 2/2] Polish "Enforce use of BDDMockito" See gh-29178 --- .../servlet/CloudFoundrySecurityInterceptorTests.java | 3 +-- .../cloudfoundry/servlet/TokenValidatorTests.java | 3 +-- .../jmx/JmxEndpointAutoConfigurationTests.java | 3 +-- .../AuditEventsEndpointDocumentationTests.java | 3 +-- .../LoggersEndpointDocumentationTests.java | 3 +-- .../SessionsEndpointDocumentationTests.java | 3 +-- .../metrics/MeterRegistryConfigurerTests.java | 3 +-- .../metrics/MetricsAutoConfigurationTests.java | 3 +-- ...MethodInvocationListenerBeanPostProcessorTests.java | 3 +-- ...JerseyChildManagementContextConfigurationTests.java | 2 +- .../JerseySameManagementContextConfigurationTests.java | 2 +- .../actuate/audit/listener/AuditListenerTests.java | 3 +-- .../boot/actuate/cache/CachesEndpointTests.java | 3 +-- .../couchbase/CouchbaseHealthIndicatorTests.java | 3 +-- .../CouchbaseReactiveHealthIndicatorTests.java | 2 +- .../ConversionServiceParameterValueMapperTests.java | 3 +-- .../cache/CachingOperationInvokerAdvisorTests.java | 3 +-- .../invoker/cache/CachingOperationInvokerTests.java | 3 +-- .../boot/actuate/endpoint/jmx/EndpointMBeanTests.java | 3 +-- .../jmx/JacksonJmxOperationResponseMapperTests.java | 3 +-- .../actuate/endpoint/jmx/JmxEndpointExporterTests.java | 3 +-- .../endpoint/web/ServletEndpointRegistrarTests.java | 3 +-- .../AbstractWebEndpointIntegrationTests.java | 3 +-- .../actuate/influx/InfluxDbHealthIndicatorTests.java | 3 +-- .../integration/IntegrationGraphEndpointTests.java | 3 +-- .../actuate/jdbc/DataSourceHealthIndicatorTests.java | 3 +-- .../boot/actuate/jms/JmsHealthIndicatorTests.java | 3 +-- .../boot/actuate/ldap/LdapHealthIndicatorTests.java | 3 +-- .../boot/actuate/logging/LoggersEndpointTests.java | 3 +-- .../logging/LoggersEndpointWebIntegrationTests.java | 3 +-- .../prometheus/PrometheusPushGatewayManagerTests.java | 3 +-- .../boot/actuate/mongo/MongoHealthIndicatorTests.java | 3 +-- .../boot/actuate/neo4j/Neo4jHealthIndicatorTests.java | 3 +-- .../neo4j/Neo4jReactiveHealthIndicatorTests.java | 3 +-- .../boot/actuate/quartz/QuartzEndpointTests.java | 3 +-- .../boot/actuate/redis/RedisHealthIndicatorTests.java | 3 +-- .../redis/RedisReactiveHealthIndicatorTests.java | 3 +-- .../security/AuthenticationAuditListenerTests.java | 2 +- .../security/AuthorizationAuditListenerTests.java | 2 +- .../boot/actuate/session/SessionsEndpointTests.java | 3 +-- .../boot/actuate/solr/SolrHealthIndicatorTests.java | 3 +-- ...edMetadataReaderFactoryContextInitializerTests.java | 3 +-- .../amqp/RabbitAutoConfigurationTests.java | 3 +-- .../batch/BatchDataSourceInitializerTests.java | 3 +-- .../cache/CacheAutoConfigurationTests.java | 6 +++--- .../CassandraAutoConfigurationIntegrationTests.java | 3 +-- .../boot/autoconfigure/domain/EntityScannerTests.java | 3 +-- .../ElasticsearchRestClientAutoConfigurationTests.java | 2 +- .../IntegrationDataSourceInitializerTests.java | 2 +- .../jooq/JooqExceptionTranslatorTests.java | 3 +-- .../boot/autoconfigure/jooq/JooqPropertiesTests.java | 3 +-- .../kafka/KafkaAutoConfigurationTests.java | 3 +-- .../mail/MailSenderAutoConfigurationTests.java | 3 +-- .../mongo/MongoClientFactorySupportTests.java | 3 +-- .../orm/jpa/HibernatePropertiesTests.java | 3 +-- .../quartz/QuartzAutoConfigurationTests.java | 2 +- .../quartz/QuartzDataSourceInitializerTests.java | 6 +++--- .../session/JdbcSessionDataSourceInitializerTests.java | 1 - .../SessionAutoConfigurationHazelcastTests.java | 3 +-- .../autoconfigure/session/SessionPropertiesTests.java | 3 +-- .../task/TaskExecutionAutoConfigurationTests.java | 3 +-- .../template/TemplateAvailabilityProvidersTests.java | 3 +-- .../validation/ValidatorAdapterTests.java | 3 +-- .../web/client/RestTemplateAutoConfigurationTests.java | 3 +-- .../embedded/JettyWebServerFactoryCustomizerTests.java | 3 +-- .../embedded/NettyWebServerFactoryCustomizerTests.java | 2 +- .../UndertowWebServerFactoryCustomizerTests.java | 3 +-- ...ReactiveWebServerFactoryAutoConfigurationTests.java | 3 +-- .../ReactiveWebServerFactoryCustomizerTests.java | 3 +-- .../web/reactive/WebFluxAutoConfigurationTests.java | 3 +-- .../ClientHttpConnectorAutoConfigurationTests.java | 3 +-- .../client/WebClientAutoConfigurationTests.java | 3 +-- .../ServletWebServerFactoryAutoConfigurationTests.java | 3 +-- .../ServletWebServerFactoryCustomizerTests.java | 3 +-- .../ServletWebServerServletContextListenerTests.java | 3 +-- .../servlet/error/DefaultErrorViewResolverTests.java | 3 +-- .../boot/cli/command/CommandRunnerTests.java | 3 +-- .../encodepassword/EncodePasswordCommandTests.java | 3 +-- .../boot/cli/command/init/InitCommandTests.java | 2 +- ...encyManagementArtifactCoordinatesResolverTests.java | 3 +-- ...tRepositorySystemSessionAutoConfigurationTests.java | 3 +-- ...stractDevToolsDataSourceAutoConfigurationTests.java | 3 +-- ...vToolsEmbeddedDataSourceAutoConfigurationTests.java | 3 +-- ...DevToolsPooledDataSourceAutoConfigurationTests.java | 3 +-- .../LocalDevToolsAutoConfigurationTests.java | 3 +-- .../autoconfigure/OptionalLiveReloadServerTests.java | 3 +-- .../classpath/ClassPathFileChangeListenerTests.java | 3 +-- .../livereload/ConnectionOutputStreamTests.java | 3 +-- .../remote/client/DelayedLiveReloadTriggerTests.java | 3 +-- .../remote/client/RemoteClientConfigurationTests.java | 3 +-- .../devtools/remote/server/DispatcherFilterTests.java | 2 +- .../boot/devtools/remote/server/DispatcherTests.java | 3 +-- .../ClassLoaderFilesResourcePatternResolverTests.java | 3 +-- .../boot/devtools/restart/RestarterTests.java | 3 +-- .../restart/server/HttpRestartServerHandlerTests.java | 3 +-- .../restart/server/HttpRestartServerTests.java | 3 +-- .../tunnel/client/HttpTunnelConnectionTests.java | 3 +-- .../tunnel/server/HttpTunnelServerHandlerTests.java | 3 +-- .../devtools/tunnel/server/HttpTunnelServerTests.java | 1 - .../autoconfigure/orm/jpa/TestEntityManagerTests.java | 2 +- .../PropertyMappingContextCustomizerFactoryTests.java | 3 +-- .../reactive/WebTestClientAutoConfigurationTests.java | 3 +-- .../web/servlet/MockMvcAutoConfigurationTests.java | 5 +---- .../assertj/ApplicationContextAssertProviderTests.java | 3 +-- .../InheritedNestedTestConfigurationTests.java | 3 +-- ...ldForExistingBeanWithQualifierIntegrationTests.java | 3 +-- .../test/mock/mockito/MockBeanWithAopProxyTests.java | 2 +- .../mockito/MockitoTestExecutionListenerTests.java | 3 +-- .../test/mock/mockito/QualifierDefinitionTests.java | 3 +-- ...figurationClassForExistingBeanIntegrationTests.java | 3 +-- ...OnConfigurationClassForNewBeanIntegrationTests.java | 3 +-- ...figurationFieldForExistingBeanIntegrationTests.java | 3 +-- ...OnConfigurationFieldForNewBeanIntegrationTests.java | 3 +-- ...BeanOnTestClassForExistingBeanIntegrationTests.java | 3 +-- .../SpyBeanOnTestClassForNewBeanIntegrationTests.java | 3 +-- ...nTestFieldForExistingBeanCacheIntegrationTests.java | 3 +-- ...BeanOnTestFieldForExistingBeanIntegrationTests.java | 3 +-- ...ldForExistingBeanWithQualifierIntegrationTests.java | 3 +-- ...estFieldForExistingGenericBeanIntegrationTests.java | 3 +-- ...pleExistingBeansWithOnePrimaryIntegrationTests.java | 3 +-- .../SpyBeanOnTestFieldForNewBeanIntegrationTests.java | 3 +-- ...SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java | 3 +-- .../test/mock/mockito/SpyBeanWithAopProxyTests.java | 3 +-- ...esContextClassModeBeforeMethodIntegrationTests.java | 3 +-- .../test/mock/mockito/SpyBeanWithJdkProxyTests.java | 3 +-- .../test/util/ApplicationContextTestUtilsTests.java | 3 +-- .../web/client/LocalHostUriTemplateHandlerTests.java | 3 +-- .../client/RootUriRequestExpectationManagerTests.java | 3 +-- .../boot/test/web/client/TestRestTemplateTests.java | 3 +-- .../test/web/htmlunit/LocalHostWebClientTests.java | 3 +-- .../LocalHostWebConnectionHtmlUnitDriverTests.java | 9 +++++---- ...WebTestClientContextCustomizerIntegrationTests.java | 3 +-- .../boot/buildpack/platform/build/BuilderTests.java | 3 +-- .../boot/buildpack/platform/build/LifecycleTests.java | 2 +- .../boot/buildpack/platform/build/PhaseTests.java | 2 +- .../boot/buildpack/platform/docker/DockerApiTests.java | 2 +- .../docker/transport/HttpClientTransportTests.java | 3 +-- .../springframework/boot/loader/jar/JarFileTests.java | 3 +-- .../boot/maven/ArtifactsLibrariesTests.java | 3 +-- .../java/org/springframework/boot/BannerTests.java | 3 +-- .../boot/DefaultPropertiesPropertySourceTests.java | 3 +-- .../springframework/boot/SpringApplicationTests.java | 2 +- .../boot/SpringBootExceptionHandlerTests.java | 3 +-- .../springframework/boot/StartupInfoLoggerTests.java | 3 +-- .../availability/AvailabilityChangeEventTests.java | 3 +-- .../boot/builder/SpringApplicationBuilderTests.java | 3 +-- .../config/ConfigDataEnvironmentContributorsTests.java | 1 - .../ConfigDataEnvironmentPostProcessorTests.java | 8 +++----- .../InvalidConfigDataPropertyExceptionTests.java | 3 +-- .../properties/ConfigurationPropertiesTests.java | 3 +-- .../EnableConfigurationPropertiesRegistrarTests.java | 3 +-- .../context/properties/bind/BindConverterTests.java | 3 +-- .../boot/context/properties/bind/BindResultTests.java | 3 +-- .../bind/BoundPropertiesTrackingBindHandlerTests.java | 3 +-- .../ConfigurationPropertySourcesCachingTests.java | 3 +-- .../convert/ApplicationConversionServiceTests.java | 3 +-- .../boot/diagnostics/FailureAnalyzersTests.java | 3 +-- ...vironmentPostProcessorApplicationListenerTests.java | 3 +-- .../boot/jdbc/DataSourceUnwrapperTests.java | 3 +-- .../boot/json/JacksonJsonParserTests.java | 3 +-- .../atomikos/AtomikosConnectionFactoryBeanTests.java | 10 +++++----- .../boot/jta/atomikos/AtomikosDataSourceBeanTests.java | 10 +++++----- .../springframework/boot/logging/DeferredLogTests.java | 3 +-- .../boot/logging/DeferredLogsTests.java | 3 +-- .../logging/DelegatingLoggingSystemFactoryTests.java | 3 +-- .../boot/logging/log4j2/Log4J2LoggingSystemTests.java | 3 +-- .../logging/logback/LogbackLoggingSystemTests.java | 3 +-- .../boot/logging/logback/SpringProfileActionTests.java | 3 +-- .../boot/origin/OriginTrackedResourceTests.java | 3 +-- ...cketPortInfoApplicationContextInitializerTests.java | 3 +-- ...atabaseInitializationDependencyConfigurerTests.java | 3 +-- .../boot/task/TaskExecutorBuilderTests.java | 3 +-- .../boot/task/TaskSchedulerBuilderTests.java | 3 +-- ...rentReferenceCachingMetadataReaderFactoryTests.java | 3 +-- .../org/springframework/boot/util/LambdaSafeTests.java | 3 +-- .../boot/web/client/RestTemplateBuilderTests.java | 3 +-- .../boot/web/client/RootUriTemplateHandlerTests.java | 3 +-- .../tomcat/TomcatReactiveWebServerFactoryTests.java | 3 +-- .../tomcat/TomcatServletWebServerFactoryTests.java | 3 +-- .../ReactiveWebServerApplicationContextTests.java | 3 +-- .../servlet/AbstractFilterRegistrationBeanTests.java | 3 +-- .../boot/web/servlet/FilterRegistrationBeanTests.java | 3 +-- .../servlet/ServletListenerRegistrationBeanTests.java | 3 +-- .../boot/web/servlet/ServletRegistrationBeanTests.java | 3 +-- ...nConfigServletWebServerApplicationContextTests.java | 3 +-- .../ServletWebServerApplicationContextTests.java | 3 +-- .../XmlServletWebServerApplicationContextTests.java | 3 +-- .../server/AbstractServletWebServerFactoryTests.java | 3 +-- .../boot/web/servlet/support/ErrorPageFilterTests.java | 3 +-- ...rvletContextApplicationContextInitializerTests.java | 3 +-- .../support/SpringBootServletInitializerTests.java | 3 +-- .../client/WebServiceTemplateBuilderTests.java | 3 +-- .../data/jpa/SpyBeanSampleDataJpaApplicationTests.java | 3 +-- 193 files changed, 208 insertions(+), 381 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java index 4278a7a5f3..b1b3e4e981 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link CloudFoundrySecurityInterceptor}. * * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CloudFoundrySecurityInterceptorTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java index 2603afeb05..cf469ce897 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/TokenValidatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -52,7 +52,6 @@ import static org.mockito.Mockito.never; * Tests for {@link TokenValidator}. * * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class TokenValidatorTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java index 4a7c4faed6..eedf2db398 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link JmxEndpointAutoConfiguration}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class JmxEndpointAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java index f507c4207a..d5c18d1735 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AuditEventsEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing {@link AuditEventsEndpoint}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class AuditEventsEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java index aac18dd585..ff01109eb1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -52,7 +52,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing the {@link LoggersEndpoint}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java index e21697c5ea..d2282f986d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SessionsEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -52,7 +52,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for generating documentation describing the {@link ShutdownEndpoint}. * * @author Andy Wilkinson - * @author Yanming Zhou */ @TestPropertySource(properties = "spring.jackson.serialization.write-dates-as-timestamps=false") class SessionsEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java index 5b65c4c068..b7fbc5eaca 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -44,7 +44,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class MeterRegistryConfigurerTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java index aa545f71fd..fd8f773084 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link MetricsAutoConfiguration}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class MetricsAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java index 8f42b64fd8..2077bfeefa 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -33,7 +33,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link MetricsRepositoryMethodInvocationListenerBeanPostProcessor} . * * @author Phillip Webb - * @author Yanming Zhou */ class MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java index a03fd05abe..cca272741d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseyChildManagementContextConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java index 9af16cba82..e8c8120d35 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/jersey/JerseySameManagementContextConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java index dc9e92b0c4..6984a24a8a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/listener/AuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link AuditListener}. * * @author Phillip Webb - * @author Yanming Zhou */ class AuditListenerTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java index 34c2713e94..bbbd0e5b42 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.never; * Tests for {@link CachesEndpoint}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class CachesEndpointTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java index d5235b0ad7..e3345aa878 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.mock; * * @author Eddú Meléndez * @author Stephane Nicoll - * @author Yanming Zhou */ class CouchbaseHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java index 50b164c6d9..adc00a8751 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java index 8660e244dd..c2edffcee8 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.Mockito.spy; * Tests for {@link ConversionServiceParameterValueMapper}. * * @author Phillip Webb - * @author Yanming Zhou */ class ConversionServiceParameterValueMapperTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java index 3471b9e7c4..1d468ebbbe 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.BDDMockito.then; * * @author Phillip Webb * @author Stephane Nicoll - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CachingOperationInvokerAdvisorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java index bbd72290fb..77549d0368 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -47,7 +47,6 @@ import static org.mockito.Mockito.times; * @author Stephane Nicoll * @author Christoph Dreis * @author Phillip Webb - * @author Yanming Zhou */ class CachingOperationInvokerTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java index 170d622168..bcebfa49a3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.spy; * * @author Phillip Webb * @author Stephane Nicoll - * @author Yanming Zhou */ class EndpointMBeanTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java index 6a22c4f78f..2b3b7273f7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.spy; * Tests for {@link JacksonJmxOperationResponseMapper} * * @author Phillip Webb - * @author Yanming Zhou */ class JacksonJmxOperationResponseMapperTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java index 9e35ac8ca2..b4765c6882 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -51,7 +51,6 @@ import static org.mockito.BDDMockito.willThrow; * * @author Stephane Nicoll * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class JmxEndpointExporterTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java index 9deff8ac3a..cbbc52befe 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Stephane Nicoll - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletEndpointRegistrarTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index bedb03b83c..0f5851073a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -62,7 +62,6 @@ import static org.mockito.BDDMockito.then; * @param the type of application context used by the tests * @author Andy Wilkinson * @author Scott Frederick - * @author Yanming Zhou */ public abstract class AbstractWebEndpointIntegrationTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java index 508d3b7b37..b991ceb5e0 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link InfluxDbHealthIndicator}. * * @author Eddú Meléndez - * @author Yanming Zhou */ class InfluxDbHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java index a389b2bb79..c832b2d054 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link IntegrationGraphEndpoint}. * * @author Tim Ysewyn - * @author Yanming Zhou */ class IntegrationGraphEndpointTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java index 2161c1211e..df69e11813 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.times; * * @author Dave Syer * @author Stephane Nicoll - * @author Yanming Zhou */ class DataSourceHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java index e04a751b06..151dc70778 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jms/JmsHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link JmsHealthIndicator}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class JmsHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java index be55705fe7..9af6b7950a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ldap/LdapHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link LdapHealthIndicator} * * @author Eddú Meléndez - * @author Yanming Zhou */ class LdapHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java index 4ac9d7c94f..5c7515e3b2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock; * @author Andy Wilkinson * @author HaiTao Zhang * @author Madhura Bhave - * @author Yanming Zhou */ class LoggersEndpointTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java index 6ae41c744f..254df61e22 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -57,7 +57,6 @@ import static org.mockito.Mockito.mock; * @author Andy Wilkinson * @author HaiTao Zhang * @author Madhura Bhave - * @author Yanming Zhou */ class LoggersEndpointWebIntegrationTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java index 2d42eaeab3..7bb3ceef2f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.never; * Tests for {@link PrometheusPushGatewayManager}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class PrometheusPushGatewayManagerTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java index a976b693c2..0ad1de2b2c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -33,7 +33,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link MongoHealthIndicator}. * * @author Christian Dupuis - * @author Yanming Zhou */ class MongoHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java index a44a5ff5ba..1291f710aa 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.times; * @author Eric Spiegelberg * @author Stephane Nicoll * @author Michael Simons - * @author Yanming Zhou */ class Neo4jHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java index 33ba91fd95..8c66165f12 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.times; * * @author Michael J. Simons * @author Stephane Nicoll - * @author Yanming Zhou */ class Neo4jReactiveHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java index 1a7b4a2b93..2d51fca356 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/quartz/QuartzEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -83,7 +83,6 @@ import static org.mockito.Mockito.mock; * * @author Vedran Pavic * @author Stephane Nicoll - * @author Yanming Zhou */ class QuartzEndpointTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java index 1ffaee209d..564f68e070 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * @author Christian Dupuis * @author Richard Santana * @author Stephane Nicoll - * @author Yanming Zhou */ class RedisHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java index 913f8e8604..f45b25eb92 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock; * @author Nikolay Rybak * @author Artsiom Yudovin * @author Scott Frederick - * @author Yanming Zhou */ class RedisReactiveHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java index 17b0c69697..77f973c656 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java index a979fd2fe9..cbda5c70b1 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthorizationAuditListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java index 95e983b410..5095187a56 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/session/SessionsEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link SessionsEndpoint}. * * @author Vedran Pavic - * @author Yanming Zhou */ class SessionsEndpointTests { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java index ef5f8c1512..31223253ac 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.times; * @author Andy Wilkinson * @author Markus Schuch * @author Phillip Webb - * @author Yanming Zhou */ class SolrHealthIndicatorTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java index 289ec6c092..ba4f4aa661 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -47,7 +47,6 @@ import static org.mockito.Mockito.mock; * * @author Dave Syer * @author Phillip Webb - * @author Yanming Zhou */ class SharedMetadataReaderFactoryContextInitializerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index fc6a1cff6e..c4d17faa72 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -90,7 +90,6 @@ import static org.mockito.Mockito.mock; * @author Gary Russell * @author HaiTao Zhang * @author Franjo Zilic - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class RabbitAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java index 6e7f8081f9..dbb8ff5019 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link BatchDataSourceInitializer}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class BatchDataSourceInitializerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java index 25e96b44b8..a7740adcb1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -74,9 +74,9 @@ import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; /** * Tests for {@link CacheAutoConfiguration}. @@ -573,7 +573,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests { .run((context) -> { assertThat(getCacheManager(context, SpringEmbeddedCacheManager.class).getCacheNames()) .containsOnly("foo", "bar"); - verify(context.getBean(ConfigurationBuilder.class), times(2)).build(); + then(context.getBean(ConfigurationBuilder.class)).should(times(2)).build(); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java index 7a707129c6..2f4aa175f3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.Mockito.spy; * Integration tests for {@link CassandraAutoConfiguration}. * * @author Andy Wilkinson - * @author Yanming Zhou */ @Testcontainers(disabledWithoutDocker = true) class CassandraAutoConfigurationIntegrationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java index 4347dbd0de..2ea5904677 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link EntityScanner}. * * @author Phillip Webb - * @author Yanming Zhou */ class EntityScannerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java index 43e20819eb..eaf8a5edda 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java index 874b2576c5..fff4b1e695 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java index 05abebf7db..f0dae1359e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.never; * Tests for {@link JooqExceptionTranslator} * * @author Andy Wilkinson - * @author Yanming Zhou */ class JooqExceptionTranslatorTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java index c7e44cd3e6..88263b4bb3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.Mockito.never; * Tests for {@link JooqProperties}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class JooqPropertiesTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index 3b88eee9c1..c2446cf6fe 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -86,7 +86,6 @@ import static org.mockito.Mockito.never; * @author Stephane Nicoll * @author Eddú Meléndez * @author Nakul Mishra - * @author Yanming Zhou */ class KafkaAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java index a1dcd6d29a..3b4089357d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.never; * * @author Stephane Nicoll * @author Eddú Meléndez - * @author Yanming Zhou */ class MailSenderAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java index 84a9232a3a..1829ec803c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactorySupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * @author Mark Paluch * @author Artsiom Yudovin * @author Scott Frederick - * @author Yanming Zhou */ abstract class MongoClientFactorySupportTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java index de2f2741e5..f98a1e41fb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.never; * @author Stephane Nicoll * @author Artsiom Yudovin * @author Chris Bono - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HibernatePropertiesTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java index 5fdedbfbdb..d54f769ec9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java index ff52f46905..2fb2eca62a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,8 +35,8 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link QuartzDataSourceInitializer}. @@ -59,7 +59,7 @@ class QuartzDataSourceInitializerTests { QuartzDataSourceInitializer initializer = new QuartzDataSourceInitializer(dataSource, new DefaultResourceLoader(), properties); assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); + then(dataSource).shouldHaveNoInteractions(); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java index 4099cd3396..5d6cf3865c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link JdbcSessionDataSourceInitializer}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class JdbcSessionDataSourceInitializerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java index b3c7ce676f..857a04505a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * Hazelcast specific tests for {@link SessionAutoConfiguration}. * * @author Vedran Pavic - * @author Yanming Zhou */ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java index 8f9124946a..4dc24f60aa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link SessionProperties}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class SessionPropertiesTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java index 648e811bde..5b1c97250b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -51,7 +51,6 @@ import static org.mockito.Mockito.mock; * * @author Stephane Nicoll * @author Camille Vienot - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class TaskExecutionAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java index 17beff24d7..903e04463f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.Mockito.times; * Tests for {@link TemplateAvailabilityProviders}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class TemplateAvailabilityProvidersTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java index 0804cbc291..f11535abfe 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidatorAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.never; * * @author Stephane Nicoll * @author Madhura Bhave - * @author Yanming Zhou */ class ValidatorAdapterTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java index 381479cac9..72b592b971 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -52,7 +52,6 @@ import static org.mockito.Mockito.mock; * * @author Stephane Nicoll * @author Phillip Webb - * @author Yaming Zhou */ class RestTemplateAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java index 2728a5a3f6..db30924210 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -63,7 +63,6 @@ import static org.mockito.Mockito.mock; * @author Brian Clozel * @author Phillip Webb * @author HaiTao Zhang - * @author Yanming Zhou */ class JettyWebServerFactoryCustomizerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java index 91e14df400..960acbeba7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java index 08882af77b..7b544fb3e6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -53,7 +53,6 @@ import static org.mockito.Mockito.mock; * @author Artsiom Yudovin * @author Rafiullah Hamedy * @author HaiTao Zhang - * @author Yanming Zhou */ class UndertowWebServerFactoryCustomizerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java index 8cbc42be71..4b549494d6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -62,7 +62,6 @@ import static org.mockito.Mockito.mock; * @author Brian Clozel * @author Raheela Aslam * @author Madhura Bhave - * @author Yanming Zhou */ class ReactiveWebServerFactoryAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java index 68e7a5d801..63a7344911 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.mock; * * @author Brian Clozel * @author Yunkun Huang - * @author Yanming Zhou */ class ReactiveWebServerFactoryCustomizerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index 8499883a0c..56dfbd022c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -101,7 +101,6 @@ import static org.mockito.Mockito.mock; * @author Brian Clozel * @author Andy Wilkinson * @author Artsiom Yudovin - * @author Yanming Zhou */ class WebFluxAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java index bc89ad0a9b..e329138a31 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link ClientHttpConnectorAutoConfiguration} * * @author Brian Clozel - * @author Yanming Zhou */ class ClientHttpConnectorAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java index 6e5c7adc52..9059dd3b06 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.times; * Tests for {@link WebClientAutoConfiguration} * * @author Brian Clozel - * @author Yanming Zhou */ class WebClientAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java index 442477a056..0338bcdd16 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -74,7 +74,6 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @author Raheela Aslam * @author Madhura Bhave - * @author Yanming Zhou */ class ServletWebServerFactoryAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java index 3ae32e93dd..c11cd14cb1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.mock; * * @author Brian Clozel * @author Yunkun Huang - * @author Yanming Zhou */ class ServletWebServerFactoryCustomizerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java index 625f32f806..f462da8cc8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerServletContextListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link WebServer}s driving {@link ServletContextListener}s correctly * * @author Andy Wilkinson - * @author Yanming Zhou */ class ServletWebServerServletContextListenerTests { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java index 8d37f3c0b6..a22d7707dd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/DefaultErrorViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -55,7 +55,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DefaultErrorViewResolverTests { diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java index 2b86c2c11e..462cd0c2cf 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.Mockito.lenient; * * @author Phillip Webb * @author Dave Syer - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class CommandRunnerTests { diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java index c247e7eb95..2980ae3b08 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -37,7 +37,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link EncodePasswordCommand}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class EncodePasswordCommandTests { diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java index 8fb9800be6..18edf49190 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java index ae817deff5..abe2756b4d 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -31,7 +31,6 @@ import static org.mockito.Mockito.never; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ class DependencyManagementArtifactCoordinatesResolverTests { diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java index 1743e7f6cf..001c79e642 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/GrapeRootRepositorySystemSessionAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.never; * Tests for {@link GrapeRootRepositorySystemSessionAutoConfiguration} * * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class GrapeRootRepositorySystemSessionAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java index 8141f4668d..432298e17e 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/AbstractDevToolsDataSourceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.spy; * Base class for tests for {@link DevToolsDataSourceAutoConfiguration}. * * @author Andy Wilkinson - * @author Yanming Zhou */ abstract class AbstractDevToolsDataSourceAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java index 9c56694d03..dbd1d2030f 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.Mockito.never; * Tests for {@link DevToolsDataSourceAutoConfiguration} with an embedded data source. * * @author Andy Wilkinson - * @author Yanming Zhou */ @ClassPathExclusions("HikariCP-*.jar") class DevToolsEmbeddedDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java index d6cfa4145b..0db015da50 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.never; * Tests for {@link DevToolsDataSourceAutoConfiguration} with a pooled data source. * * @author Andy Wilkinson - * @author Yanming Zhou */ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java index a63bbdc213..1017c2f490 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -70,7 +70,6 @@ import static org.mockito.Mockito.reset; * @author Phillip Webb * @author Andy Wilkinson * @author Vladimir Tsanev - * @author Yanming Zhou */ @ExtendWith(MockRestarter.class) class LocalDevToolsAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java index 553effb50e..dfae3b454e 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.never; * Tests for {@link OptionalLiveReloadServer}. * * @author Phillip Webb - * @author Yanming Zhou */ class OptionalLiveReloadServerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java index 1b56a237ce..10d24c88ea 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -44,7 +44,6 @@ import static org.mockito.Mockito.never; * Tests for {@link ClassPathFileChangeListener}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ClassPathFileChangeListenerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java index 87254e7720..ec80f8c64d 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/ConnectionOutputStreamTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link ConnectionOutputStream}. * * @author Phillip Webb - * @author Yanming Zhou */ @SuppressWarnings("resource") class ConnectionOutputStreamTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java index f6df319665..5845181f60 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/DelayedLiveReloadTriggerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.never; * Tests for {@link DelayedLiveReloadTrigger}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DelayedLiveReloadTriggerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java index 81e9b78fd1..824f5e911e 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -59,7 +59,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link RemoteClientConfiguration}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockRestarter.class }) class RemoteClientConfigurationTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java index c6b162a555..5f24095117 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java index 063bd426ba..43b883149b 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/DispatcherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -47,7 +47,6 @@ import static org.mockito.Mockito.withSettings; * Tests for {@link Dispatcher}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DispatcherTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java index 70b618fdaf..6dff93e440 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -50,7 +50,6 @@ import static org.mockito.Mockito.mock; * @author Phillip Webb * @author Andy Wilkinson * @author Stephane Nicoll - * @author Yanming Zhou */ class ClassLoaderFilesResourcePatternResolverTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java index dbef473663..456b9539c2 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -57,7 +57,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class RestarterTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java index a4d623fda2..25c6c7cb4c 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link HttpRestartServerHandler}. * * @author Phillip Webb - * @author Yanming Zhou */ class HttpRestartServerHandlerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java index d931cb8192..7c70e4c11f 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/HttpRestartServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -44,7 +44,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link HttpRestartServer}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpRestartServerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java index 49792448a8..717e778a43 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.never; * @author Phillip Webb * @author Rob Winch * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class }) class HttpTunnelConnectionTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java index c281643cdf..50f8907fa8 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link HttpTunnelServerHandler}. * * @author Phillip Webb - * @author Yanming Zhou */ class HttpTunnelServerHandlerTests { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java index d3019f1606..2f1304e3f6 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java @@ -58,7 +58,6 @@ import static org.mockito.Mockito.never; * Tests for {@link HttpTunnelServer}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpTunnelServerTests { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java index 294c99557f..ed06824cbe 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java index 463193855f..535d8f6f99 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link PropertyMappingContextCustomizerFactory}. * * @author Phillip Webb - * @author Yanming Zhou */ class PropertyMappingContextCustomizerFactoryTests { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java index 5f200d3c7c..df78ddd033 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -46,7 +46,6 @@ import static org.mockito.Mockito.mock; * * @author Brian Clozel * @author Stephane Nicoll - * @author Yanming Zhou */ class WebTestClientAutoConfigurationTests { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java index f31713e430..eeaa6592c6 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,9 +24,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.web.servlet.DispatcherServlet; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; /** * Tests for {@link MockMvcAutoConfiguration}. diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java index 8d0f51f972..b77726ec5f 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.BDDMockito.then; * {@link AssertProviderApplicationContextInvocationHandler}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ApplicationContextAssertProviderTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java index 940e456396..c898c6cbfd 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/nestedtests/InheritedNestedTestConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.times; * enclosing class (the default behaviour). * * @author Andy Wilkinson - * @author Yanming Zhou */ @SpringBootTest(classes = AppConfiguration.class) @Import(ActionPerformer.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java index 97bc12ddbe..30a54cab0e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.BDDMockito.then; * * @author Stephane Nicoll * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java index a88cbdc2b2..32c9577625 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanWithAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java index 66d9ecbe1d..05d8ed51fa 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link MockitoTestExecutionListener}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class MockitoTestExecutionListenerTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java index 7d9fdd3ed5..53272bd00b 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/QualifierDefinitionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link QualifierDefinition}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class QualifierDefinitionTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java index a8cb09c6d3..e39877a322 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.BDDMockito.then; * beans. * * @author Phillip Webb - * @author Yanming ZHou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java index 8e41b68a15..3bccd8ead1 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationClassForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.BDDMockito.then; * instances. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationClassForNewBeanIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java index 79b1984125..3b8a2163b1 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.BDDMockito.then; * to replace existing beans. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java index 23fd2a6169..447022fc65 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnConfigurationFieldForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.BDDMockito.then; * to inject new spy instances. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java index 0b71decbac..d35570810b 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -33,7 +33,6 @@ import static org.mockito.BDDMockito.then; * Test {@link SpyBean @SpyBean} on a test class can be used to replace existing beans. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @SpyBean(SimpleExampleService.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java index a467a8deb1..ddc2fed148 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestClassForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -33,7 +33,6 @@ import static org.mockito.BDDMockito.then; * Test {@link SpyBean @SpyBean} on a test class can be used to inject new spy instances. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @SpyBean(SimpleExampleService.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java index 4de3793bca..45cd5879ba 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.BDDMockito.then; * application context caching. * * @author Phillip Webb - * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanIntegrationTests */ @ExtendWith(SpringExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java index 5c8f718d1f..0043abd197 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -33,7 +33,6 @@ import static org.mockito.BDDMockito.then; * beans. * * @author Phillip Webb - * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests */ @ExtendWith(SpringExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java index a9b56ce267..a758fdb8c3 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.BDDMockito.then; * bean while preserving qualifiers. * * @author Andreas Neiser - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java index 197254514c..d3034b61c8 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -37,7 +37,6 @@ import static org.mockito.BDDMockito.then; * beans. * * @author Phillip Webb - * @author Yanming Zhou * @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests */ @ExtendWith(SpringExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java index 2c8b3b362c..6751f49f0c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -37,7 +37,6 @@ import static org.mockito.BDDMockito.then; * instance when there are multiple candidates and one is primary. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java index 872abba16c..2cf35176d8 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanOnTestFieldForNewBeanIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.BDDMockito.then; * instances. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanOnTestFieldForNewBeanIntegrationTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java index 6440e5e53e..38b5439a39 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyAndNotProxyTargetAwareTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.reset; * Test {@link SpyBean @SpyBean} when mixed with Spring AOP. * * @author Phillip Webb - * @author Yanming Zhou * @see 5837 */ @ExtendWith(SpringExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java index e773997513..2c0fd0e2a8 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.BDDMockito.then; * Test {@link SpyBean @SpyBean} when mixed with Spring AOP. * * @author Phillip Webb - * @author Yanming Zhou * @see 5837 */ @ExtendWith(SpringExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java index ecb71dfe3e..875deecc1e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.BDDMockito.then; * {@link DirtiesContext @DirtiesContext} and {@link ClassMode#BEFORE_EACH_TEST_METHOD}. * * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java index be4a007dc6..002ca14dec 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link SpyBean @SpyBean} with a JDK proxy. * * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(SpringExtension.class) class SpyBeanWithJdkProxyTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java index a9f110b0ce..13aaaf2cec 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/util/ApplicationContextTestUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link ApplicationContextTestUtils}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class ApplicationContextTestUtilsTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java index e0ff595c31..85d0e57b84 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -37,7 +37,6 @@ import static org.mockito.Mockito.mock; * @author Phillip Webb * @author Andy Wilkinson * @author Eddú Meléndez - * @author Yanming Zhou */ class LocalHostUriTemplateHandlerTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java index 26b2740beb..2fd99419ca 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -49,7 +49,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * Tests for {@link RootUriRequestExpectationManager}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RootUriRequestExpectationManagerTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 630bde66cb..4215136214 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -67,7 +67,6 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @author Andy Wilkinson * @author Kristine Jetzke - * @author Yanming Zhou */ class TestRestTemplateTests { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java index b000787bcd..46c461341a 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/LocalHostWebClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link LocalHostWebClient}. * * @author Phillip Webb - * @author Yanming Zhou */ @SuppressWarnings("resource") @ExtendWith(MockitoExtension.class) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java index 933e9718f8..5be09f5b69 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/htmlunit/webdriver/LocalHostWebConnectionHtmlUnitDriverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link LocalHostWebConnectionHtmlUnitDriver}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class LocalHostWebConnectionHtmlUnitDriverTests { @@ -92,7 +91,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests { MockEnvironment environment = new MockEnvironment(); LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment); driver.get("/test"); - then(this.webClient).should().getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8080/test"))); + then(this.webClient).should().getPage(any(WebWindow.class), + requestToUrl(new URL("http://localhost:8080/test"))); } @Test @@ -101,7 +101,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests { environment.setProperty("local.server.port", "8181"); LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment); driver.get("/test"); - then(this.webClient).should().getPage(any(WebWindow.class), requestToUrl(new URL("http://localhost:8181/test"))); + then(this.webClient).should().getPage(any(WebWindow.class), + requestToUrl(new URL("http://localhost:8181/test"))); } private WebRequest requestToUrl(URL url) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java index 34af6e8dbb..ee02eaff23 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * Integration test for {@link WebTestClientContextCustomizer}. * * @author Phillip Webb - * @author Yanming Zhou */ @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=reactive") @DirtiesContext diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java index dc5b68e353..fe1b5f0804 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -57,7 +57,6 @@ import static org.mockito.Mockito.times; * * @author Phillip Webb * @author Scott Frederick - * @author Rafael Ceccone */ class BuilderTests { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java index 430536e3f6..e239e0226b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java index 87f89faaf0..6f1b0c5af9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PhaseTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java index 8ac72bdc10..519bab6e52 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java index 7ce4bffe05..397aa5194c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -58,7 +58,6 @@ import static org.mockito.BDDMockito.then; * @author Phillip Webb * @author Mike Smithson * @author Scott Frederick - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class HttpClientTransportTests { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index ce3b9917aa..4363d5abc5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -74,7 +74,6 @@ import static org.mockito.Mockito.spy; * @author Martin Lau * @author Andy Wilkinson * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(JarUrlProtocolHandler.class) class JarFileTests { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java index 0f72578ac4..1e4eceed03 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -50,7 +50,6 @@ import static org.mockito.Mockito.times; * Tests for {@link ArtifactsLibraries}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ArtifactsLibrariesTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java index 74a0edb6ba..4c39c3f8da 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.reset; * @author Phillip Webb * @author Michael Stummvoll * @author Michael Simons - * @author Yanming Zhou */ @ExtendWith({ MockitoExtension.class, OutputCaptureExtension.class }) class BannerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java index d50a21bc3a..aac03ef012 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/DefaultPropertiesPropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.BDDMockito.then; * * @author Phillip Webb * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class DefaultPropertiesPropertySourceTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 3be1f7ceff..dbbafe189e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java index adac04d96c..836809c1d6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringBootExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.Mockito.mock; * * @author Henri Tremblay * @author Andy Wilkinson - * @author Yanming Zhou */ class SpringBootExceptionHandlerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java index 9fde84fbf9..70b69b0854 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/StartupInfoLoggerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.mock; * * @author Dave Syer * @author Andy Wilkinson - * @author Yanming Zhou */ class StartupInfoLoggerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java index c370c236db..f1527bfcbe 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/availability/AvailabilityChangeEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link AvailabilityChangeEvent}. * * @author Phillip Webb - * @author Yanming Zhou */ class AvailabilityChangeEventTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java index dacd712cff..352c39be07 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.Mockito.spy; * Tests for {@link SpringApplicationBuilder}. * * @author Dave Syer - * @author Yanming Zhou */ class SpringApplicationBuilderTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java index f07becdc72..53fabcdacc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java @@ -55,7 +55,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ConfigDataEnvironmentContributorsTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java index 7b79b13758..86fe16ddd3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willReturn; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link ConfigDataEnvironmentPostProcessor}. @@ -49,7 +48,6 @@ import static org.mockito.Mockito.verifyNoInteractions; * @author Phillip Webb * @author Madhura Bhave * @author Nguyen Bao Sach - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ConfigDataEnvironmentPostProcessorTests { @@ -125,7 +123,7 @@ class ConfigDataEnvironmentPostProcessorTests { .getConfigDataEnvironment(any(), any(), any()); willReturn(legacyListener).given(this.postProcessor).getLegacyListener(); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verifyNoInteractions(this.configDataEnvironment); + then(this.configDataEnvironment).shouldHaveNoInteractions(); then(legacyListener).should().addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); assertThat(this.environment.getActiveProfiles()).isEmpty(); } @@ -139,7 +137,7 @@ class ConfigDataEnvironmentPostProcessorTests { .getConfigDataEnvironment(any(), any(), any()); willReturn(legacyListener).given(this.postProcessor).getLegacyListener(); this.postProcessor.postProcessEnvironment(this.environment, this.application); - verifyNoInteractions(this.configDataEnvironment); + then(this.configDataEnvironment).shouldHaveNoInteractions(); then(legacyListener).should().addPropertySources(eq(this.environment), any(DefaultResourceLoader.class)); assertThat(this.environment.getActiveProfiles()).containsExactly("dev"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java index 17c22da3c0..8612104b02 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/InvalidConfigDataPropertyExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Madhura Bhave - * @author Yanming Zhou */ class InvalidConfigDataPropertyExceptionTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index 2ff92dc927..b97fb459e6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -120,7 +120,6 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @author Madhura Bhave * @author Vladislav Kisel - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class ConfigurationPropertiesTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java index c5fe03b0a8..a6595f5022 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.spy; * * @author Madhura Bhave * @author Stephane Nicoll - * @author Yanming Zhou */ class EnableConfigurationPropertiesRegistrarTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java index 81ca3e72a4..7ee4fb899a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -48,7 +48,6 @@ import static org.mockito.BDDMockito.then; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BindConverterTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java index 67f58045bb..3e744ad15a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.BDDMockito.then; * * @author Phillip Webb * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BindResultTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java index b741a2c83e..93116d2af3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BoundPropertiesTrackingBindHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,7 +38,6 @@ import static org.mockito.Mockito.never; * Tests for {@link BoundPropertiesTrackingBindHandler}. * * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class BoundPropertiesTrackingBindHandlerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java index 6da2daaaa6..1e747e4e0e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesCachingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -32,7 +32,6 @@ import static org.mockito.Mockito.withSettings; * Tests for {@link ConfigurationPropertySourcesCaching}. * * @author Phillip Webb - * @author Yanming Zhou */ class ConfigurationPropertySourcesCachingTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java index 4644fd1eb7..5fe5d23261 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/ApplicationConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link ApplicationConversionService}. * * @author Phillip Webb - * @author Yanming Zhou */ class ApplicationConversionServiceTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java index a82633ed1f..8fae3980fd 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -39,7 +39,6 @@ import static org.mockito.Mockito.times; * * @author Andy Wilkinson * @author Stephane Nicoll - * @author Yanming Zhou */ class FailureAnalyzersTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java index 7ccbfc1b07..cd17935818 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/EnvironmentPostProcessorApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.Mockito.spy; * Tests for {@link EnvironmentPostProcessorApplicationListener}. * * @author Phillip Webb - * @author Yanming Zhou */ class EnvironmentPostProcessorApplicationListenerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java index 04f327474b..0f93285fdd 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link DataSourceUnwrapper}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class DataSourceUnwrapperTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java index 2b5099800b..c259f2ae06 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/JacksonJsonParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -32,7 +32,6 @@ import static org.mockito.Mockito.spy; * * @author Dave Syer * @author Stephane Nicoll - * @author Yanming Zhou */ class JacksonJsonParserTests extends AbstractJsonParserTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosConnectionFactoryBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosConnectionFactoryBeanTests.java index 0f9d348416..6babbc0aa7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosConnectionFactoryBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosConnectionFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,9 +19,9 @@ package org.springframework.boot.jta.atomikos; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link AtomikosConnectionFactoryBean}. @@ -36,10 +36,10 @@ class AtomikosConnectionFactoryBeanTests { bean.setBeanName("bean"); bean.afterPropertiesSet(); assertThat(bean.getUniqueResourceName()).isEqualTo("bean"); - verify(bean).init(); - verify(bean, never()).close(); + then(bean).should().init(); + then(bean).should(never()).close(); bean.destroy(); - verify(bean).close(); + then(bean).should().close(); } static class MockAtomikosConnectionFactoryBean extends AtomikosConnectionFactoryBean { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosDataSourceBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosDataSourceBeanTests.java index b078d0012e..bc33b770dc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosDataSourceBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jta/atomikos/AtomikosDataSourceBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,9 +19,9 @@ package org.springframework.boot.jta.atomikos; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link AtomikosDataSourceBean}. @@ -36,10 +36,10 @@ class AtomikosDataSourceBeanTests { bean.setBeanName("bean"); bean.afterPropertiesSet(); assertThat(bean.getUniqueResourceName()).isEqualTo("bean"); - verify(bean).init(); - verify(bean, never()).close(); + then(bean).should().init(); + then(bean).should(never()).close(); bean.destroy(); - verify(bean).close(); + then(bean).should().close(); } static class MockAtomikosDataSourceBean extends AtomikosDataSourceBean { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java index c032c594e4..c887824089 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link DeferredLog}. * * @author Phillip Webb - * @author Yanming Zhou */ class DeferredLogTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java index 278b5a588b..8010cb9ef2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -28,7 +28,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link DeferredLogs}. * * @author Phillip Webb - * @author Yanming Zhou */ class DeferredLogsTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java index 8af76f78ba..86f4d028dc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DelegatingLoggingSystemFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link DelegatingLoggingSystemFactory}. * * @author Phillip Webb - * @author Yanming Zhou */ class DelegatingLoggingSystemFactoryTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index 41a8993635..7fcb0c860f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -69,7 +69,6 @@ import static org.mockito.Mockito.times; * @author Andy Wilkinson * @author Ben Hale * @author Madhura Bhave - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 56076e2a9e..18f309016b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -82,7 +82,6 @@ import static org.mockito.Mockito.times; * @author Vedran Pavic * @author Robert Thornton * @author Eddú Meléndez - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java index ca318c1af1..acb6e9c41d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileActionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link SpringProfileAction}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class SpringProfileActionTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java index d3ff36e697..0a50d36648 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/OriginTrackedResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link OriginTrackedResource}. * * @author Phillip Webb - * @author Yanming Zhou */ class OriginTrackedResourceTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java index 6490d2d716..1fb098565c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.mock; * * @author Spencer Gibb * @author Andy Wilkinson - * @author Yanming Zhou */ class RSocketPortInfoApplicationContextInitializerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java index 3be7af7be5..a5b60dd2b8 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -62,7 +62,6 @@ import static org.mockito.Mockito.reset; * * @author Andy Wilkinson * @author Phillip Webb - * @author Yanming Zhou */ class DatabaseInitializationDependencyConfigurerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java index 2d8bb0da64..183a491934 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -36,7 +36,6 @@ import static org.mockito.Mockito.spy; * * @author Stephane Nicoll * @author Filip Hrisafov - * @author Yanming Zhou */ class TaskExecutorBuilderTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java index fc849ee7e2..b9f8786f43 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -34,7 +34,6 @@ import static org.mockito.Mockito.spy; * Tests for {@link TaskSchedulerBuilder}. * * @author Stephane Nicoll - * @author Yanming Zhou */ class TaskSchedulerBuilderTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java index 8d79e95863..3b6670a785 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -32,7 +32,6 @@ import static org.mockito.Mockito.times; * Tests for {@link ConcurrentReferenceCachingMetadataReaderFactory}. * * @author Phillip Webb - * @author Yanming Zhou */ class ConcurrentReferenceCachingMetadataReaderFactoryTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java index 96eb48feee..374642980e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/LambdaSafeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock; * Tests for {@link LambdaSafe}. * * @author Phillip Webb - * @author Yanming Zhou */ class LambdaSafeTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 80d6cc2403..45ca08e663 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -73,7 +73,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Dmytro Nosan * @author Kevin Strijbos * @author Ilya Lukyanovich - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RestTemplateBuilderTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java index f0de79fd7f..f75da6468b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -41,7 +41,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link RootUriTemplateHandler}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class RootUriTemplateHandlerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java index 4b977763dc..d047fff2b2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -65,7 +65,6 @@ import static org.mockito.Mockito.mock; * @author Brian Clozel * @author Madhura Bhave * @author HaiTao Zhang - * @author Yanming Zhou */ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactoryTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index 8324669a3e..83a2d12a9b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -104,7 +104,6 @@ import static org.mockito.Mockito.mock; * @author Phillip Webb * @author Dave Syer * @author Stephane Nicoll - * @author Yanming Zhou */ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactoryTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java index 4a26a0f1be..24ff9da399 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -47,7 +47,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link ReactiveWebServerApplicationContext}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class ReactiveWebServerApplicationContextTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java index 6c90a36df6..998d376256 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.never; * Abstract base for {@link AbstractFilterRegistrationBean} tests. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) abstract class AbstractFilterRegistrationBeanTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java index 0416513cef..17faa28d7a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -42,7 +42,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link FilterRegistrationBean}. * * @author Phillip Webb - * @author Yanming Zhou */ class FilterRegistrationBeanTests extends AbstractFilterRegistrationBeanTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java index 7695784b38..b934637bc1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -35,7 +35,6 @@ import static org.mockito.Mockito.never; * Tests for {@link ServletListenerRegistrationBean}. * * @author Dave Syer - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletListenerRegistrationBeanTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java index a5cf6ac78f..f6a2d46080 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.Mockito.never; * Tests for {@link ServletRegistrationBean}. * * @author Phillip Webb - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class ServletRegistrationBeanTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java index 169b0a8b48..756fcecba3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -45,7 +45,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link AnnotationConfigServletWebServerApplicationContext}. * * @author Phillip Webb - * @author Yanming Zhou */ class AnnotationConfigServletWebServerApplicationContextTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java index 55bc804aae..60cbafa3ee 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -92,7 +92,6 @@ import static org.mockito.Mockito.withSettings; * * @author Phillip Webb * @author Stephane Nicoll - * @author Yanming Zhou */ @ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class }) class ServletWebServerApplicationContextTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java index 2f91e16bdb..04e0ea8749 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/XmlServletWebServerApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import static org.mockito.BDDMockito.then; * Tests for {@link XmlServletWebServerApplicationContext}. * * @author Phillip Webb - * @author Yanming Zhou */ class XmlServletWebServerApplicationContextTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index 5dbcaa9826..37d299c9fb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -164,7 +164,6 @@ import static org.mockito.Mockito.mock; * @author Greg Turnquist * @author Andy Wilkinson * @author Raja Kolli - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) public abstract class AbstractServletWebServerFactoryTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java index 42787a9993..91a1473036 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -61,7 +61,6 @@ import static org.mockito.Mockito.never; * * @author Dave Syer * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class ErrorPageFilterTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java index e37ef9f21e..82ec8f217b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ServletContextApplicationContextInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -31,7 +31,6 @@ import static org.mockito.Mockito.never; * Tests for {@link ServletContextApplicationContextInitializer}. * * @author Andy Wilkinson - * @author Yanming Zhou */ class ServletContextApplicationContextInitializerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java index 1396c967c3..84ac463bcb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -65,7 +65,6 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb * @author Andy Wilkinson - * @author Yanming Zhou */ @ExtendWith(OutputCaptureExtension.class) class SpringBootServletInitializerTests { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java index b9c70aef6d..550bc0f8c6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -53,7 +53,6 @@ import static org.mockito.Mockito.spy; * * @author Stephane Nicoll * @author Dmytro Nosan - * @author Yanming Zhou */ @ExtendWith(MockitoExtension.class) class WebServiceTemplateBuilderTests { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java index ecc6305167..4e2e4b801c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SpyBeanSampleDataJpaApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -37,7 +37,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for {@link SampleDataJpaApplication} that use {@link SpyBean @SpyBean}. * * @author Andy Wilkinson - * @author Yanming Zhou */ @SpringBootTest @AutoConfigureTestDatabase