Polish "Enforce use of BDDMockito"

See gh-29178
This commit is contained in:
Stephane Nicoll
2022-02-01 09:47:21 +01:00
parent b49418aaaf
commit 7f17f819a6
193 changed files with 208 additions and 381 deletions

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 <a href="https://github.com/spring-projects/spring-boot/issues/5837">5837</a>
*/
@ExtendWith(SpringExtension.class)

View File

@@ -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 <a href="https://github.com/spring-projects/spring-boot/issues/5837">5837</a>
*/
@ExtendWith(SpringExtension.class)

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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