Enable SpringJUnit5 Checkstyle rule

See gh-36496
Closes gh-36496
This commit is contained in:
Sam Brannen
2026-03-18 18:38:43 +01:00
parent 4c14abf0cd
commit 1256307c83
249 changed files with 424 additions and 361 deletions
@@ -52,5 +52,5 @@ import org.junit.platform.suite.api.Suite;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class ContextCacheTestSuite {
class ContextCacheTestSuite {
}
@@ -50,5 +50,5 @@ import org.junit.platform.suite.api.Suite;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class ContextConfigTestSuite {
class ContextConfigTestSuite {
}
@@ -45,13 +45,13 @@ import static org.springframework.test.context.TestExecutionListeners.MergeMode.
*/
@ExtendWith(SpringExtension.class)
@TestExecutionListeners(listeners = CustomEventPublishingTestExecutionListener.class, mergeMode = MERGE_WITH_DEFAULTS)
public class CustomTestEventTests {
class CustomTestEventTests {
private static final List<CustomEvent> events = new ArrayList<>();
@BeforeEach
public void clearEvents() {
void clearEvents() {
events.clear();
}
@@ -66,7 +66,7 @@ import static org.mockito.Mockito.verify;
* @author Sam Brannen
* @since 5.2
*/
public class EventPublishingTestExecutionListenerIntegrationTests {
class EventPublishingTestExecutionListenerIntegrationTests {
private static final String THREAD_NAME_PREFIX = "Test-";
@@ -88,7 +88,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
@AfterEach
public void closeApplicationContext() {
void closeApplicationContext() {
this.testContext.markApplicationContextDirty(null);
}
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class DispatcherWacRootWacEarTests extends RootWacEarTests {
class DispatcherWacRootWacEarTests extends RootWacEarTests {
@Autowired
private WebApplicationContext wac;
@@ -58,5 +58,5 @@ import org.springframework.context.ApplicationContextInitializer;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class AciTestSuite {
class AciTestSuite {
}
@@ -53,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ComposedContextConfiguration(BarConfig.class)
public class InitializerConfiguredViaMetaAnnotationTests {
class InitializerConfiguredViaMetaAnnotationTests {
@Autowired
String foo;
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = EntireAppInitializer.class)
public class InitializerWithoutConfigFilesOrClassesTests {
class InitializerWithoutConfigFilesOrClassesTests {
@Autowired
private String foo;
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = DevProfileInitializer.class)
public class MergedInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
class MergedInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
@Override
@Test
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@SpringJUnitConfig(classes = { GlobalConfig.class, DevProfileConfig.class }, initializers = {
FooBarAliasInitializer.class, DevProfileInitializer.class })
public class MultipleInitializersAnnotationConfigTests {
class MultipleInitializersAnnotationConfigTests {
@Autowired
private String foo, bar, baz;
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
// Note: the ordering of the initializers is intentionally: two, one.
@SpringJUnitConfig(classes = { GlobalConfig.class, ConfigTwo.class, ConfigOne.class }, initializers = {
OrderedTwoInitializer.class, OrderedOneInitializer.class })
public class OrderedInitializersAnnotationConfigTests {
class OrderedInitializersAnnotationConfigTests {
private static final String PROFILE_GLOBAL = "global";
private static final String PROFILE_ONE = "one";
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = DevProfileInitializer.class, inheritInitializers = false)
public class OverriddenInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
class OverriddenInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
@Test
@Override
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.1
*/
@SpringJUnitConfig(initializers = PropertySourcesInitializerTests.PropertySourceInitializer.class)
public class PropertySourcesInitializerTests {
class PropertySourcesInitializerTests {
@Configuration
static class Config {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(classes = { GlobalConfig.class, DevProfileConfig.class }, initializers = FooBarAliasInitializer.class)
public class SingleInitializerAnnotationConfigTests {
class SingleInitializerAnnotationConfigTests {
@Autowired
protected String foo;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = { FooBarAliasInitializer.class, DevProfileInitializer.class })
public class MultipleInitializersXmlConfigTests {
class MultipleInitializersXmlConfigTests {
@Autowired
private String foo, bar, baz;
@@ -46,5 +46,5 @@ import org.junit.platform.suite.api.Suite;
@SelectPackages("org.springframework.test.context.junit.jupiter")
@IncludeClassNamePatterns(".*Tests$")
@ExcludeTags("failing-test-case")
public class SpringJUnitJupiterTestSuite {
class SpringJUnitJupiterTestSuite {
}
@@ -24,11 +24,12 @@ import org.springframework.test.context.ActiveProfilesResolver;
* @since 4.0
*/
@ActiveProfiles(resolver = DevProfileResolverAnnotationConfigTests.class, inheritProfiles = false)
public class DevProfileResolverAnnotationConfigTests extends DevProfileAnnotationConfigTests implements
class DevProfileResolverAnnotationConfigTests extends DevProfileAnnotationConfigTests implements
ActiveProfilesResolver {
@Override
public String[] resolve(Class<?> testClass) {
return new String[] { "dev" };
}
}
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatNoException;
* @author Sam Brannen
* @since 5.3.10
*/
public class ExceptionCollectorTests {
class ExceptionCollectorTests {
private static final char EOL = '\n';
@@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.hasXPath;
*
* @author Rossen Stoyanchev
*/
public class ContentRequestMatchersTests {
class ContentRequestMatchersTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.equalTo;
* @author Rossen Stoyanchev
* @author Sam Brannen
*/
public class JsonPathRequestMatchersTests {
class JsonPathRequestMatchersTests {
private static final String REQUEST_CONTENT = "{" + //
"'str': 'foo', " + //
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Valentin Spac
* @author Rossen Stoyanchev
*/
public class MultipartRequestMatchersTests {
class MultipartRequestMatchersTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@@ -54,7 +54,7 @@ public class MultipartRequestMatchersTests {
@BeforeEach
public void setup() {
void setup() {
this.request.getHeaders().setContentType(MediaType.MULTIPART_FORM_DATA);
}
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Rossen Stoyanchev
*/
public class XpathRequestMatchersTests {
class XpathRequestMatchersTests {
private static final String RESPONSE_CONTENT = "<foo><bar>111</bar><bar>true</bar></foo>";
@@ -39,7 +39,7 @@ public class XpathRequestMatchersTests {
@BeforeEach
public void setUp() throws IOException {
void setUp() throws IOException {
this.request = new MockClientHttpRequest();
this.request.getBody().write(RESPONSE_CONTENT.getBytes());
}
@@ -53,7 +53,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
* @see ContentRequestMatchersIntegrationTests
* @see XmlContentRequestMatchersIntegrationTests
*/
public class XpathRequestMatchersIntegrationTests {
class XpathRequestMatchersIntegrationTests {
private static final Map<String, String> NS =
Collections.singletonMap("ns", "https://example.org/music/people");
@@ -67,7 +67,7 @@ public class XpathRequestMatchersIntegrationTests {
@BeforeEach
public void setup() {
void setup() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
new Person("Johannes Brahms").setSomeDouble(.0025),
@@ -34,8 +34,7 @@ import org.springframework.web.server.session.WebSessionManager;
* Unit tests with {@link ApplicationContextSpec}.
* @author Rossen Stoyanchev
*/
public class ApplicationContextSpecTests {
class ApplicationContextSpecTests {
@Test // SPR-17094
void sessionManagerBean() {
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class DefaultControllerSpecTests {
class DefaultControllerSpecTests {
@Test
void controller() {
@@ -30,7 +30,7 @@ import org.springframework.web.reactive.function.server.ServerResponse;
*
* @author Rossen Stoyanchev
*/
public class DefaultRouterFunctionSpecTests {
class DefaultRouterFunctionSpecTests {
@Test
void webFilter() {
@@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class HttpHandlerConnectorTests {
class HttpHandlerConnectorTests {
@Test
void adaptRequest() {
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link AbstractMockServerSpec}.
* @author Rossen Stoyanchev
*/
public class MockServerSpecTests {
class MockServerSpecTests {
private final TestMockServerSpec serverSpec = new TestMockServerSpec();
@@ -37,8 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Test scenarios involving a mock server.
* @author Rossen Stoyanchev
*/
public class MockServerTests {
class MockServerTests {
@Test // SPR-15674 (in comments)
void mutateDoesNotCreateNewSession() {
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
* @since 5.0
*/
public class WiretapConnectorTests {
class WiretapConnectorTests {
private final LeakAwareDataBufferFactory bufferFactory =
new LeakAwareDataBufferFactory(new NettyDataBufferFactory(PooledByteBufAllocator.DEFAULT));
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class WebTestClientResponseTests {
class WebTestClientResponseTests {
private final WebTestClient client = WebTestClient.bindToController(HelloController.class).build();
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class ApiVersionTests {
class ApiVersionTests {
@Test
void header() {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class GlobalEntityResultConsumerTests {
class GlobalEntityResultConsumerTests {
private final StringBuilder output = new StringBuilder();
@@ -29,13 +29,13 @@ import org.springframework.web.bind.annotation.RestController;
*
* @author Rossen Stoyanchev
*/
public class ControllerTests {
class ControllerTests {
private WebTestClient client;
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
this.client = WebTestClient.bindToController(new TestController()).build();
}
@@ -35,7 +35,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* @author Rossen Stoyanchev
* @since 5.0
*/
public class HttpServerTests {
class HttpServerTests {
private ReactorHttpServer server;
@@ -43,7 +43,7 @@ public class HttpServerTests {
@BeforeEach
public void start() throws Exception {
void start() throws Exception {
HttpHandler httpHandler = RouterFunctions.toHttpHandler(
route(GET("/test"), request -> ServerResponse.ok().bodyValue("It works!")));
@@ -58,7 +58,7 @@ public class HttpServerTests {
}
@AfterEach
public void stop() {
void stop() {
this.server.stop();
}
@@ -32,13 +32,13 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* @author Rossen Stoyanchev
* @since 5.0
*/
public class RouterFunctionTests {
class RouterFunctionTests {
private WebTestClient testClient;
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
RouterFunction<?> route = route(GET("/test"), request ->
ServerResponse.ok().bodyValue("It works!"));
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*
* @author Rossen Stoyanchev
*/
public class DefaultMvcResultTests {
class DefaultMvcResultTests {
private final DefaultMvcResult mvcResult = new DefaultMvcResult(new MockHttpServletRequest(), null);
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Stephane Nicoll
*/
public class AbstractHttpServletRequestAssertTests {
class AbstractHttpServletRequestAssertTests {
@Nested
class AttributesTests {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Stephane Nicoll
*/
public class AbstractMockHttpServletResponseAssertTests {
class AbstractMockHttpServletResponseAssertTests {
@Test
void bodyText() {
@@ -96,7 +96,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
* @author Stephane Nicoll
*/
@SpringJUnitWebConfig
public class MockMvcTesterIntegrationTests {
class MockMvcTesterIntegrationTests {
private static final MockMultipartFile file = new MockMultipartFile("file", "content.txt", null,
"value".getBytes(StandardCharsets.UTF_8));
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class RestTestClientResponseTests {
class RestTestClientResponseTests {
private final RestTestClient client =
RestTestClient.bindToController(HelloController.class)
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class ApiVersionTests {
class ApiVersionTests {
@Test
void header() {
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
* @author Sam Brannen
* @since 4.2
*/
public class HostRequestMatcherTests extends AbstractWebRequestMatcherTests {
class HostRequestMatcherTests extends AbstractWebRequestMatcherTests {
@Test
void localhost() throws Exception {
@@ -55,7 +55,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
* @author Sam Brannen
* @since 4.2
*/
public class HtmlUnitRequestBuilderTests {
class HtmlUnitRequestBuilderTests {
private final WebClient webClient = new WebClient();
@@ -51,7 +51,7 @@ import static org.mockito.Mockito.mock;
*/
@SpringJUnitWebConfig
@SuppressWarnings("rawtypes")
public class MockMvcConnectionBuilderSupportTests {
class MockMvcConnectionBuilderSupportTests {
private final WebClient client = mock();
@@ -62,7 +62,7 @@ public class MockMvcConnectionBuilderSupportTests {
@BeforeEach
public void setup() {
void setup() {
given(this.client.getWebConnection()).willReturn(mock());
this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {};
}
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Rob Winch
* @since 4.2
*/
public class MockMvcWebConnectionTests {
class MockMvcWebConnectionTests {
private final WebClient webClient = new WebClient();
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rob Winch
* @since 4.2
*/
public class MockWebResponseBuilderTests {
class MockWebResponseBuilderTests {
private final MockHttpServletResponse response = new MockHttpServletResponse();
@@ -48,7 +48,7 @@ public class MockWebResponseBuilderTests {
@BeforeEach
public void setup() throws Exception {
void setup() throws Exception {
this.webRequest = new WebRequest(new URL("http://company.example:80/test/this/here"));
this.responseBuilder = new MockWebResponseBuilder(System.currentTimeMillis(), this.webRequest, this.response);
}
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
* @author Sam Brannen
* @since 4.2
*/
public class UrlRegexRequestMatcherTests extends AbstractWebRequestMatcherTests {
class UrlRegexRequestMatcherTests extends AbstractWebRequestMatcherTests {
@Test
void verifyExampleInClassLevelJavadoc() throws Exception {
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
public class AbstractMockMultipartHttpServletRequestBuilderTests {
class AbstractMockMultipartHttpServletRequestBuilderTests {
private final ServletContext servletContext = new MockServletContext();
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link MockMultipartHttpServletRequestBuilder}.
* @author Rossen Stoyanchev
*/
public class MockMultipartHttpServletRequestBuilderTests {
class MockMultipartHttpServletRequestBuilderTests {
@Test // gh-26166
void addFileAndParts() throws Exception {
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Craig Walls
*/
public class FlashAttributeResultMatchersTests {
class FlashAttributeResultMatchersTests {
@Test
void attributeExists() throws Exception {
@@ -32,7 +32,7 @@ import org.springframework.test.web.servlet.StubMvcResult;
*
* @author Rossen Stoyanchev
*/
public class HeaderResultMatchersTests {
class HeaderResultMatchersTests {
private final HeaderResultMatchers matchers = new HeaderResultMatchers();
@@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Brian Clozel
* @author Sam Brannen
*/
public class MockMvcResultMatchersTests {
class MockMvcResultMatchersTests {
@Test
void redirect() throws Exception {
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.fail;
*
* @author Rossen Stoyanchev
*/
public class StatusResultMatchersTests {
class StatusResultMatchersTests {
private final StatusResultMatchers matchers = new StatusResultMatchers();
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Rossen Stoyanchev
*/
public class XpathResultMatchersTests {
class XpathResultMatchersTests {
private static final String RESPONSE_CONTENT = "<foo><bar>111</bar><bar>true</bar></foo>";
@@ -57,7 +57,7 @@ import static org.mockito.Mockito.mock;
@WebAppConfiguration
@ContextHierarchy(@ContextConfiguration(classes = AsyncControllerJavaConfigTests.WebConfig.class))
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class AsyncControllerJavaConfigTests {
class AsyncControllerJavaConfigTests {
@Autowired
private WebApplicationContext wac;
@@ -69,7 +69,7 @@ public class AsyncControllerJavaConfigTests {
@BeforeEach
public void setup() {
void setup() {
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
}
@@ -50,7 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("../../context/servlet-context.xml")
})
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class WebAppResourceTests {
class WebAppResourceTests {
@Autowired
private WebApplicationContext wac;
@@ -59,7 +59,7 @@ public class WebAppResourceTests {
@BeforeEach
public void setup() {
void setup() {
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
}
@@ -48,7 +48,7 @@ import static org.mockito.BDDMockito.given;
@ContextConfiguration("../../context/servlet-context.xml")
})
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class XmlConfigTests {
class XmlConfigTests {
@Autowired
private WebApplicationContext wac;
@@ -60,7 +60,7 @@ public class XmlConfigTests {
@BeforeEach
public void setup() {
void setup() {
this.testClient = MockMvcWebTestClient.bindToApplicationContext(this.wac).build();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
@@ -58,7 +58,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class FilterTests {
class FilterTests {
@Test
void whenFiltersCompleteMvcProcessesRequest() throws Exception {
@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class FrameworkExtensionTests {
class FrameworkExtensionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new SampleController())
@@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class MultipartControllerTests {
class MultipartControllerTests {
private final WebTestClient testClient = MockMvcWebTestClient.bindToController(new MultipartController()).build();
@@ -36,7 +36,7 @@ import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
*
* @author Rossen Stoyanchev
*/
public class ReactiveReturnTypeTests {
class ReactiveReturnTypeTests {
@Test
void sseWithFlux() {
@@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class RedirectTests {
class RedirectTests {
private final WebTestClient testClient =
MockMvcWebTestClient.bindToController(new PersonController()).build();
@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
*
* @author Rossen Stoyanchev
*/
public class RequestParameterTests {
class RequestParameterTests {
@Test
void queryParameter() {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class SseTests {
class SseTests {
private final WebTestClient testClient =
MockMvcWebTestClient.bindToController(new SseController()).build();
@@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author Rossen Stoyanchev
*/
@Disabled
public class PrintingResultHandlerSmokeTests {
class PrintingResultHandlerSmokeTests {
private final WebTestClient testClient =
MockMvcWebTestClient.bindToController(new SimpleController()).build();
@@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class CookieAssertionTests {
class CookieAssertionTests {
private static final String COOKIE_NAME = CookieLocaleResolver.DEFAULT_COOKIE_NAME;
@@ -47,7 +47,7 @@ public class CookieAssertionTests {
@BeforeEach
public void setup() {
void setup() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setCookieDomain("domain");
localeResolver.setCookieHttpOnly(true);
@@ -42,7 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class FlashAttributeAssertionTests {
class FlashAttributeAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new PersonController())
@@ -43,7 +43,7 @@ import static org.springframework.web.servlet.mvc.method.annotation.MvcUriCompon
*
* @author Rossen Stoyanchev
*/
public class HandlerAssertionTests {
class HandlerAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new SimpleController())
@@ -46,7 +46,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class JsonPathAssertionTests {
class JsonPathAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new MusicController())
@@ -49,7 +49,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class ModelAssertionTests {
class ModelAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new SampleController("a string value", 3, new Person("a name")))
@@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class RequestAttributeAssertionTests {
class RequestAttributeAssertionTests {
private final WebTestClient mainServletClient =
MockMvcWebTestClient.bindToController(new SimpleController())
@@ -44,7 +44,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class SessionAttributeAssertionTests {
class SessionAttributeAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new SimpleController())
@@ -33,7 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class UrlAssertionTests {
class UrlAssertionTests {
private final WebTestClient testClient =
MockMvcWebTestClient.bindToController(new SimpleController()).build();
@@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class ViewNameAssertionTests {
class ViewNameAssertionTests {
private final WebTestClient client =
MockMvcWebTestClient.bindToController(new SimpleController())
@@ -44,7 +44,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class XmlContentAssertionTests {
class XmlContentAssertionTests {
private static final String PEOPLE_XML =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
@@ -53,7 +53,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.HEAD;
*
* @author Rossen Stoyanchev
*/
public class XpathAssertionTests {
class XpathAssertionTests {
private static final Map<String, String> musicNamespace =
Collections.singletonMap("ns", "https://example.org/music/people");
@@ -63,7 +63,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@WebAppConfiguration
@ContextHierarchy(@ContextConfiguration(classes = AsyncControllerJavaConfigTests.WebConfig.class))
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class AsyncControllerJavaConfigTests {
class AsyncControllerJavaConfigTests {
@Autowired
private WebApplicationContext wac;
@@ -75,7 +75,7 @@ public class AsyncControllerJavaConfigTests {
@BeforeEach
public void setup() {
void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@@ -69,7 +69,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration(classes = WebConfig.class)
})
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class JavaConfigTests {
class JavaConfigTests {
@Autowired
private WebApplicationContext wac;
@@ -84,7 +84,7 @@ public class JavaConfigTests {
@BeforeEach
public void setup() {
void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
verifyRootWacSupport();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
@@ -50,7 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("servlet-context.xml")
})
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class WebAppResourceTests {
class WebAppResourceTests {
@Autowired
private WebApplicationContext wac;
@@ -58,7 +58,7 @@ public class WebAppResourceTests {
private MockMvc mockMvc;
@BeforeEach
public void setup() {
void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).alwaysExpect(status().isOk()).build();
}
@@ -51,7 +51,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("servlet-context.xml")
})
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class XmlConfigTests {
class XmlConfigTests {
@Autowired
private WebApplicationContext wac;
@@ -63,7 +63,7 @@ public class XmlConfigTests {
@BeforeEach
public void setup() {
void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
given(this.personDao.getPerson(5L)).willReturn(new Person("Joe"));
}
@@ -53,7 +53,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
* @since 4.2
* @see RequestContextHolderTests
*/
public class CustomRequestAttributesRequestContextHolderTests {
class CustomRequestAttributesRequestContextHolderTests {
private static final String FROM_CUSTOM_MOCK = "fromCustomMock";
private static final String FROM_MVC_TEST_DEFAULT = "fromSpringMvcTestDefault";
@@ -65,7 +65,7 @@ public class CustomRequestAttributesRequestContextHolderTests {
@BeforeEach
public void setUp() {
void setUp() {
ServletContext servletContext = new MockServletContext();
MockHttpServletRequest mockRequest = new MockHttpServletRequest(servletContext);
mockRequest.setAttribute(FROM_CUSTOM_MOCK, FROM_CUSTOM_MOCK);
@@ -54,7 +54,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
* @author Sebastien Deleuze
*/
@SpringJUnitWebConfig
public class EncodedUriTests {
class EncodedUriTests {
private final MockMvc mockMvc;
@@ -33,7 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class FormContentTests {
class FormContentTests {
@Test // SPR-15753
void formContentIsNotDuplicated() throws Exception {
@@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
* @author Arnaud Cogoluègnes
*/
@SpringJUnitWebConfig
public class HttpOptionsTests {
class HttpOptionsTests {
private final WebApplicationContext wac;
@@ -72,7 +72,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
@WebAppConfiguration
@ContextConfiguration
@DirtiesContext
public class RequestContextHolderTests {
class RequestContextHolderTests {
private static final String FROM_TCF_MOCK = "fromTestContextFrameworkMock";
private static final String FROM_MVC_TEST_DEFAULT = "fromSpringMvcTestDefault";
@@ -102,7 +102,7 @@ public class RequestContextHolderTests {
@BeforeEach
public void setup() {
void setup() {
this.mockRequest.setAttribute(FROM_TCF_MOCK, FROM_TCF_MOCK);
this.mockMvc = webAppContextSetup(this.wac)
@@ -41,7 +41,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* Tests demonstrating the use of API version.
* @author Rossen Stoyanchev
*/
public class ApiVersionTests {
class ApiVersionTests {
@Test
void queryParameter() throws Exception {
@@ -42,7 +42,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Rossen Stoyanchev
* @author Sam Brannen
*/
public class ExceptionHandlerTests {
class ExceptionHandlerTests {
@Nested
class MvcTests {
@@ -65,7 +65,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* Tests with {@link Filter}'s.
* @author Rob Winch
*/
public class FilterTests {
class FilterTests {
@Test
void whenFiltersCompleteMvcProcessesRequest() throws Exception {
@@ -50,7 +50,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Rossen Stoyanchev
* @since 4.1
*/
public class FrameworkExtensionTests {
class FrameworkExtensionTests {
private final MockMvc mockMvc = standaloneSetup(new SampleController()).apply(defaultSetup()).build();
@@ -39,8 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Rossen Stoyanchev
*/
public class ReactiveReturnTypeTests {
class ReactiveReturnTypeTests {
@Test // SPR-16869
void sseWithFlux() throws Exception {
@@ -45,13 +45,13 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Rossen Stoyanchev
* @author Juergen Hoeller
*/
public class RedirectTests {
class RedirectTests {
private MockMvc mockMvc;
@BeforeEach
public void setup() {
void setup() {
this.mockMvc = standaloneSetup(new PersonController()).build();
}
@@ -36,11 +36,10 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
*
* @author Rossen Stoyanchev
*/
public class RequestParameterTests {
class RequestParameterTests {
@Test
void queryParameter() throws Exception {
standaloneSetup(new PersonController()).build()
.perform(get("/search?name=George").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
@@ -45,7 +45,7 @@ import static org.springframework.web.servlet.function.ServerResponse.ok;
/**
* @author Arjen Poutsma
*/
public class RouterFunctionTests {
class RouterFunctionTests {
private MockMvc mockMvc = routerFunctions(testRoute()).defaultResponseCharacterEncoding(UTF_8).build();
@@ -48,7 +48,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @see org.springframework.test.web.servlet.result.PrintingResultHandlerTests
*/
@Disabled
public class PrintingResultHandlerSmokeTests {
class PrintingResultHandlerSmokeTests {
// Not intended to be executed with the build.
// Comment out class-level @Disabled to see the output.
@@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @see XmlContentAssertionTests
* @see XpathAssertionTests
*/
public class ContentAssertionTests {
class ContentAssertionTests {
private final MockMvc mockMvc = standaloneSetup(new SimpleController()).alwaysExpect(status().isOk()).build();
@@ -45,7 +45,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Rossen Stoyanchev
* @author Nikola Yovchev
*/
public class CookieAssertionTests {
class CookieAssertionTests {
private static final String COOKIE_NAME = CookieLocaleResolver.DEFAULT_COOKIE_NAME;
private static final String COOKIE_WITH_ATTRIBUTES_NAME = "SecondCookie";
@@ -55,7 +55,7 @@ public class CookieAssertionTests {
@BeforeEach
public void setup() {
void setup() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setCookieDomain("domain");
localeResolver.setCookieHttpOnly(true);
@@ -41,7 +41,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Rossen Stoyanchev
* @author Sam Brannen
*/
public class FlashAttributeAssertionTests {
class FlashAttributeAssertionTests {
private final MockMvc mockMvc = standaloneSetup(new PersonController())
.alwaysExpect(status().isFound())
@@ -42,7 +42,7 @@ import static org.springframework.web.servlet.mvc.method.annotation.MvcUriCompon
* @author Rossen Stoyanchev
* @author Sam Brannen
*/
public class HandlerAssertionTests {
class HandlerAssertionTests {
private final MockMvc mockMvc = standaloneSetup(new SimpleController()).alwaysExpect(status().isOk()).build();
@@ -57,7 +57,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
* @author Sam Brannen
* @author Brian Clozel
*/
public class HeaderAssertionTests {
class HeaderAssertionTests {
private static final String ERROR_MESSAGE = "Should have thrown an AssertionError";
@@ -74,7 +74,7 @@ public class HeaderAssertionTests {
@BeforeEach
public void setup() {
void setup() {
this.dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
this.dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
this.now = dateFormat.format(new Date(this.currentTime));

Some files were not shown because too many files have changed in this diff Show More