Enable SpringJUnit5 Checkstyle rule

See gh-36496
Closes gh-36496

(cherry picked from commit 1256307c83)
This commit is contained in:
Sam Brannen
2026-03-17 12:40:52 +01:00
parent 01248c7753
commit 6d6b788b25
232 changed files with 424 additions and 359 deletions
@@ -167,7 +167,7 @@ import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
*/
@SuppressWarnings("deprecation")
public class MvcNamespaceTests {
class MvcNamespaceTests {
public static final String VIEWCONTROLLER_BEAN_NAME =
"org.springframework.web.servlet.config.viewControllerHandlerMapping";
@@ -62,7 +62,7 @@ import static org.mockito.Mockito.verify;
* @author Rossen Stoyanchev
*/
@ExtendWith(MockitoExtension.class)
public class DelegatingWebMvcConfigurationTests {
class DelegatingWebMvcConfigurationTests {
@Mock
private WebMvcConfigurer webMvcConfigurer;
@@ -51,7 +51,7 @@ import static org.mockito.Mockito.mock;
* @author Eko Kurniawan Khannedy
*/
@SuppressWarnings("deprecation")
public class InterceptorRegistryTests {
class InterceptorRegistryTests {
private InterceptorRegistry registry;
@@ -334,7 +334,7 @@ class WebMvcConfigurationSupportTests {
@Test
@SuppressWarnings("deprecation")
public void defaultThemeResolverConfiguration() {
void defaultThemeResolverConfiguration() {
ApplicationContext context = initContext(WebConfig.class);
org.springframework.web.servlet.ThemeResolver themeResolver =
context.getBean(THEME_RESOLVER_BEAN_NAME, org.springframework.web.servlet.ThemeResolver.class);
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.mock;
*
* @author Rossen Stoyanchev
*/
public class HandlerFunctionAdapterTests {
class HandlerFunctionAdapterTests {
private final MockHttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/");
@@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Rossen Stoyanchev
*/
@SuppressWarnings("unused")
public class HandlerMethodMappingTests {
class HandlerMethodMappingTests {
private MyHandlerMethodMapping mapping;
@@ -89,7 +89,7 @@ class DeferredResultReturnValueHandlerTests {
@Test
@SuppressWarnings({"deprecation", "removal"})
public void listenableFuture() throws Exception {
void listenableFuture() throws Exception {
org.springframework.util.concurrent.SettableListenableFuture<String> future =
new org.springframework.util.concurrent.SettableListenableFuture<>();
testHandle(future, org.springframework.util.concurrent.ListenableFuture.class,
@@ -110,7 +110,7 @@ class DeferredResultReturnValueHandlerTests {
@Test
@SuppressWarnings({"deprecation", "removal"})
public void listenableFutureWithError() throws Exception {
void listenableFutureWithError() throws Exception {
org.springframework.util.concurrent.SettableListenableFuture<String> future =
new org.springframework.util.concurrent.SettableListenableFuture<>();
IllegalStateException ex = new IllegalStateException();
@@ -52,7 +52,7 @@ import static org.springframework.web.testfixture.method.ResolvableMethod.on;
* Tests for streaming of {@link ModelAndView} fragments.
* @author Rossen Stoyanchev
*/
public class FragmentRenderingStreamTests {
class FragmentRenderingStreamTests {
private final MockHttpServletRequest request = new MockHttpServletRequest();
@@ -66,7 +66,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
*/
@SuppressWarnings("unused")
public class HttpEntityMethodProcessorTests {
class HttpEntityMethodProcessorTests {
private MethodParameter paramList;
@@ -86,7 +86,7 @@ import static org.springframework.web.servlet.mvc.method.annotation.MvcUriCompon
* @author Sam Brannen
*/
@SuppressWarnings("unused")
public class MvcUriComponentsBuilderTests {
class MvcUriComponentsBuilderTests {
private final MockHttpServletRequest request = new MockHttpServletRequest();
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Brian Clozel
*/
@ExtendWith(MockitoExtension.class)
public class ResponseBodyEmitterTests {
class ResponseBodyEmitterTests {
@Mock
private ResponseBodyEmitter.Handler handler;
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
* @author Rossen Stoyanchev
*/
@ExtendWith(GzipSupport.class)
public class CachingResourceResolverTests {
class CachingResourceResolverTests {
private Cache cache;
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
*/
@ExtendWith(GzipSupport.class)
public class EncodedResourceResolverTests {
class EncodedResourceResolverTests {
private ResourceResolverChain resolver;
@@ -52,7 +52,7 @@ class ResourceUrlProviderJavaConfigTests {
@BeforeEach
public void setup() throws Exception {
void setup() throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(WebConfig.class);
@@ -56,7 +56,7 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests {
@BeforeEach
public final void setUp() throws Exception {
final void setUp() throws Exception {
// set up a writer for the tag content to be written to
this.writer = new StringWriter();
@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Jeremy Grelle
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CheckboxesTagTests extends AbstractFormTagTests {
class CheckboxesTagTests extends AbstractFormTagTests {
private CheckboxesTag tag;
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Jeremy Grelle
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class ErrorsTagTests extends AbstractFormTagTests {
class ErrorsTagTests extends AbstractFormTagTests {
private static final String COMMAND_NAME = "testBean";
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Jeremy Grelle
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class RadioButtonsTagTests extends AbstractFormTagTests {
class RadioButtonsTagTests extends AbstractFormTagTests {
private RadioButtonsTag tag;
@@ -58,7 +58,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Sam Brannen
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class SelectTagTests extends AbstractFormTagTests {
class SelectTagTests extends AbstractFormTagTests {
private static final Locale LOCALE_AT = new Locale("de", "AT");
private static final Locale LOCALE_NL = new Locale("nl", "NL");
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 19.06.2003
*/
@SuppressWarnings("deprecation")
public class ThemeResolverTests {
class ThemeResolverTests {
private static final String TEST_THEME_NAME = "test.theme";
private static final String DEFAULT_TEST_THEME_NAME = "default.theme";
@@ -312,7 +312,7 @@ class ContentNegotiatingViewResolverTests {
@Test
@SuppressWarnings("deprecation")
public void resolveViewNameFilename() throws Exception {
void resolveViewNameFilename() throws Exception {
request.setRequestURI("/test.html");
ContentNegotiationManager manager =
@@ -344,7 +344,7 @@ class ContentNegotiatingViewResolverTests {
@Test
@SuppressWarnings("deprecation")
public void resolveViewNameFilenameDefaultView() throws Exception {
void resolveViewNameFilenameDefaultView() throws Exception {
request.setRequestURI("/test.json");
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
@@ -41,7 +41,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_21;
* @author Rossen Stoyanchev
*/
@DisabledForJreRange(min = JAVA_21, disabledReason = "Kotlin doesn't support Java 21+ yet")
public class DefaultFragmentsRenderingTests {
class DefaultFragmentsRenderingTests {
@Test
void render() throws Exception {
@@ -42,7 +42,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
* @author Sam Brannen
*/
@SuppressWarnings("deprecation")
public class ResourceBundleViewResolverTests {
class ResourceBundleViewResolverTests {
/** Comes from this package */
private static final String PROPS_FILE = "org.springframework.web.servlet.view.testviews";
@@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 25.01.2005
*/
@SuppressWarnings("deprecation")
public class FreeMarkerMacroTests {
class FreeMarkerMacroTests {
private static final String TEMPLATE_FILE = "test.ftl";
@@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock;
*
* @author Sebastien Deleuze
*/
public class ScriptTemplateViewTests {
class ScriptTemplateViewTests {
private ScriptTemplateView view;
@@ -66,7 +66,7 @@ public class ScriptTemplateViewTests {
@BeforeEach
public void setup() {
void setup() {
this.configurer = new ScriptTemplateConfigurer();
this.wac = new StaticWebApplicationContext();
this.wac.getBeanFactory().registerSingleton("scriptTemplateConfigurer", this.configurer);