diff --git a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java index c7a88ede834..dc5219976c8 100644 --- a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java +++ b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; class MockServerHttpResponseTests { @Test - void cookieHeaderSet() throws Exception { + void cookieHeaderSet() { ResponseCookie foo11 = ResponseCookie.from("foo1", "bar1").build(); ResponseCookie foo12 = ResponseCookie.from("foo1", "bar2").build(); diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java index 2b352bf1b19..7d97259b06a 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,13 +62,13 @@ class MockFilterChainTests { } @Test - void doFilterNullRequest() throws Exception { + void doFilterNullRequest() { MockFilterChain chain = new MockFilterChain(); assertThatIllegalArgumentException().isThrownBy(() -> chain.doFilter(null, this.response)); } @Test - void doFilterNullResponse() throws Exception { + void doFilterNullResponse() { MockFilterChain chain = new MockFilterChain(); assertThatIllegalArgumentException().isThrownBy(() -> chain.doFilter(this.request, null)); } @@ -143,7 +143,7 @@ class MockFilterChainTests { } @Override - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) { } @Override diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java index b48ff3cd6c6..033bf360cf3 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java @@ -114,7 +114,7 @@ class MockHttpServletRequestTests { } @Test - void getContentAsStringWithoutSettingCharacterEncoding() throws IOException { + void getContentAsStringWithoutSettingCharacterEncoding() { assertThatIllegalStateException().isThrownBy( request::getContentAsString) .withMessageContaining("Cannot get content as a String for a null character encoding"); @@ -145,14 +145,14 @@ class MockHttpServletRequestTests { } @Test // SPR-16505 - void getInputStreamTwice() throws IOException { + void getInputStreamTwice() { byte[] bytes = "body".getBytes(Charset.defaultCharset()); request.setContent(bytes); assertThat(request.getInputStream()).isSameAs(request.getInputStream()); } @Test // SPR-16499 - void getReaderAfterGettingInputStream() throws IOException { + void getReaderAfterGettingInputStream() { request.getInputStream(); assertThatIllegalStateException().isThrownBy( request::getReader) diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockPageContextTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockPageContextTests.java index 6689928cca0..98a7efb849d 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockPageContextTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockPageContextTests.java @@ -35,7 +35,7 @@ class MockPageContextTests { private final MockPageContext ctx = new MockPageContext(); @Test - void setAttributeWithNoScopeUsesPageScope() throws Exception { + void setAttributeWithNoScopeUsesPageScope() { ctx.setAttribute(key, value); assertThat(ctx.getAttribute(key, PageContext.PAGE_SCOPE)).isEqualTo(value); assertThat(ctx.getAttribute(key, PageContext.APPLICATION_SCOPE)).isNull(); @@ -44,7 +44,7 @@ class MockPageContextTests { } @Test - void removeAttributeWithNoScopeSpecifiedRemovesValueFromAllScopes() throws Exception { + void removeAttributeWithNoScopeSpecifiedRemovesValueFromAllScopes() { ctx.setAttribute(key, value, PageContext.APPLICATION_SCOPE); ctx.removeAttribute(key); diff --git a/spring-test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java b/spring-test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java index 5cd19a7f27e..cda7ef18052 100644 --- a/spring-test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java @@ -46,11 +46,11 @@ class ProfileValueUtilsTests { System.setProperty(NAME, VALUE); } - private void assertClassIsEnabled(Class testClass) throws Exception { + private void assertClassIsEnabled(Class testClass) { assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be enabled.").isTrue(); } - private void assertClassIsDisabled(Class testClass) throws Exception { + private void assertClassIsDisabled(Class testClass) { assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be disabled.").isFalse(); } @@ -81,7 +81,7 @@ class ProfileValueUtilsTests { // ------------------------------------------------------------------- @Test - void isTestEnabledInThisEnvironmentForProvidedClass() throws Exception { + void isTestEnabledInThisEnvironmentForProvidedClass() { assertClassIsEnabled(NonAnnotated.class); assertClassIsEnabled(EnabledAnnotatedSingleValue.class); assertClassIsEnabled(EnabledAnnotatedMultiValue.class); diff --git a/spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java index 424edde7bc0..550de54679f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author 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 @@ class DynamicPropertySourceIntegrationTests { System.setProperty(TEST_CONTAINER_IP, "system"); } - static DemoContainer container = new DemoContainer(); + static final DemoContainer container = new DemoContainer(); @DynamicPropertySource static void containerProperties(DynamicPropertyRegistry registry) { diff --git a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java index 693c0131b43..655ec8a66a8 100644 --- a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java @@ -241,7 +241,7 @@ class MergedContextConfigurationTests { void equalsBasics() { MergedContextConfiguration mergedConfig = new MergedContextConfiguration(null, null, null, null, null); assertThat(mergedConfig).isEqualTo(mergedConfig); - assertThat(mergedConfig).isNotNull(); + assertThat(mergedConfig).isNotEqualTo(null); assertThat(mergedConfig).isNotEqualTo(1); } diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java index d66c1454c0d..bf78b89241f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ class TestContextConcurrencyTests { - private static Set expectedMethods = stream(TestCase.class.getDeclaredMethods()) + private static final Set expectedMethods = stream(TestCase.class.getDeclaredMethods()) .map(Method::getName) .collect(toCollection(TreeSet::new)); @@ -122,7 +122,7 @@ class TestContextConcurrencyTests { @Override - public void beforeTestMethod(TestContext testContext) throws Exception { + public void beforeTestMethod(TestContext testContext) { String name = testContext.getTestMethod().getName(); actualMethods.add(name); testContext.setAttribute("method", name); @@ -130,7 +130,7 @@ class TestContextConcurrencyTests { } @Override - public void afterTestMethod(TestContext testContext) throws Exception { + public void afterTestMethod(TestContext testContext) { assertThat(testContext.getAttribute("method")).isEqualTo(this.methodName.get()); } diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerMethodInvokerTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerMethodInvokerTests.java index bf613604485..2f57c252376 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerMethodInvokerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerMethodInvokerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class TestContextManagerMethodInvokerTests { } @Override - public void prepareTestInstance(TestContext testContext) throws Exception { + public void prepareTestInstance(TestContext testContext) { assertThat(testContext.getMethodInvoker()).isSameAs(customMethodInvoker); } diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerSuppressedExceptionsTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerSuppressedExceptionsTests.java index 5cb3490731f..008e18ff96f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerSuppressedExceptionsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerSuppressedExceptionsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,23 +36,23 @@ import static org.assertj.core.api.Assertions.fail; class TestContextManagerSuppressedExceptionsTests { @Test - void afterTestExecution() throws Exception { + void afterTestExecution() { test("afterTestExecution", FailingAfterTestExecutionTestCase.class, (tcm, c, m) -> tcm.afterTestExecution(this, m, null)); } @Test - void afterTestMethod() throws Exception { + void afterTestMethod() { test("afterTestMethod", FailingAfterTestMethodTestCase.class, (tcm, c, m) -> tcm.afterTestMethod(this, m, null)); } @Test - void afterTestClass() throws Exception { + void afterTestClass() { test("afterTestClass", FailingAfterTestClassTestCase.class, (tcm, c, m) -> tcm.afterTestClass()); } - private void test(String useCase, Class testClass, Callback callback) throws Exception { + private void test(String useCase, Class testClass, Callback callback) { TestContextManager testContextManager = new TestContextManager(testClass); assertThat(testContextManager.getTestExecutionListeners().size()).as("Registered TestExecutionListeners").isEqualTo(2); diff --git a/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java b/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java index 61870018e53..595208e0596 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestExecutionListenersTests.java @@ -134,13 +134,13 @@ class TestExecutionListenersTests { @Test void nonInheritedDefaultListeners() { - assertRegisteredListeners(NonInheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class)); + assertRegisteredListeners(NonInheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class)); } @Test void inheritedDefaultListeners() { - assertRegisteredListeners(InheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class)); - assertRegisteredListeners(SubInheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class)); + assertRegisteredListeners(InheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class)); + assertRegisteredListeners(SubInheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class)); assertRegisteredListeners(SubSubInheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class, EnigmaTestExecutionListener.class)); } diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorIntegrationTests.java index 093e3614de7..c056ffb84cc 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorIntegrationTests.java @@ -292,7 +292,7 @@ class TestContextAotGeneratorIntegrationTests extends AbstractAotTests { assertThat(messageService.generateMessage()).isEqualTo(expectedMessage); } - private void assertContextForJdbcTests(ApplicationContext context) throws Exception { + private void assertContextForJdbcTests(ApplicationContext context) { assertThat(context.getEnvironment().getProperty("test.engine")).as("Environment").isNotNull(); assertThat(context.getBean(DataSource.class)).as("DataSource").isNotNull(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java index 783b1fbf052..d5db204983a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 +21,6 @@ import org.junit.jupiter.api.Test; import org.springframework.aot.AotDetector; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.TestPropertySource; @@ -52,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class DisabledInAotRuntimeClassLevelTests { @Test - void test(@Autowired ApplicationContext context, @Autowired MessageService messageService, + void test(@Autowired MessageService messageService, @Value("${disabledInAotMode}") String disabledInAotMode) { assertThat(AotDetector.useGeneratedArtifacts()).as("Should be disabled in AOT mode").isFalse(); diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java index e12707b6376..af8f0b8c515 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 +21,6 @@ import org.junit.jupiter.api.Test; import org.springframework.aot.AotDetector; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.TestPropertySource; @@ -49,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class DisabledInAotRuntimeMethodLevelTests { @Test - void test(@Autowired ApplicationContext context, @Autowired MessageService messageService, + void test(@Autowired MessageService messageService, @Value("${disabledInAotMode}") String disabledInAotMode) { assertThat(messageService.generateMessage()).isEqualTo("Hello, AOT!"); diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java index 9c60bc9b6f3..f0663a50e2c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class ClassLevelDirtiesContextTestNGTests { } @Test - void verifyDirtiesContextBehavior() throws Exception { + void verifyDirtiesContextBehavior() { assertBehaviorForCleanTestCase(); diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java index 4249ddb7ab9..76a665a782c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java @@ -155,7 +155,6 @@ class LruContextCacheTests { return new MergedContextConfiguration(null, null, new Class[] { clazz }, null, null); } - @SuppressWarnings("unchecked") private static void assertCacheContents(DefaultContextCache cache, String... expectedNames) { assertThat(cache).extracting("contextMap", as(map(MergedContextConfiguration.class, ApplicationContext.class))) .satisfies(contextMap -> { diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java index 78506f997a0..72dbddc0eaf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/MethodLevelDirtiesContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,31 +62,31 @@ class MethodLevelDirtiesContextTests { @Test @Order(1) - void basics() throws Exception { + void basics() { performAssertions(1); } @Test @Order(2) @DirtiesContext(methodMode = BEFORE_METHOD) - void dirtyContextBeforeTestMethod() throws Exception { + void dirtyContextBeforeTestMethod() { performAssertions(2); } @Test @Order(3) @DirtiesContext - void dirtyContextAfterTestMethod() throws Exception { + void dirtyContextAfterTestMethod() { performAssertions(2); } @Test @Order(4) - void backToBasics() throws Exception { + void backToBasics() { performAssertions(3); } - private void performAssertions(int expectedContextCreationCount) throws Exception { + private void performAssertions(int expectedContextCreationCount) { assertThat(this.context).as("context must not be null").isNotNull(); assertThat(this.context.isActive()).as("context must be active").isTrue(); diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/BootstrapWithTestInterface.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/BootstrapWithTestInterface.java index 0161e9da08f..69786306181 100644 --- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/BootstrapWithTestInterface.java +++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/BootstrapWithTestInterface.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,7 +19,6 @@ package org.springframework.test.context.configuration.interfaces; import java.util.List; import org.springframework.test.context.BootstrapWith; -import org.springframework.test.context.ContextCustomizer; import org.springframework.test.context.ContextCustomizerFactory; import org.springframework.test.context.configuration.interfaces.BootstrapWithTestInterface.CustomTestContextBootstrapper; import org.springframework.test.context.support.DefaultTestContextBootstrapper; @@ -38,9 +37,8 @@ interface BootstrapWithTestInterface { @Override protected List getContextCustomizerFactories() { - return singletonList( - (ContextCustomizerFactory) (testClass, configAttributes) -> (ContextCustomizer) (context, - mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo")); + return singletonList((testClass, configAttributes) -> + (context,mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo")); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationComposedAnnotationTests.java b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationComposedAnnotationTests.java index ba692dcef69..0ee0432e13a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationComposedAnnotationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationComposedAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 6.1 */ -@SpringJUnitConfig({}) +@SpringJUnitConfig @CustomizeWithFruit @CustomizeWithFoo @CustomizeWithBar diff --git a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationTests.java b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationTests.java index eee46f4d9c6..93d33fc0065 100644 --- a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerDeclarativeRegistrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 6.1 */ -@SpringJUnitConfig({}) +@SpringJUnitConfig @CustomizeWithFruit @CustomizeWithFoo @ContextCustomizerFactories(EnigmaContextCustomizerFactory.class) diff --git a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerTests.java b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerTests.java index 757e632231a..83b741d25ed 100644 --- a/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/customizers/ContextCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @since 4.3 */ -@SpringJUnitConfig({}) +@SpringJUnitConfig @CustomizeWithFoo @BootstrapWith(EnigmaTestContextBootstrapper.class) @CustomizeWithBar diff --git a/spring-test/src/test/java/org/springframework/test/context/customizers/LocalContextCustomizerRegistrationTests.java b/spring-test/src/test/java/org/springframework/test/context/customizers/LocalContextCustomizerRegistrationTests.java index d02d463a22f..3014200b046 100644 --- a/spring-test/src/test/java/org/springframework/test/context/customizers/LocalContextCustomizerRegistrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/customizers/LocalContextCustomizerRegistrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 6.1 */ -@SpringJUnitConfig({}) +@SpringJUnitConfig @CustomizeWithFruit @CustomizeWithFoo class LocalContextCustomizerRegistrationTests { diff --git a/spring-test/src/test/java/org/springframework/test/context/customizers/ReplaceDefaultsContextCustomizerTests.java b/spring-test/src/test/java/org/springframework/test/context/customizers/ReplaceDefaultsContextCustomizerTests.java index 7fee221e103..ba4215e215f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/customizers/ReplaceDefaultsContextCustomizerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/customizers/ReplaceDefaultsContextCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 6.1 */ -@SpringJUnitConfig({}) +@SpringJUnitConfig @ContextCustomizerFactories(factories = {FooContextCustomizerFactory.class, BarContextCustomizerFactory.class}, mergeMode = MergeMode.REPLACE_DEFAULTS) class ReplaceDefaultsContextCustomizerTests { diff --git a/spring-test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java b/spring-test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java index c7a17fe3fef..6457afdec36 100644 --- a/spring-test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class ExpressionUsageTests { @Test - void testSpr5906() throws Exception { + void testSpr5906() { // verify the property values have been evaluated as expressions assertThat(props.getProperty("user.name")).isEqualTo("Dave"); assertThat(props.getProperty("username")).isEqualTo("Andy"); @@ -60,7 +60,7 @@ class ExpressionUsageTests { } @Test - void testSpr5847() throws Exception { + void testSpr5847() { assertThat(andy2.getName()).isEqualTo("Andy"); assertThat(andy.getName()).isEqualTo("Andy"); } diff --git a/spring-test/src/test/java/org/springframework/test/context/failures/TrackingApplicationContextFailureProcessor.java b/spring-test/src/test/java/org/springframework/test/context/failures/TrackingApplicationContextFailureProcessor.java index 45421e0c63a..09e729f2e72 100644 --- a/spring-test/src/test/java/org/springframework/test/context/failures/TrackingApplicationContextFailureProcessor.java +++ b/spring-test/src/test/java/org/springframework/test/context/failures/TrackingApplicationContextFailureProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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.test.context.ApplicationContextFailureProcessor; */ public class TrackingApplicationContextFailureProcessor implements ApplicationContextFailureProcessor { - public static List loadFailures = Collections.synchronizedList(new ArrayList<>()); + public static final List loadFailures = Collections.synchronizedList(new ArrayList<>()); @Override diff --git a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java index aa713d62c59..02997ff5bbb 100644 --- a/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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.assertj.core.api.Assertions.assertThat; class GroovyControlGroupTests { @Test - @SuppressWarnings("resource") void verifyScriptUsingGenericGroovyApplicationContext() { ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy"); diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/MergedSqlConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/MergedSqlConfigTests.java index 5643d880cf3..61ef5fe60ca 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/MergedSqlConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/MergedSqlConfigTests.java @@ -157,7 +157,7 @@ class MergedSqlConfigTests { } @Test - void globalConfigWithEmptyCommentPrefix() throws Exception { + void globalConfigWithEmptyCommentPrefix() { SqlConfig sqlConfig = GlobalConfigWithWithEmptyCommentPrefixClass.class.getAnnotation(SqlConfig.class); assertThatIllegalArgumentException() @@ -166,7 +166,7 @@ class MergedSqlConfigTests { } @Test - void globalConfigWithEmptyCommentPrefixes() throws Exception { + void globalConfigWithEmptyCommentPrefixes() { SqlConfig sqlConfig = GlobalConfigWithWithEmptyCommentPrefixesClass.class.getAnnotation(SqlConfig.class); assertThatIllegalArgumentException() @@ -175,7 +175,7 @@ class MergedSqlConfigTests { } @Test - void globalConfigWithDuplicatedCommentPrefixes() throws Exception { + void globalConfigWithDuplicatedCommentPrefixes() { SqlConfig sqlConfig = GlobalConfigWithWithDuplicatedCommentPrefixesClass.class.getAnnotation(SqlConfig.class); assertThatIllegalArgumentException() diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java index 1bbcd211b57..38dd0f77513 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java @@ -135,7 +135,7 @@ class SqlScriptsTestExecutionListenerTests { .withMessage("@SQL execution phase AFTER_TEST_CLASS cannot be used on methods"); } - private void assertExceptionContains(String msg) throws Exception { + private void assertExceptionContains(String msg) { assertThatIllegalStateException() .isThrownBy(() -> listener.beforeTestMethod(testContext)) .withMessageContaining(msg); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfAndDirtiesContextTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfAndDirtiesContextTests.java index 007ab98660f..44e2c565d42 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfAndDirtiesContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfAndDirtiesContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass */ class DisabledIfAndDirtiesContextTests { - private static AtomicBoolean contextClosed = new AtomicBoolean(); + private static final AtomicBoolean contextClosed = new AtomicBoolean(); @BeforeEach diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfAndDirtiesContextTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfAndDirtiesContextTests.java index 1cbe48b8a60..9e105aa0706 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfAndDirtiesContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfAndDirtiesContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass */ class EnabledIfAndDirtiesContextTests { - private static AtomicBoolean contextClosed = new AtomicBoolean(); + private static final AtomicBoolean contextClosed = new AtomicBoolean(); @BeforeEach diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java index c5f0fec9027..89df44bb8ae 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,7 +135,7 @@ class FailingBeforeAndAfterMethodsSpringExtensionTests { private static class AlwaysFailingPrepareTestInstanceTestExecutionListener implements TestExecutionListener { @Override - public void prepareTestInstance(TestContext testContext) throws Exception { + public void prepareTestInstance(TestContext testContext) { fail("always failing prepareTestInstance()"); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ConstructorInjectionNestedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ConstructorInjectionNestedTests.java index 61be8f3b961..a6e3aa3b1bc 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ConstructorInjectionNestedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ConstructorInjectionNestedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class ConstructorInjectionNestedTests { } @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(foo).isEqualTo("foo"); assertThat(bar).isEqualTo("bar"); } @@ -87,7 +87,7 @@ class ConstructorInjectionNestedTests { } @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(foo).isEqualTo("foo"); assertThat(bar).isEqualTo("bar"); } @@ -104,7 +104,7 @@ class ConstructorInjectionNestedTests { } @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(foo).isEqualTo("foo"); assertThat(bar).isEqualTo("bar"); } @@ -123,7 +123,7 @@ class ConstructorInjectionNestedTests { } @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(foo).isEqualTo("foo"); assertThat(bar).isEqualTo("bar"); assertThat(answer).isEqualTo(42); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ContextHierarchyNestedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ContextHierarchyNestedTests.java index af6f5f23864..21809f1ac92 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ContextHierarchyNestedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/ContextHierarchyNestedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class ContextHierarchyNestedTests { @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(this.context).as("local ApplicationContext").isNotNull(); assertThat(this.context.getParent()).as("parent ApplicationContext").isNull(); @@ -107,7 +107,7 @@ class ContextHierarchyNestedTests { @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(this.context).as("local ApplicationContext").isNotNull(); assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull(); @@ -135,7 +135,7 @@ class ContextHierarchyNestedTests { @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(this.context).as("local ApplicationContext").isNotNull(); assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull(); @@ -160,7 +160,7 @@ class ContextHierarchyNestedTests { @Test - void nestedTest() throws Exception { + void nestedTest() { assertThat(this.context).as("local ApplicationContext").isNotNull(); assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull(); assertThat(this.context.getParent().getParent()).as("grandparent ApplicationContext").isNotNull(); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DynamicPropertySourceNestedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DynamicPropertySourceNestedTests.java index 4ee76a80b22..04a3340ac3c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DynamicPropertySourceNestedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DynamicPropertySourceNestedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class DynamicPropertySourceNestedTests { private static final String TEST_CONTAINER_PORT = "DynamicPropertySourceNestedTests.test.container.port"; - static DemoContainer container = new DemoContainer(); + static final DemoContainer container = new DemoContainer(); @DynamicPropertySource static void containerProperties(DynamicPropertyRegistry registry) { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java b/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java index 75643a19c04..eaefadc1a80 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ public class JUnitTestingUtils { */ public static void runTestsAndAssertCounters(Computer computer, int expectedStartedCount, int expectedFailedCount, int expectedFinishedCount, int expectedIgnoredCount, int expectedAssumptionFailedCount, - Class... testClasses) throws Exception { + Class... testClasses) { JUnitCore junit = new JUnitCore(); TrackingRunListener listener = new TrackingRunListener(); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java index c5b4a438d91..10308ff18ae 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java @@ -16,7 +16,6 @@ package org.springframework.test.context.junit4; -import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.concurrent.atomic.AtomicInteger; @@ -99,7 +98,7 @@ public class RepeatedSpringRunnerTests { @TestExecutionListeners({}) public abstract static class AbstractRepeatedTestCase { - protected void incrementInvocationCount() throws IOException { + protected void incrementInvocationCount() { invocationCount.incrementAndGet(); } } @@ -108,7 +107,7 @@ public class RepeatedSpringRunnerTests { @Test @Timed(millis = 10000) - public void nonAnnotated() throws Exception { + public void nonAnnotated() { incrementInvocationCount(); } } @@ -118,7 +117,7 @@ public class RepeatedSpringRunnerTests { @Test @Repeat @Timed(millis = 10000) - public void defaultRepeatValue() throws Exception { + public void defaultRepeatValue() { incrementInvocationCount(); } } @@ -128,7 +127,7 @@ public class RepeatedSpringRunnerTests { @Test @Repeat(-5) @Timed(millis = 10000) - public void negativeRepeatValue() throws Exception { + public void negativeRepeatValue() { incrementInvocationCount(); } } @@ -137,7 +136,7 @@ public class RepeatedSpringRunnerTests { @Test @Repeat(5) - public void repeatedFiveTimes() throws Exception { + public void repeatedFiveTimes() { incrementInvocationCount(); } } @@ -151,7 +150,7 @@ public class RepeatedSpringRunnerTests { @Test @RepeatedFiveTimes - public void repeatedFiveTimes() throws Exception { + public void repeatedFiveTimes() { incrementInvocationCount(); } } @@ -165,7 +164,7 @@ public class RepeatedSpringRunnerTests { @Test @Timed(millis = 1000) @Repeat(5) - public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception { + public void repeatedFiveTimesButDoesNotExceedTimeout() { incrementInvocationCount(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java index ca6e43e9bc0..4bbc906dd00 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAwa /** * Default resource path for the application context configuration for - * {@link SpringJUnit4ClassRunnerAppCtxTests}: {@value #DEFAULT_CONTEXT_RESOURCE_PATH} + * {@link SpringJUnit4ClassRunnerAppCtxTests}: {@value} */ public static final String DEFAULT_CONTEXT_RESOURCE_PATH = "/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml"; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/TrackingRunListener.java b/spring-test/src/test/java/org/springframework/test/context/junit4/TrackingRunListener.java index 89607794f54..808f8c83786 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/TrackingRunListener.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/TrackingRunListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2024 the original author 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,17 +63,17 @@ public class TrackingRunListener extends RunListener { } @Override - public void testFailure(Failure failure) throws Exception { + public void testFailure(Failure failure) { this.testFailureCount.incrementAndGet(); } @Override - public void testStarted(Description description) throws Exception { + public void testStarted(Description description) { this.testStartedCount.incrementAndGet(); } @Override - public void testFinished(Description description) throws Exception { + public void testFinished(Description description) { this.testFinishedCount.incrementAndGet(); } @@ -83,7 +83,7 @@ public class TrackingRunListener extends RunListener { } @Override - public void testIgnored(Description description) throws Exception { + public void testIgnored(Description description) { this.testIgnoredCount.incrementAndGet(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoaderTests.java index 6ebd008b74f..1ef7a18c09f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class HybridContextLoaderTests { // Note: the XML bean definition for "enigma" always wins since // ConfigurationClassBeanDefinitionReader.isOverriddenByExistingDefinition() - // lets XML bean definitions override those "discovered" later via an + // lets XML bean definitions override those "discovered" later via a // @Bean method. assertThat(enigma).isEqualTo("enigma from XML"); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java index 9ad8a979ce4..9521097a72b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class NestedTestsWithSpringRulesTests extends SpringRuleConfigurer { @Test - public void nestedTest() throws Exception { + public void nestedTest() { assertThat(foo).isEqualTo("foo"); assertThat(bar).isEqualTo("bar"); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java index 5919bb6f152..54f2177dc95 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp } @Test - public void updateSamWithNullDriversLicenseWithSessionFlush() throws Throwable { + public void updateSamWithNullDriversLicenseWithSessionFlush() { updateSamWithNullDriversLicense(); assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(() -> { // Manual flush is required to avoid false positive in test diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/RepeatedSpringRuleTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/RepeatedSpringRuleTests.java index 96fb617c432..5d3441b2076 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/rules/RepeatedSpringRuleTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/rules/RepeatedSpringRuleTests.java @@ -16,7 +16,6 @@ package org.springframework.test.context.junit4.rules; -import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -79,7 +78,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { public final SpringMethodRule springMethodRule = new SpringMethodRule(); - protected void incrementInvocationCount() throws IOException { + protected void incrementInvocationCount() { invocationCount.incrementAndGet(); } } @@ -88,7 +87,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @Timed(millis = 10000) - public void nonAnnotated() throws Exception { + public void nonAnnotated() { incrementInvocationCount(); } } @@ -98,7 +97,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @Repeat @Timed(millis = 10000) - public void defaultRepeatValue() throws Exception { + public void defaultRepeatValue() { incrementInvocationCount(); } } @@ -108,7 +107,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @Repeat(-5) @Timed(millis = 10000) - public void negativeRepeatValue() throws Exception { + public void negativeRepeatValue() { incrementInvocationCount(); } } @@ -117,7 +116,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @Repeat(5) - public void repeatedFiveTimes() throws Exception { + public void repeatedFiveTimes() { incrementInvocationCount(); } } @@ -131,7 +130,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @RepeatedFiveTimes - public void repeatedFiveTimes() throws Exception { + public void repeatedFiveTimes() { incrementInvocationCount(); } } @@ -145,7 +144,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests { @Test @Timed(millis = 1000) @Repeat(5) - public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception { + public void repeatedFiveTimesButDoesNotExceedTimeout() { incrementInvocationCount(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr4868/Jsr250LifecycleTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr4868/Jsr250LifecycleTests.java index 634859211e2..cc2c82c966f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr4868/Jsr250LifecycleTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr4868/Jsr250LifecycleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +99,7 @@ public class Jsr250LifecycleTests { } @After - public void tearDown() throws Exception { + public void tearDown() { logger.info("tearDown()"); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/Spr8849Tests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/Spr8849Tests.java index b6429d9ff4e..707c726535d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/Spr8849Tests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/Spr8849Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2024 the original author 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 org.junit.runners.Suite.SuiteClasses; * @author Sam Brannen * @since 3.2 */ -@SuppressWarnings("javadoc") @RunWith(Suite.class) @SuiteClasses({ TestClass1.class, TestClass2.class, TestClass3.class, TestClass4.class }) public class Spr8849Tests { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java index e31eb93fbf1..6489efd4a09 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AbstractTransactionalAnnotatedConfigClassTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ public abstract class AbstractTransactionalAnnotatedConfigClassTests { } @After - public void tearDown() throws Exception { + public void tearDown() { assertNumRowsInPersonTable((isActualTransactionActive() ? 3 : 0), "after a test method"); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java index aa70c7c3e02..523c6c06eae 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public class AnnotatedConfigClassesWithoutAtConfigurationTests { @Test - public void testSPR_9051() throws Exception { + public void testSPR_9051() { assertThat(enigma).isNotNull(); assertThat(lifecycleBean).isNotNull(); assertThat(lifecycleBean.isInitialized()).isTrue(); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java index 12fa85b6039..3a8df08203d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassWithAtConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class TransactionalAnnotatedConfigClassWithAtConfigurationTests extends @Before - public void compareDataSources() throws Exception { + public void compareDataSources() { // NOTE: the two DataSource instances ARE the same! assertThat(dataSourceViaInjection).isSameAs(dataSourceFromTxManager); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java index 2be7df70041..e13dd93c80a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests exte @Before - public void compareDataSources() throws Exception { + public void compareDataSources() { // NOTE: the two DataSource instances are NOT the same! assertThat(dataSourceViaInjection).isNotSameAs(dataSourceFromTxManager); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java index af6ed48bcb8..4a8481f33b4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java @@ -42,13 +42,13 @@ public class SpringFailOnTimeoutTests { @Test - public void nullNextStatement() throws Throwable { + public void nullNextStatement() { assertThatIllegalArgumentException().isThrownBy(() -> new SpringFailOnTimeout(null, 1)); } @Test - public void negativeTimeout() throws Throwable { + public void negativeTimeout() { assertThatIllegalArgumentException().isThrownBy(() -> new SpringFailOnTimeout(statement, -1)); } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java index 0842f691742..21d308d70c4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ abstract class AbstractContextConfigurationUtilsTests { static final String[] EMPTY_STRING_ARRAY = new String[0]; static final Set>> - EMPTY_INITIALIZER_CLASSES = Collections.>> emptySet(); + EMPTY_INITIALIZER_CLASSES = Collections.emptySet(); MergedContextConfiguration buildMergedContextConfiguration(Class testClass) { diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java index f72f884d35b..45dc4b47fab 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java @@ -79,12 +79,10 @@ class AnnotationConfigContextLoaderTests { AnnotatedFooConfigInnerClassTestCase.class, EMPTY_STRING_ARRAY, new Class[] {AnnotatedFooConfigInnerClassTestCase.FooConfig.class}, EMPTY_STRING_ARRAY, contextLoader); - ApplicationContext context = contextLoader.loadContextForAotProcessing(mergedConfig); - assertThat(context).isInstanceOf(ConfigurableApplicationContext.class); - ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context; - assertThat(cac.isActive()).as("ApplicationContext is active").isFalse(); + ConfigurableApplicationContext context = contextLoader.loadContextForAotProcessing(mergedConfig); + assertThat(context.isActive()).as("ApplicationContext is active").isFalse(); assertThat(Arrays.stream(context.getBeanDefinitionNames())).anyMatch(name -> name.contains("FooConfig")); - cac.close(); + context.close(); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java index 14553baf40f..4da0bd8a3cd 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java @@ -99,12 +99,12 @@ class DelegatingSmartContextLoaderTests { } @Test - void loadContextWithNullConfig() throws Exception { + void loadContextWithNullConfig() { assertThatIllegalArgumentException().isThrownBy(() -> loader.loadContext((MergedContextConfiguration) null)); } @Test - void loadContextWithoutLocationsAndConfigurationClasses() throws Exception { + void loadContextWithoutLocationsAndConfigurationClasses() { MergedContextConfiguration mergedConfig = new MergedContextConfiguration( getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertThatIllegalStateException() @@ -117,7 +117,7 @@ class DelegatingSmartContextLoaderTests { * @since 4.1 */ @Test - void loadContextWithLocationsAndConfigurationClasses() throws Exception { + void loadContextWithLocationsAndConfigurationClasses() { MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), new String[] {"test.xml"}, new Class[] {getClass()}, EMPTY_STRING_ARRAY, loader); assertThatIllegalStateException() diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java index f6b2a97177c..649c041cb04 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java @@ -325,7 +325,7 @@ class DirtiesContextTestExecutionListenerTests { verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE); } - private void assertAfterMethod(Class clazz) throws NoSuchMethodException, Exception { + private void assertAfterMethod(Class clazz) throws Exception { BDDMockito.> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("test")); beforeListener.beforeTestMethod(testContext); diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizerTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizerTests.java index 6d1d974fa8b..2ce3ad76dcf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/DynamicPropertiesContextCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class DynamicPropertiesContextCustomizerTests { } @Test - void nullPropertyNameResultsInException() throws Exception { + void nullPropertyNameResultsInException() { DynamicPropertiesContextCustomizer customizer = customizerFor("nullName"); ConfigurableApplicationContext context = new StaticApplicationContext(); assertThatIllegalArgumentException() @@ -67,7 +67,7 @@ class DynamicPropertiesContextCustomizerTests { } @Test - void emptyPropertyNameResultsInException() throws Exception { + void emptyPropertyNameResultsInException() { DynamicPropertiesContextCustomizer customizer = customizerFor("emptyName"); ConfigurableApplicationContext context = new StaticApplicationContext(); assertThatIllegalArgumentException() @@ -76,7 +76,7 @@ class DynamicPropertiesContextCustomizerTests { } @Test - void nullValueSupplierResultsInException() throws Exception { + void nullValueSupplierResultsInException() { DynamicPropertiesContextCustomizer customizer = customizerFor("nullValueSupplier"); ConfigurableApplicationContext context = new StaticApplicationContext(); assertThatIllegalArgumentException() @@ -85,7 +85,7 @@ class DynamicPropertiesContextCustomizerTests { } @Test - void customizeContextAddsPropertySource() throws Exception { + void customizeContextAddsPropertySource() { ConfigurableApplicationContext context = new StaticApplicationContext(); DynamicPropertiesContextCustomizer customizer = customizerFor("valid1", "valid2"); customizer.customizeContext(context, mock()); diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DynamicValuesPropertySourceTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DynamicValuesPropertySourceTests.java index e408a7fa55b..065486b2a27 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/DynamicValuesPropertySourceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/DynamicValuesPropertySourceTests.java @@ -30,19 +30,18 @@ import static org.assertj.core.api.Assertions.assertThat; */ class DynamicValuesPropertySourceTests { - @SuppressWarnings("serial") private final DynamicValuesPropertySource source = new DynamicValuesPropertySource("test", Map.of("a", () -> "A", "b", () -> "B")); @Test - void getPropertyReturnsSuppliedProperty() throws Exception { + void getPropertyReturnsSuppliedProperty() { assertThat(this.source.getProperty("a")).isEqualTo("A"); assertThat(this.source.getProperty("b")).isEqualTo("B"); } @Test - void getPropertyWhenMissingReturnsNull() throws Exception { + void getPropertyWhenMissingReturnsNull() { assertThat(this.source.getProperty("c")).isNull(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java index 39367e05714..af36e79fb8f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class GenericXmlContextLoaderResourceLocationsTests { @ParameterizedTest(name = "[{index}] {0}") @MethodSource("contextConfigurationLocationsData") - void assertContextConfigurationLocations(Class testClass, String[] expectedLocations) throws Exception { + void assertContextConfigurationLocations(Class testClass, String[] expectedLocations) { ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class); String[] configuredLocations = contextConfig.value(); ContextConfigurationAttributes configAttributes = diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java index 3411c213dff..aa3f66cecd3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java @@ -35,7 +35,7 @@ class GenericXmlContextLoaderTests { @Test - void configMustNotContainAnnotatedClasses() throws Exception { + void configMustNotContainAnnotatedClasses() { GenericXmlContextLoader loader = new GenericXmlContextLoader(); MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, new Class[] { getClass() }, EMPTY_STRING_ARRAY, loader); diff --git a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java index d642eeddc25..111bfff0d56 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java @@ -184,7 +184,7 @@ class TestPropertySourceUtilsTests { @Test void addPropertiesFilesToEnvironmentWithNullContext() { assertThatIllegalArgumentException() - .isThrownBy(() -> addPropertiesFilesToEnvironment((ConfigurableApplicationContext) null, FOO_LOCATIONS)) + .isThrownBy(() -> addPropertiesFilesToEnvironment(null, FOO_LOCATIONS)) .withMessageContaining("'context' must not be null"); } @@ -198,7 +198,7 @@ class TestPropertySourceUtilsTests { @Test void addPropertiesFilesToEnvironmentWithNullEnvironment() { assertThatIllegalArgumentException() - .isThrownBy(() -> addPropertiesFilesToEnvironment((ConfigurableEnvironment) null, mock(), FOO_LOCATIONS)) + .isThrownBy(() -> addPropertiesFilesToEnvironment(null, mock(), FOO_LOCATIONS)) .withMessageContaining("'environment' must not be null"); } @@ -287,7 +287,6 @@ class TestPropertySourceUtilsTests { } @Test - @SuppressWarnings("rawtypes") void addInlinedPropertiesToEnvironmentWithEmptyProperty() { ConfigurableEnvironment environment = new MockEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); @@ -296,8 +295,8 @@ class TestPropertySourceUtilsTests { addInlinedPropertiesToEnvironment(environment, " "); assertThat(propertySources).hasSize(1); PropertySource propertySource = propertySources.get(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME); - assertThat(propertySource).isInstanceOf(MapPropertySource.class); - assertThat(((MapPropertySource) propertySource).getSource()).isEmpty(); + assertThat(propertySource).isInstanceOfSatisfying(MapPropertySource.class, + mps -> assertThat(mps.getSource()).isEmpty()); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java index b4270bff7bc..05084bd07ab 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java @@ -127,7 +127,7 @@ class AnnotationConfigTransactionalTestNGSpringContextTests } @BeforeMethod - void setUp() throws Exception { + void setUp() { numSetUpCalls++; if (isActualTransactionActive()) { numSetUpCallsInTransaction++; @@ -144,7 +144,7 @@ class AnnotationConfigTransactionalTestNGSpringContextTests } @AfterMethod - void tearDown() throws Exception { + void tearDown() { numTearDownCalls++; if (isActualTransactionActive()) { numTearDownCallsInTransaction++; diff --git a/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java index 17f42f1cee7..b79e3902804 100644 --- a/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java @@ -32,7 +32,7 @@ class GenericXmlWebContextLoaderTests { @Test - void configMustNotContainAnnotatedClasses() throws Exception { + void configMustNotContainAnnotatedClasses() { GenericXmlWebContextLoader loader = new GenericXmlWebContextLoader(); @SuppressWarnings("deprecation") WebMergedContextConfiguration mergedConfig = new WebMergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, diff --git a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java index 70568f3e78b..1247484fda0 100644 --- a/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/web/RequestAndSessionScopedBeansWacTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ class RequestAndSessionScopedBeansWacTests { @Test - void requestScope() throws Exception { + void requestScope() { String beanName = "requestScopedTestBean"; String contextPath = "/path"; @@ -63,7 +63,7 @@ class RequestAndSessionScopedBeansWacTests { } @Test - void sessionScope() throws Exception { + void sessionScope() { String beanName = "sessionScopedTestBean"; assertThat(session.getAttribute(beanName)).isNull(); diff --git a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java index 8a768af66e6..e03f9d415dc 100644 --- a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java @@ -56,27 +56,27 @@ class JsonPathExpectationsHelperTests { @Test - void exists() throws Exception { + void exists() { new JsonPathExpectationsHelper("$.str").exists(CONTENT); } @Test - void existsForAnEmptyArray() throws Exception { + void existsForAnEmptyArray() { new JsonPathExpectationsHelper("$.emptyArray").exists(CONTENT); } @Test - void existsForAnEmptyMap() throws Exception { + void existsForAnEmptyMap() { new JsonPathExpectationsHelper("$.emptyMap").exists(CONTENT); } @Test - void existsForIndefinitePathWithResults() throws Exception { + void existsForIndefinitePathWithResults() { new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Bart')]").exists(SIMPSONS); } @Test - void existsForIndefinitePathWithEmptyResults() throws Exception { + void existsForIndefinitePathWithEmptyResults() { String expression = "$.familyMembers[?(@.name == 'Dilbert')]"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).exists(SIMPSONS)) @@ -84,12 +84,12 @@ class JsonPathExpectationsHelperTests { } @Test - void doesNotExist() throws Exception { + void doesNotExist() { new JsonPathExpectationsHelper("$.bogus").doesNotExist(CONTENT); } @Test - void doesNotExistForAnEmptyArray() throws Exception { + void doesNotExistForAnEmptyArray() { String expression = "$.emptyArray"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT)) @@ -97,7 +97,7 @@ class JsonPathExpectationsHelperTests { } @Test - void doesNotExistForAnEmptyMap() throws Exception { + void doesNotExistForAnEmptyMap() { String expression = "$.emptyMap"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT)) @@ -105,7 +105,7 @@ class JsonPathExpectationsHelperTests { } @Test - void doesNotExistForIndefinitePathWithResults() throws Exception { + void doesNotExistForIndefinitePathWithResults() { String expression = "$.familyMembers[?(@.name == 'Bart')]"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).doesNotExist(SIMPSONS)) @@ -113,32 +113,32 @@ class JsonPathExpectationsHelperTests { } @Test - void doesNotExistForIndefinitePathWithEmptyResults() throws Exception { + void doesNotExistForIndefinitePathWithEmptyResults() { new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Dilbert')]").doesNotExist(SIMPSONS); } @Test - void assertValueIsEmptyForAnEmptyString() throws Exception { + void assertValueIsEmptyForAnEmptyString() { new JsonPathExpectationsHelper("$.emptyString").assertValueIsEmpty(CONTENT); } @Test - void assertValueIsEmptyForAnEmptyArray() throws Exception { + void assertValueIsEmptyForAnEmptyArray() { new JsonPathExpectationsHelper("$.emptyArray").assertValueIsEmpty(CONTENT); } @Test - void assertValueIsEmptyForAnEmptyMap() throws Exception { + void assertValueIsEmptyForAnEmptyMap() { new JsonPathExpectationsHelper("$.emptyMap").assertValueIsEmpty(CONTENT); } @Test - void assertValueIsEmptyForIndefinitePathWithEmptyResults() throws Exception { + void assertValueIsEmptyForIndefinitePathWithEmptyResults() { new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Dilbert')]").assertValueIsEmpty(SIMPSONS); } @Test - void assertValueIsEmptyForIndefinitePathWithResults() throws Exception { + void assertValueIsEmptyForIndefinitePathWithResults() { String expression = "$.familyMembers[?(@.name == 'Bart')]"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsEmpty(SIMPSONS)) @@ -146,7 +146,7 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsEmptyForWhitespace() throws Exception { + void assertValueIsEmptyForWhitespace() { String expression = "$.whitespace"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsEmpty(CONTENT)) @@ -154,37 +154,37 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsNotEmptyForString() throws Exception { + void assertValueIsNotEmptyForString() { new JsonPathExpectationsHelper("$.str").assertValueIsNotEmpty(CONTENT); } @Test - void assertValueIsNotEmptyForNumber() throws Exception { + void assertValueIsNotEmptyForNumber() { new JsonPathExpectationsHelper("$.num").assertValueIsNotEmpty(CONTENT); } @Test - void assertValueIsNotEmptyForBoolean() throws Exception { + void assertValueIsNotEmptyForBoolean() { new JsonPathExpectationsHelper("$.bool").assertValueIsNotEmpty(CONTENT); } @Test - void assertValueIsNotEmptyForArray() throws Exception { + void assertValueIsNotEmptyForArray() { new JsonPathExpectationsHelper("$.arr").assertValueIsNotEmpty(CONTENT); } @Test - void assertValueIsNotEmptyForMap() throws Exception { + void assertValueIsNotEmptyForMap() { new JsonPathExpectationsHelper("$.colorMap").assertValueIsNotEmpty(CONTENT); } @Test - void assertValueIsNotEmptyForIndefinitePathWithResults() throws Exception { + void assertValueIsNotEmptyForIndefinitePathWithResults() { new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Bart')]").assertValueIsNotEmpty(SIMPSONS); } @Test - void assertValueIsNotEmptyForIndefinitePathWithEmptyResults() throws Exception { + void assertValueIsNotEmptyForIndefinitePathWithEmptyResults() { String expression = "$.familyMembers[?(@.name == 'Dilbert')]"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(SIMPSONS)) @@ -192,7 +192,7 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsNotEmptyForAnEmptyString() throws Exception { + void assertValueIsNotEmptyForAnEmptyString() { String expression = "$.emptyString"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT)) @@ -200,7 +200,7 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsNotEmptyForAnEmptyArray() throws Exception { + void assertValueIsNotEmptyForAnEmptyArray() { String expression = "$.emptyArray"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT)) @@ -208,7 +208,7 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsNotEmptyForAnEmptyMap() throws Exception { + void assertValueIsNotEmptyForAnEmptyMap() { String expression = "$.emptyMap"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT)) @@ -263,32 +263,32 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValue() throws Exception { + void assertValue() { new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5); } @Test // SPR-14498 - void assertValueWithNumberConversion() throws Exception { + void assertValueWithNumberConversion() { new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5.0); } @Test // SPR-14498 - void assertValueWithNumberConversionAndMatcher() throws Exception { + void assertValueWithNumberConversionAndMatcher() { new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, is(5.0), Double.class); } @Test - void assertValueIsString() throws Exception { + void assertValueIsString() { new JsonPathExpectationsHelper("$.str").assertValueIsString(CONTENT); } @Test - void assertValueIsStringForAnEmptyString() throws Exception { + void assertValueIsStringForAnEmptyString() { new JsonPathExpectationsHelper("$.emptyString").assertValueIsString(CONTENT); } @Test - void assertValueIsStringForNonString() throws Exception { + void assertValueIsStringForNonString() { String expression = "$.bool"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsString(CONTENT)) @@ -296,12 +296,12 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsNumber() throws Exception { + void assertValueIsNumber() { new JsonPathExpectationsHelper("$.num").assertValueIsNumber(CONTENT); } @Test - void assertValueIsNumberForNonNumber() throws Exception { + void assertValueIsNumberForNonNumber() { String expression = "$.bool"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsNumber(CONTENT)) @@ -309,12 +309,12 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsBoolean() throws Exception { + void assertValueIsBoolean() { new JsonPathExpectationsHelper("$.bool").assertValueIsBoolean(CONTENT); } @Test - void assertValueIsBooleanForNonBoolean() throws Exception { + void assertValueIsBooleanForNonBoolean() { String expression = "$.num"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsBoolean(CONTENT)) @@ -322,17 +322,17 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsArray() throws Exception { + void assertValueIsArray() { new JsonPathExpectationsHelper("$.arr").assertValueIsArray(CONTENT); } @Test - void assertValueIsArrayForAnEmptyArray() throws Exception { + void assertValueIsArrayForAnEmptyArray() { new JsonPathExpectationsHelper("$.emptyArray").assertValueIsArray(CONTENT); } @Test - void assertValueIsArrayForNonArray() throws Exception { + void assertValueIsArrayForNonArray() { String expression = "$.str"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsArray(CONTENT)) @@ -340,17 +340,17 @@ class JsonPathExpectationsHelperTests { } @Test - void assertValueIsMap() throws Exception { + void assertValueIsMap() { new JsonPathExpectationsHelper("$.colorMap").assertValueIsMap(CONTENT); } @Test - void assertValueIsMapForAnEmptyMap() throws Exception { + void assertValueIsMapForAnEmptyMap() { new JsonPathExpectationsHelper("$.emptyMap").assertValueIsMap(CONTENT); } @Test - void assertValueIsMapForNonMap() throws Exception { + void assertValueIsMapForNonMap() { String expression = "$.str"; assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathExpectationsHelper(expression).assertValueIsMap(CONTENT)) diff --git a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java index b043d95adb5..b8b95cc93b4 100644 --- a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java @@ -62,61 +62,61 @@ class ReflectionTestUtilsTests { } @Test - void setFieldWithNullTargetObject() throws Exception { + void setFieldWithNullTargetObject() { assertThatIllegalArgumentException() .isThrownBy(() -> setField((Object) null, "id", 99L)) .withMessageStartingWith("Either targetObject or targetClass"); } @Test - void getFieldWithNullTargetObject() throws Exception { + void getFieldWithNullTargetObject() { assertThatIllegalArgumentException() .isThrownBy(() -> getField((Object) null, "id")) .withMessageStartingWith("Either targetObject or targetClass"); } @Test - void setFieldWithNullTargetClass() throws Exception { + void setFieldWithNullTargetClass() { assertThatIllegalArgumentException() - .isThrownBy(() -> setField((Class) null, "id", 99L)) + .isThrownBy(() -> setField(null, "id", 99L)) .withMessageStartingWith("Either targetObject or targetClass"); } @Test - void getFieldWithNullTargetClass() throws Exception { + void getFieldWithNullTargetClass() { assertThatIllegalArgumentException() - .isThrownBy(() -> getField((Class) null, "id")) + .isThrownBy(() -> getField(null, "id")) .withMessageStartingWith("Either targetObject or targetClass"); } @Test - void setFieldWithNullNameAndNullType() throws Exception { + void setFieldWithNullNameAndNullType() { assertThatIllegalArgumentException() .isThrownBy(() -> setField(person, null, 99L, null)) .withMessageStartingWith("Either name or type"); } @Test - void setFieldWithBogusName() throws Exception { + void setFieldWithBogusName() { assertThatIllegalArgumentException() .isThrownBy(() -> setField(person, "bogus", 99L, long.class)) .withMessageStartingWith("Could not find field 'bogus'"); } @Test - void setFieldWithWrongType() throws Exception { + void setFieldWithWrongType() { assertThatIllegalArgumentException() .isThrownBy(() -> setField(person, "id", 99L, String.class)) .withMessageStartingWith("Could not find field"); } @Test - void setFieldAndGetFieldForStandardUseCases() throws Exception { + void setFieldAndGetFieldForStandardUseCases() { assertSetFieldAndGetFieldBehavior(this.person); } @Test - void setFieldAndGetFieldViaJdkDynamicProxy() throws Exception { + void setFieldAndGetFieldViaJdkDynamicProxy() { ProxyFactory pf = new ProxyFactory(this.person); pf.addInterface(Person.class); Person proxy = (Person) pf.getProxy(); @@ -125,7 +125,7 @@ class ReflectionTestUtilsTests { } @Test - void setFieldAndGetFieldViaCglibProxy() throws Exception { + void setFieldAndGetFieldViaCglibProxy() { ProxyFactory pf = new ProxyFactory(this.person); pf.setProxyTargetClass(true); Person proxy = (Person) pf.getProxy(); @@ -172,7 +172,7 @@ class ReflectionTestUtilsTests { } @Test - void setFieldWithNullValuesForNonPrimitives() throws Exception { + void setFieldWithNullValuesForNonPrimitives() { // Fields must be non-null to start with setField(person, "name", "Tom"); setField(person, "eyeColor", "blue", String.class); @@ -192,22 +192,22 @@ class ReflectionTestUtilsTests { } @Test - void setFieldWithNullValueForPrimitiveLong() throws Exception { + void setFieldWithNullValueForPrimitiveLong() { assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "id", null, long.class)); } @Test - void setFieldWithNullValueForPrimitiveInt() throws Exception { + void setFieldWithNullValueForPrimitiveInt() { assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "age", null, int.class)); } @Test - void setFieldWithNullValueForPrimitiveBoolean() throws Exception { + void setFieldWithNullValueForPrimitiveBoolean() { assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "likesPets", null, boolean.class)); } @Test - void setStaticFieldViaClass() throws Exception { + void setStaticFieldViaClass() { setField(StaticFields.class, "publicField", "xxx"); setField(StaticFields.class, "privateField", "yyy"); @@ -216,7 +216,7 @@ class ReflectionTestUtilsTests { } @Test - void setStaticFieldViaClassWithExplicitType() throws Exception { + void setStaticFieldViaClassWithExplicitType() { setField(StaticFields.class, "publicField", "xxx", String.class); setField(StaticFields.class, "privateField", "yyy", String.class); @@ -225,7 +225,7 @@ class ReflectionTestUtilsTests { } @Test - void setStaticFieldViaInstance() throws Exception { + void setStaticFieldViaInstance() { StaticFields staticFields = new StaticFields(); setField(staticFields, null, "publicField", "xxx", null); setField(staticFields, null, "privateField", "yyy", null); @@ -235,20 +235,20 @@ class ReflectionTestUtilsTests { } @Test - void getStaticFieldViaClass() throws Exception { + void getStaticFieldViaClass() { assertThat(getField(StaticFields.class, "publicField")).as("public static field").isEqualTo("public"); assertThat(getField(StaticFields.class, "privateField")).as("private static field").isEqualTo("private"); } @Test - void getStaticFieldViaInstance() throws Exception { + void getStaticFieldViaInstance() { StaticFields staticFields = new StaticFields(); assertThat(getField(staticFields, "publicField")).as("public static field").isEqualTo("public"); assertThat(getField(staticFields, "privateField")).as("private static field").isEqualTo("private"); } @Test - void invokeSetterMethodAndInvokeGetterMethodWithExplicitMethodNames() throws Exception { + void invokeSetterMethodAndInvokeGetterMethodWithExplicitMethodNames() { invokeSetterMethod(person, "setId", 1L, long.class); invokeSetterMethod(person, "setName", "Jerry", String.class); invokeSetterMethod(person, "setAge", 33, int.class); @@ -272,7 +272,7 @@ class ReflectionTestUtilsTests { } @Test - void invokeSetterMethodAndInvokeGetterMethodWithJavaBeanPropertyNames() throws Exception { + void invokeSetterMethodAndInvokeGetterMethodWithJavaBeanPropertyNames() { invokeSetterMethod(person, "id", 99L, long.class); invokeSetterMethod(person, "name", "Tom"); invokeSetterMethod(person, "age", 42); @@ -296,7 +296,7 @@ class ReflectionTestUtilsTests { } @Test - void invokeSetterMethodWithNullValuesForNonPrimitives() throws Exception { + void invokeSetterMethodWithNullValuesForNonPrimitives() { invokeSetterMethod(person, "name", null, String.class); invokeSetterMethod(person, "eyeColor", null, String.class); invokeSetterMethod(person, "favoriteNumber", null, Number.class); @@ -307,17 +307,17 @@ class ReflectionTestUtilsTests { } @Test - void invokeSetterMethodWithNullValueForPrimitiveLong() throws Exception { + void invokeSetterMethodWithNullValueForPrimitiveLong() { assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "id", null, long.class)); } @Test - void invokeSetterMethodWithNullValueForPrimitiveInt() throws Exception { + void invokeSetterMethodWithNullValueForPrimitiveInt() { assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "age", null, int.class)); } @Test - void invokeSetterMethodWithNullValueForPrimitiveBoolean() throws Exception { + void invokeSetterMethodWithNullValueForPrimitiveBoolean() { assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "likesPets", null, boolean.class)); } @@ -338,7 +338,6 @@ class ReflectionTestUtilsTests { @Test void invokeMethodWithPrimitiveVarArgsAsSingleArgument() { - // IntelliJ IDEA 11 won't accept int assignment here Integer sum = invokeMethod(component, "add", new int[] { 1, 2, 3, 4 }); assertThat(sum).as("add(1,2,3,4)").isEqualTo(10); } @@ -427,7 +426,7 @@ class ReflectionTestUtilsTests { @Test void invokeStaticMethodWithNullTargetClass() { assertThatIllegalArgumentException() - .isThrownBy(() -> invokeMethod((Class) null, null)) + .isThrownBy(() -> invokeMethod(null, null)) .withMessage("Target class must not be null"); } @@ -482,7 +481,7 @@ class ReflectionTestUtilsTests { @Test void invokeStaticMethodWithNullTargetObjectAndNullTargetClass() { assertThatIllegalArgumentException() - .isThrownBy(() -> invokeMethod((Object) null, (Class) null, "id")) + .isThrownBy(() -> invokeMethod(null, (Class) null, "id")) .withMessage("Either 'targetObject' or 'targetClass' for the method must be specified"); } diff --git a/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java b/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java index b67ed92c585..eae8b99b2d2 100644 --- a/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java @@ -36,7 +36,7 @@ class XmlExpectationsHelperTests { } @Test - void assertXmlEqualExceptionForIncorrectValue() throws Exception { + void assertXmlEqualExceptionForIncorrectValue() { String control = "f1f2"; String test = "notf1f2"; XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper(); @@ -54,7 +54,7 @@ class XmlExpectationsHelperTests { } @Test - void assertXmlEqualExceptionForMoreEntries() throws Exception { + void assertXmlEqualExceptionForMoreEntries() { String control = "f1f2"; String test = "f1f2f3"; XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper(); @@ -65,7 +65,7 @@ class XmlExpectationsHelperTests { } @Test - void assertXmlEqualExceptionForLessEntries() throws Exception { + void assertXmlEqualExceptionForLessEntries() { String control = "f1f2f3"; String test = "f1f2"; XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper(); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java b/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java index c8488bb9fec..9a61abd684b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java @@ -48,7 +48,7 @@ class SimpleRequestExpectationManagerTests { @Test - void unexpectedRequest() throws Exception { + void unexpectedRequest() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> this.manager.validateRequest(createRequest(GET, "/foo"))) .withMessage(""" @@ -58,7 +58,7 @@ class SimpleRequestExpectationManagerTests { } @Test - void zeroExpectedRequests() throws Exception { + void zeroExpectedRequests() { this.manager.verify(); } @@ -94,7 +94,7 @@ class SimpleRequestExpectationManagerTests { this.manager.expectRequest(min(1), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); this.manager.validateRequest(createRequest(GET, "/foo")); assertThatExceptionOfType(AssertionError.class) - .isThrownBy(() -> this.manager.verify()) + .isThrownBy(this.manager::verify) .withMessage(""" Further request(s) expected leaving 1 unsatisfied expectation(s). 1 request(s) executed: @@ -144,7 +144,7 @@ class SimpleRequestExpectationManagerTests { this.manager.validateRequest(createRequest(GET, "/bar")); this.manager.validateRequest(createRequest(GET, "/foo")); assertThatExceptionOfType(AssertionError.class) - .isThrownBy(() -> this.manager.verify()) + .isThrownBy(this.manager::verify) .withMessageContaining(""" 3 request(s) executed: GET /foo @@ -154,7 +154,7 @@ class SimpleRequestExpectationManagerTests { } @Test - void repeatedRequestsNotInOrder() throws Exception { + void repeatedRequestsNotInOrder() { this.manager.expectRequest(twice(), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess()); this.manager.expectRequest(twice(), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); this.manager.expectRequest(twice(), requestTo("/baz")).andExpect(method(GET)).andRespond(withSuccess()); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/match/ContentRequestMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/client/match/ContentRequestMatchersTests.java index dfe6c0084c1..a14b288408b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/match/ContentRequestMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/match/ContentRequestMatchersTests.java @@ -49,7 +49,7 @@ public class ContentRequestMatchersTests { } @Test - public void testContentTypeNoMatch1() throws Exception { + public void testContentTypeNoMatch1() { this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON); assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> @@ -57,7 +57,7 @@ public class ContentRequestMatchersTests { } @Test - public void testContentTypeNoMatch2() throws Exception { + public void testContentTypeNoMatch2() { this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON); assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> diff --git a/spring-test/src/test/java/org/springframework/test/web/client/match/JsonPathRequestMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/client/match/JsonPathRequestMatchersTests.java index 01d8e252906..e895a9bbc07 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/match/JsonPathRequestMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/match/JsonPathRequestMatchersTests.java @@ -58,7 +58,7 @@ public class JsonPathRequestMatchersTests { @Test - public void valueWithMismatch() throws Exception { + public void valueWithMismatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").value("bogus").match(request)); } @@ -84,7 +84,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void valueWithMatcherAndMismatch() throws Exception { + public void valueWithMatcherAndMismatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").value(equalTo("bogus")).match(request)); } @@ -105,7 +105,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void existsNoMatch() throws Exception { + public void existsNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.bogus").exists().match(request)); } @@ -116,19 +116,19 @@ public class JsonPathRequestMatchersTests { } @Test - public void doesNotExistNoMatch() throws Exception { + public void doesNotExistNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").doesNotExist().match(request)); } @Test - public void doesNotExistForAnEmptyArray() throws Exception { + public void doesNotExistForAnEmptyArray() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.emptyArray").doesNotExist().match(request)); } @Test - public void doesNotExistForAnEmptyMap() throws Exception { + public void doesNotExistForAnEmptyMap() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.emptyMap").doesNotExist().match(request)); } @@ -174,19 +174,19 @@ public class JsonPathRequestMatchersTests { } @Test - public void isNotEmptyForAnEmptyString() throws Exception { + public void isNotEmptyForAnEmptyString() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.emptyString").isNotEmpty().match(request)); } @Test - public void isNotEmptyForAnEmptyArray() throws Exception { + public void isNotEmptyForAnEmptyArray() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.emptyArray").isNotEmpty().match(request)); } @Test - public void isNotEmptyForAnEmptyMap() throws Exception { + public void isNotEmptyForAnEmptyMap() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.emptyMap").isNotEmpty().match(request)); } @@ -202,7 +202,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void isArrayNoMatch() throws Exception { + public void isArrayNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").isArray().match(request)); } @@ -218,7 +218,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void isMapNoMatch() throws Exception { + public void isMapNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").isMap().match(request)); } @@ -229,7 +229,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void isBooleanNoMatch() throws Exception { + public void isBooleanNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").isBoolean().match(request)); } @@ -240,7 +240,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void isNumberNoMatch() throws Exception { + public void isNumberNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.str").isNumber().match(request)); } @@ -251,7 +251,7 @@ public class JsonPathRequestMatchersTests { } @Test - public void isStringNoMatch() throws Exception { + public void isStringNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathRequestMatchers("$.arr").isString().match(request)); } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/match/XpathRequestMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/client/match/XpathRequestMatchersTests.java index d4bb33a1ad7..ce725289557 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/match/XpathRequestMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/match/XpathRequestMatchersTests.java @@ -51,7 +51,7 @@ public class XpathRequestMatchersTests { } @Test - public void testNodeMatcherNoMatch() throws Exception { + public void testNodeMatcherNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar", null).node(Matchers.nullValue()).match(this.request)); } @@ -62,7 +62,7 @@ public class XpathRequestMatchersTests { } @Test - public void testExistsNoMatch() throws Exception { + public void testExistsNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/Bar", null).exists().match(this.request)); } @@ -73,7 +73,7 @@ public class XpathRequestMatchersTests { } @Test - public void testDoesNotExistNoMatch() throws Exception { + public void testDoesNotExistNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar", null).doesNotExist().match(this.request)); } @@ -84,7 +84,7 @@ public class XpathRequestMatchersTests { } @Test - public void testNodeCountNoMatch() throws Exception { + public void testNodeCountNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar", null).nodeCount(1).match(this.request)); } @@ -95,7 +95,7 @@ public class XpathRequestMatchersTests { } @Test - public void testStringNoMatch() throws Exception { + public void testStringNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar[1]", null).string("112").match(this.request)); } @@ -106,7 +106,7 @@ public class XpathRequestMatchersTests { } @Test - public void testNumberNoMatch() throws Exception { + public void testNumberNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar[1]", null).number(111.1).match(this.request)); } @@ -117,7 +117,7 @@ public class XpathRequestMatchersTests { } @Test - public void testBooleanNoMatch() throws Exception { + public void testBooleanNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new XpathRequestMatchers("/foo/bar[2]", null).booleanValue(false).match(this.request)); } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java index d1b01cf769e..17347ddf541 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.test.web.client.samples.matchers; import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -190,7 +189,7 @@ public class XpathRequestMatchersIntegrationTests { executeAndVerify(); } - private void executeAndVerify() throws URISyntaxException { + private void executeAndVerify() { this.restTemplate.put(URI.create("/composers"), this.people); this.mockServer.verify(); } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java index 7ad332dfec1..9b817d50537 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java @@ -93,8 +93,7 @@ class StatusAssertionTests { assertions.is1xxInformational(); // Wrong series - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - assertions.is2xxSuccessful()); + assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful); } @Test @@ -105,8 +104,7 @@ class StatusAssertionTests { assertions.is2xxSuccessful(); // Wrong series - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - assertions.is5xxServerError()); + assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is5xxServerError); } @Test @@ -117,8 +115,7 @@ class StatusAssertionTests { assertions.is3xxRedirection(); // Wrong series - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - assertions.is2xxSuccessful()); + assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful); } @Test @@ -129,8 +126,7 @@ class StatusAssertionTests { assertions.is4xxClientError(); // Wrong series - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - assertions.is2xxSuccessful()); + assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful); } @Test @@ -141,8 +137,7 @@ class StatusAssertionTests { assertions.is5xxServerError(); // Wrong series - assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> - assertions.is2xxSuccessful()); + assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java index b5dded5daeb..31393ce73c9 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java @@ -439,7 +439,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestPathInfo() throws Exception { + void buildRequestPathInfo() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getPathInfo()).isNull(); @@ -466,7 +466,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestProtocol() throws Exception { + void buildRequestProtocol() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getProtocol()).isEqualTo("HTTP/1.1"); @@ -534,14 +534,14 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestRemoteAddr() throws Exception { + void buildRequestRemoteAddr() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getRemoteAddr()).isEqualTo("127.0.0.1"); } @Test - void buildRequestRemoteHost() throws Exception { + void buildRequestRemoteHost() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getRemoteAddr()).isEqualTo("127.0.0.1"); @@ -574,7 +574,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestRequestedSessionId() throws Exception { + void buildRequestRequestedSessionId() { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); @@ -583,7 +583,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestRequestedSessionIdNull() throws Exception { + void buildRequestRequestedSessionIdNull() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getRequestedSessionId()).isNull(); @@ -618,7 +618,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestServerName() throws Exception { + void buildRequestServerName() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getServerName()).isEqualTo("example.com"); @@ -641,14 +641,14 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestServletContext() throws Exception { + void buildRequestServletContext() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getServletContext()).isEqualTo(servletContext); } @Test - void buildRequestServletPath() throws Exception { + void buildRequestServletPath() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getServletPath()).isEqualTo("/this/here"); @@ -665,7 +665,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSession() throws Exception { + void buildRequestSession() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession newSession = actualRequest.getSession(); @@ -682,7 +682,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionWithExistingSession() throws Exception { + void buildRequestSessionWithExistingSession() { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); @@ -703,7 +703,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionTrue() throws Exception { + void buildRequestSessionTrue() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession session = actualRequest.getSession(true); @@ -711,7 +711,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionFalseIsNull() throws Exception { + void buildRequestSessionFalseIsNull() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession session = actualRequest.getSession(false); @@ -719,7 +719,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionFalseWithExistingSession() throws Exception { + void buildRequestSessionFalseWithExistingSession() { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); @@ -729,14 +729,14 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionIsNew() throws Exception { + void buildRequestSessionIsNew() { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getSession().isNew()).isTrue(); } @Test - void buildRequestSessionIsNewFalse() throws Exception { + void buildRequestSessionIsNewFalse() { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); @@ -746,7 +746,7 @@ public class HtmlUnitRequestBuilderTests { } @Test - void buildRequestSessionInvalidate() throws Exception { + void buildRequestSessionInvalidate() { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionTests.java index d370005b8cc..b6f9d7d1a8e 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class MockMvcWebConnectionTests { } @Test - public void contextPathEmpty() throws IOException { + public void contextPathEmpty() { this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, "")); // Empty context path (root context) should not match to a URL with a context path assertThatExceptionOfType(FailingHttpStatusCodeException.class).isThrownBy(() -> @@ -89,15 +89,13 @@ public class MockMvcWebConnectionTests { } @Test - @SuppressWarnings("resource") - public void contextPathDoesNotStartWithSlash() throws IOException { + public void contextPathDoesNotStartWithSlash() { assertThatIllegalArgumentException().isThrownBy(() -> new MockMvcWebConnection(this.mockMvc, this.webClient, "context")); } @Test - @SuppressWarnings("resource") - public void contextPathEndsWithSlash() throws IOException { + public void contextPathEndsWithSlash() { assertThatIllegalArgumentException().isThrownBy(() -> new MockMvcWebConnection(this.mockMvc, this.webClient, "/context/")); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java index dd72b0d7b23..d8784fd10ca 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public class MockWebResponseBuilderTests { } @Test - public void constructorWithNullResponse() throws Exception { + public void constructorWithNullResponse() { assertThatIllegalArgumentException().isThrownBy(() -> new MockWebResponseBuilder(0L, new WebRequest(new URL("http://company.example:80/test/this/here")), null)); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java index 9edb7bd6ee1..2106d757c95 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.springframework.test.web.servlet.htmlunit.webdriver; -import java.io.IOException; - import com.gargoylesoftware.htmlunit.util.Cookie; import jakarta.servlet.http.HttpServletRequest; import org.junit.jupiter.api.Test; @@ -68,7 +66,7 @@ class MockMvcHtmlUnitDriverBuilderTests { } @Test - void mockMvcSetupWithCustomDriverDelegate() throws Exception { + void mockMvcSetupWithCustomDriverDelegate() { WebConnectionHtmlUnitDriver otherDriver = new WebConnectionHtmlUnitDriver(); this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).withDelegate(otherDriver).build(); @@ -76,7 +74,7 @@ class MockMvcHtmlUnitDriverBuilderTests { } @Test - void mockMvcSetupWithDefaultDriverDelegate() throws Exception { + void mockMvcSetupWithDefaultDriverDelegate() { this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).build(); assertMockMvcUsed("http://localhost/test"); @@ -95,7 +93,7 @@ class MockMvcHtmlUnitDriverBuilderTests { } @Test // SPR-14066 - void cookieManagerShared() throws Exception { + void cookieManagerShared() { WebConnectionHtmlUnitDriver otherDriver = new WebConnectionHtmlUnitDriver(); this.mockMvc = MockMvcBuilders.standaloneSetup(new CookieController()).build(); this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).withDelegate(otherDriver).build(); @@ -107,11 +105,11 @@ class MockMvcHtmlUnitDriverBuilderTests { } - private void assertMockMvcUsed(String url) throws Exception { + private void assertMockMvcUsed(String url) { assertThat(get(url)).contains(EXPECTED_BODY); } - private String get(String url) throws IOException { + private String get(String url) { this.driver.get(url); return this.driver.getPageSource(); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 4f5f5d3655e..fa09baa7324 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -18,7 +18,6 @@ package org.springframework.test.web.servlet.request; import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; @@ -96,7 +95,7 @@ class MockHttpServletRequestBuilderTests { } @Test // SPR-13435 - void requestUriWithDoubleSlashes() throws URISyntaxException { + void requestUriWithDoubleSlashes() { this.builder = new MockHttpServletRequestBuilder(GET, URI.create("/test//currentlyValid/0")); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); @@ -311,7 +310,7 @@ class MockHttpServletRequestBuilderTests { } @Test // SPR-13801 - void requestParameterFromMultiValueMap() throws Exception { + void requestParameterFromMultiValueMap() { MultiValueMap params = new LinkedMultiValueMap<>(); params.add("foo", "bar"); params.add("foo", "baz"); @@ -324,7 +323,7 @@ class MockHttpServletRequestBuilderTests { } @Test - void requestParameterFromRequestBodyFormData() throws Exception { + void requestParameterFromRequestBodyFormData() { String contentType = "application/x-www-form-urlencoded;charset=UTF-8"; String body = "name+1=value+1&name+2=value+A&name+2=value+B&name+3"; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/ContentResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/ContentResultMatchersTests.java index e8453b5620e..fa98d3d1ea2 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/ContentResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/ContentResultMatchersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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 @@ class ContentResultMatchersTests { } @Test - void typeNoMatch() throws Exception { + void typeNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().contentType("text/plain").match(getStubMvcResult(CONTENT))); } @@ -49,7 +49,7 @@ class ContentResultMatchersTests { } @Test - void stringNoMatch() throws Exception { + void stringNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().encoding("bogus").match(getStubMvcResult(CONTENT))); } @@ -61,7 +61,7 @@ class ContentResultMatchersTests { } @Test - void stringMatcherNoMatch() throws Exception { + void stringMatcherNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().string(Matchers.equalTo("bogus")).match(getStubMvcResult(CONTENT))); } @@ -72,7 +72,7 @@ class ContentResultMatchersTests { } @Test - void bytesNoMatch() throws Exception { + void bytesNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().bytes("bogus".getBytes()).match(getStubMvcResult(CONTENT))); } @@ -90,13 +90,13 @@ class ContentResultMatchersTests { } @Test - void jsonLenientNoMatch() throws Exception { + void jsonLenientNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().json("{\n\"fooo\":\"bar\"\n}").match(getStubMvcResult(CONTENT))); } @Test - void jsonStrictNoMatch() throws Exception { + void jsonStrictNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new ContentResultMatchers().json("{\"foo\":\"bar\", \"foo array\":[\"bar\",\"foo\"]}", true).match(getStubMvcResult(CONTENT))); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java index 4967adf7b9c..31c028cbbd9 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class FlashAttributeResultMatchersTests { } @Test - public void attributeExists_doesntExist() throws Exception { + public void attributeExists_doesntExist() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new FlashAttributeResultMatchers().attributeExists("bad").match(getStubMvcResult())); } @@ -45,7 +45,7 @@ public class FlashAttributeResultMatchersTests { } @Test - public void attribute_incorrectValue() throws Exception { + public void attribute_incorrectValue() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new FlashAttributeResultMatchers().attribute("good", "not good").match(getStubMvcResult())); } @@ -53,8 +53,7 @@ public class FlashAttributeResultMatchersTests { private StubMvcResult getStubMvcResult() { FlashMap flashMap = new FlashMap(); flashMap.put("good", "good"); - StubMvcResult mvcResult = new StubMvcResult(null, null, null, null, null, flashMap, null); - return mvcResult; + return new StubMvcResult(null, null, null, null, null, flashMap, null); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java index c7e211ffe40..6c38c732a16 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java @@ -66,14 +66,14 @@ class JsonPathResultMatchersTests { @Test - void valueWithValueMismatch() throws Exception { + void valueWithValueMismatch() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> new JsonPathResultMatchers("$.str").value("bogus").match(stubMvcResult)) .withMessage("JSON path \"$.str\" expected: but was:"); } @Test - void valueWithTypeMismatch() throws Exception { + void valueWithTypeMismatch() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> new JsonPathResultMatchers("$.str").value("bogus".getBytes()).match(stubMvcResult)) .withMessage("At JSON path \"$.str\", value of type cannot be converted to type "); @@ -105,7 +105,7 @@ class JsonPathResultMatchersTests { } @Test - void valueWithMatcherAndMismatch() throws Exception { + void valueWithMatcherAndMismatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.str").value(Matchers.equalTo("bogus")).match(stubMvcResult)); } @@ -126,7 +126,7 @@ class JsonPathResultMatchersTests { } @Test - void existsNoMatch() throws Exception { + void existsNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.bogus").exists().match(stubMvcResult)); } @@ -137,19 +137,19 @@ class JsonPathResultMatchersTests { } @Test - void doesNotExistNoMatch() throws Exception { + void doesNotExistNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.str").doesNotExist().match(stubMvcResult)); } @Test - void doesNotExistForAnEmptyArray() throws Exception { + void doesNotExistForAnEmptyArray() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.emptyArray").doesNotExist().match(stubMvcResult)); } @Test - void doesNotExistForAnEmptyMap() throws Exception { + void doesNotExistForAnEmptyMap() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.emptyMap").doesNotExist().match(stubMvcResult)); } @@ -195,19 +195,19 @@ class JsonPathResultMatchersTests { } @Test - void isNotEmptyForAnEmptyString() throws Exception { + void isNotEmptyForAnEmptyString() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.emptyString").isNotEmpty().match(stubMvcResult)); } @Test - void isNotEmptyForAnEmptyArray() throws Exception { + void isNotEmptyForAnEmptyArray() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.emptyArray").isNotEmpty().match(stubMvcResult)); } @Test - void isNotEmptyForAnEmptyMap() throws Exception { + void isNotEmptyForAnEmptyMap() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.emptyMap").isNotEmpty().match(stubMvcResult)); } @@ -223,7 +223,7 @@ class JsonPathResultMatchersTests { } @Test - void isArrayNoMatch() throws Exception { + void isArrayNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.bar").isArray().match(stubMvcResult)); } @@ -239,7 +239,7 @@ class JsonPathResultMatchersTests { } @Test - void isMapNoMatch() throws Exception { + void isMapNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.str").isMap().match(stubMvcResult)); } @@ -250,7 +250,7 @@ class JsonPathResultMatchersTests { } @Test - void isBooleanNoMatch() throws Exception { + void isBooleanNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.str").isBoolean().match(stubMvcResult)); } @@ -261,7 +261,7 @@ class JsonPathResultMatchersTests { } @Test - void isNumberNoMatch() throws Exception { + void isNumberNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.str").isNumber().match(stubMvcResult)); } @@ -272,7 +272,7 @@ class JsonPathResultMatchersTests { } @Test - void isStringNoMatch() throws Exception { + void isStringNoMatch() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new JsonPathResultMatchers("$.arr").isString().match(stubMvcResult)); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/MockMvcResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/MockMvcResultMatchersTests.java index 1930453b83a..94eef5442ce 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/MockMvcResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/MockMvcResultMatchersTests.java @@ -45,33 +45,33 @@ public class MockMvcResultMatchersTests { } @Test - public void redirectNonMatching() throws Exception { + public void redirectNonMatching() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> redirectedUrl("/resource/2").match(redirectedUrlStub("/resource/1"))) .withMessageEndingWith("expected: but was:"); } @Test - public void redirectNonMatchingBecauseNotRedirect() throws Exception { + public void redirectNonMatchingBecauseNotRedirect() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> redirectedUrl("/resource/1").match(forwardedUrlStub("/resource/1"))) .withMessageEndingWith("expected: but was:"); } @Test - public void redirectWithUrlTemplate() throws Exception { + public void redirectWithUrlTemplate() { assertThatCode(() -> redirectedUrlTemplate("/orders/{orderId}/items/{itemId}", 1, 2).match(redirectedUrlStub("/orders/1/items/2"))) .doesNotThrowAnyException(); } @Test - public void redirectWithMatchingPattern() throws Exception { + public void redirectWithMatchingPattern() { assertThatCode(() -> redirectedUrlPattern("/resource/*").match(redirectedUrlStub("/resource/1"))) .doesNotThrowAnyException(); } @Test - public void redirectWithNonMatchingPattern() throws Exception { + public void redirectWithNonMatchingPattern() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> redirectedUrlPattern("/resource/").match(redirectedUrlStub("/resource/1"))) .withMessage("'/resource/' is not an Ant-style path pattern"); @@ -105,25 +105,25 @@ public class MockMvcResultMatchersTests { } @Test - public void forwardWithQueryString() throws Exception { + public void forwardWithQueryString() { assertThatCode(() -> forwardedUrl("/api/resource/1?arg=value").match(forwardedUrlStub("/api/resource/1?arg=value"))) .doesNotThrowAnyException(); } @Test - public void forwardWithUrlTemplate() throws Exception { + public void forwardWithUrlTemplate() { assertThatCode(() -> forwardedUrlTemplate("/orders/{orderId}/items/{itemId}", 1, 2).match(forwardedUrlStub("/orders/1/items/2"))) .doesNotThrowAnyException(); } @Test - public void forwardWithMatchingPattern() throws Exception { + public void forwardWithMatchingPattern() { assertThatCode(() -> forwardedUrlPattern("/api/**/?").match(forwardedUrlStub("/api/resource/1"))) .doesNotThrowAnyException(); } @Test - public void forwardWithNonMatchingPattern() throws Exception { + public void forwardWithNonMatchingPattern() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> forwardedUrlPattern("/resource/").match(forwardedUrlStub("/resource/1"))) .withMessage("'/resource/' is not an Ant-style path pattern"); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/ModelResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/ModelResultMatchersTests.java index 94ab8c2e5c7..a9ebb502cb8 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/ModelResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/ModelResultMatchersTests.java @@ -45,7 +45,7 @@ class ModelResultMatchersTests { @BeforeEach - void setUp() throws Exception { + void setUp() { ModelAndView mav = new ModelAndView("view", "good", "good"); BindingResult bindingResult = new BeanPropertyBindingResult("good", "good"); mav.addObject(BindingResult.MODEL_KEY_PREFIX + "good", bindingResult); @@ -69,7 +69,7 @@ class ModelResultMatchersTests { } @Test - void attributeExists_doesNotExist() throws Exception { + void attributeExists_doesNotExist() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeExists("bad").match(this.mvcResult)); } @@ -80,7 +80,7 @@ class ModelResultMatchersTests { } @Test - void attributeDoesNotExist_doesExist() throws Exception { + void attributeDoesNotExist_doesExist() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeDoesNotExist("good").match(this.mvcResultWithError)); } @@ -91,7 +91,7 @@ class ModelResultMatchersTests { } @Test - void attribute_notEqual() throws Exception { + void attribute_notEqual() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attribute("good", is("bad")).match(this.mvcResult)); } @@ -102,7 +102,7 @@ class ModelResultMatchersTests { } @Test - void hasNoErrors_withErrors() throws Exception { + void hasNoErrors_withErrors() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.hasNoErrors().match(this.mvcResultWithError)); } @@ -118,14 +118,14 @@ class ModelResultMatchersTests { } @Test - void attributeErrorCount_withWrongErrorCount() throws Exception { + void attributeErrorCount_withWrongErrorCount() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> this.matchers.attributeErrorCount("date", 2).match(this.mvcResultWithError)) .withMessage("Binding/validation error count for attribute 'date', expected:<2> but was:<1>"); } @Test - void attributeHasErrors_withoutErrors() throws Exception { + void attributeHasErrors_withoutErrors() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasErrors("good").match(this.mvcResultWithError)); } @@ -136,13 +136,13 @@ class ModelResultMatchersTests { } @Test - void attributeHasNoErrors_withoutAttribute() throws Exception { + void attributeHasNoErrors_withoutAttribute() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasNoErrors("missing").match(this.mvcResultWithError)); } @Test - void attributeHasNoErrors_withErrors() throws Exception { + void attributeHasNoErrors_withErrors() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasNoErrors("date").match(this.mvcResultWithError)); } @@ -153,19 +153,19 @@ class ModelResultMatchersTests { } @Test - void attributeHasFieldErrors_withoutAttribute() throws Exception { + void attributeHasFieldErrors_withoutAttribute() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasFieldErrors("missing", "bad").match(this.mvcResult)); } @Test - void attributeHasFieldErrors_withoutErrorsForAttribute() throws Exception { + void attributeHasFieldErrors_withoutErrorsForAttribute() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasFieldErrors("date", "time").match(this.mvcResult)); } @Test - void attributeHasFieldErrors_withoutErrorsForField() throws Exception { + void attributeHasFieldErrors_withoutErrorsForField() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasFieldErrors("date", "good", "time").match(this.mvcResultWithError)); } @@ -176,7 +176,7 @@ class ModelResultMatchersTests { } @Test - void attributeHasFieldErrorCode_withoutErrorOnField() throws Exception { + void attributeHasFieldErrorCode_withoutErrorOnField() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasFieldErrorCode("date", "time", "incorrectError").match(this.mvcResultWithError)); } @@ -187,7 +187,7 @@ class ModelResultMatchersTests { } @Test - void attributeHasFieldErrorCode_startsWith_withoutErrorOnField() throws Exception { + void attributeHasFieldErrorCode_startsWith_withoutErrorOnField() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.matchers.attributeHasFieldErrorCode("date", "time", startsWith("inc")).match(this.mvcResultWithError)); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java index 1a02b0869c5..bc89c421981 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java @@ -145,7 +145,6 @@ class PrintingResultHandlerTests { } @Test - @SuppressWarnings("removal") void printResponse() throws Exception { Cookie enigmaCookie = new Cookie("enigma", "42"); enigmaCookie.setHttpOnly(true); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/AsyncTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/AsyncTests.java index 0b0022d6c02..2de69a305aa 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/AsyncTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/AsyncTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,7 +128,7 @@ class AsyncTests { } @Test - void completableFutureWithImmediateValue() throws Exception { + void completableFutureWithImmediateValue() { this.testClient.get() .uri("/1?completableFutureWithImmediateValue=true") .exchange() diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/FilterTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/FilterTests.java index 6adae504d18..c555cfb364a 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/FilterTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/FilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,7 +197,7 @@ public class FilterTests { } } - private class ContinueFilter extends OncePerRequestFilter { + private static class ContinueFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, @@ -235,11 +235,11 @@ public class FilterTests { } } - private class RedirectFilter extends OncePerRequestFilter { + private static class RedirectFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { + FilterChain filterChain) throws IOException { response.sendRedirect("/login"); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/MultipartControllerTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/MultipartControllerTests.java index d9206ea8197..78b9cb2748c 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/MultipartControllerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/MultipartControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class MultipartControllerTests { @Test - public void multipartRequestWithSingleFile() throws Exception { + public void multipartRequestWithSingleFile() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -88,7 +88,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithFileArray() throws Exception { + public void multipartRequestWithFileArray() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -112,7 +112,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFile() throws Exception { + public void multipartRequestWithOptionalFile() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -128,7 +128,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFileNotPresent() throws Exception { + public void multipartRequestWithOptionalFileNotPresent() { Map json = Collections.singletonMap("name", "yeeeah"); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); @@ -142,7 +142,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFileArray() throws Exception { + public void multipartRequestWithOptionalFileArray() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -159,7 +159,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFileArrayNotPresent() throws Exception { + public void multipartRequestWithOptionalFileArrayNotPresent() { Map json = Collections.singletonMap("name", "yeeeah"); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); @@ -173,7 +173,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFileList() throws Exception { + public void multipartRequestWithOptionalFileList() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -190,7 +190,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithOptionalFileListNotPresent() throws Exception { + public void multipartRequestWithOptionalFileListNotPresent() { Map json = Collections.singletonMap("name", "yeeeah"); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); @@ -204,7 +204,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWithServletParts() throws Exception { + public void multipartRequestWithServletParts() { byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8); Map json = Collections.singletonMap("name", "yeeeah"); @@ -220,7 +220,7 @@ public class MultipartControllerTests { } @Test - public void multipartRequestWrapped() throws Exception { + public void multipartRequestWrapped() { Map json = Collections.singletonMap("name", "yeeeah"); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/RequestParameterTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/RequestParameterTests.java index bb9f0efd408..784ee8534e4 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/RequestParameterTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/RequestParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author 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,13 +50,12 @@ public class RequestParameterTests { @Controller - private class PersonController { + private static class PersonController { @RequestMapping(value="/search") @ResponseBody public Person get(@RequestParam String name) { - Person person = new Person(name); - return person; + return new Person(name); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/ContentAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/ContentAssertionTests.java index 36eb11149b0..92c9e5b3993 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/ContentAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/ContentAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,7 +136,7 @@ class ContentAssertionTests { @RequestMapping(path="/handleUtf8", produces="text/plain;charset=UTF-8") @ResponseBody String handleWithCharset() { - return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese) + return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world!" (Japanese) } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/JsonPathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/JsonPathAssertionTests.java index 0bbe20a6e62..efcd967bc29 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/JsonPathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/JsonPathAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public class JsonPathAssertionTests { @RestController - private class MusicController { + private static class MusicController { @RequestMapping("/music/people") public MultiValueMap get() { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/XpathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/XpathAssertionTests.java index aff406bfdf5..6da768268fb 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/XpathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/resultmatches/XpathAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,8 +170,8 @@ public class XpathAssertionTests { private static class MusicController { @RequestMapping(value = "/music/people") - public @ResponseBody - PeopleWrapper getPeople() { + @ResponseBody + public PeopleWrapper getPeople() { List composers = Arrays.asList( new Person("Johann Sebastian Bach").setSomeDouble(21), @@ -219,7 +219,7 @@ public class XpathAssertionTests { @Controller - public class BlogFeedController { + public static class BlogFeedController { @RequestMapping(value = "/blog.atom", method = {GET, HEAD}) @ResponseBody diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java index 07b359ee6e3..683870f677e 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -174,7 +174,7 @@ public class FilterTests { } } - private class ContinueFilter extends OncePerRequestFilter { + private static class ContinueFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, @@ -212,11 +212,11 @@ public class FilterTests { } } - private class RedirectFilter extends OncePerRequestFilter { + private static class RedirectFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { + FilterChain filterChain) throws IOException { response.sendRedirect("/login"); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java index 4a9f6c678f1..8026ea48cf3 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -244,14 +244,14 @@ class MultipartControllerTests { @PostMapping("/multipartfile") public String processMultipartFile(@RequestParam(required = false) MultipartFile file, - @RequestPart(required = false) Map json) throws IOException { + @RequestPart(required = false) Map json) { return "redirect:/index"; } @PutMapping("/multipartfile-via-put") public String processMultipartFileViaHttpPut(@RequestParam(required = false) MultipartFile file, - @RequestPart(required = false) Map json) throws IOException { + @RequestPart(required = false) Map json) { return processMultipartFile(file, json); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/RequestParameterTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/RequestParameterTests.java index 584af36911c..4c81c6f5498 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/RequestParameterTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/RequestParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,13 +50,12 @@ public class RequestParameterTests { @Controller - private class PersonController { + private static class PersonController { @RequestMapping(value="/search") @ResponseBody public Person get(@RequestParam String name) { - Person person = new Person(name); - return person; + return new Person(name); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/ContentAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/ContentAssertionTests.java index 98bc13599ca..4bdb2019fba 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/ContentAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/ContentAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ public class ContentAssertionTests { @GetMapping(path="/handleUtf8", produces="text/plain;charset=UTF-8") String handleWithCharset() { - return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese) + return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world!" (Japanese) } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/CookieAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/CookieAssertionTests.java index 99dfba6e360..ba01d59157b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/CookieAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/CookieAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class CookieAssertionTests { .addInterceptors(new LocaleChangeInterceptor()) .addInterceptors(new HandlerInterceptor() { @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { response.addCookie(cookie); return true; } @@ -125,7 +125,7 @@ public class CookieAssertionTests { } @Test - void testSameSiteNotEquals() throws Exception { + void testSameSiteNotEquals() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.mockMvc.perform(get("/")).andExpect(cookie() .sameSite(COOKIE_WITH_ATTRIBUTES_NAME, "Str"))) diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/FlashAttributeAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/FlashAttributeAssertionTests.java index 0ffc879e902..ac76372c5c7 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/FlashAttributeAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/FlashAttributeAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author 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 @@ public class FlashAttributeAssertionTests { @Test - void attributeCountWithWrongCount() throws Exception { + void attributeCountWithWrongCount() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> this.mockMvc.perform(post("/persons")).andExpect(flash().attributeCount(1))) .withMessage("FlashMap size expected:<1> but was:<3>"); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java index e7eb1f5bdf0..e16be356f95 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author 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,7 @@ public class HandlerAssertionTests { } @Test - public void methodCallOnNonMock() throws Exception { + public void methodCallOnNonMock() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.mockMvc.perform(get("/")).andExpect(handler().methodCall("bogus"))) .withMessageContaining("The supplied object [bogus] is not an instance of") diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java index f42c3b777ef..3c6c7a0ba95 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,7 +158,7 @@ public class HeaderAssertionTests { } @Test - public void existsFail() throws Exception { + public void existsFail() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.mockMvc.perform(get("/persons/1")).andExpect(header().exists("X-Custom-Header"))); } @@ -169,13 +169,13 @@ public class HeaderAssertionTests { } @Test // SPR-10771 - public void doesNotExistFail() throws Exception { + public void doesNotExistFail() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.mockMvc.perform(get("/persons/1")).andExpect(header().doesNotExist(LAST_MODIFIED))); } @Test - public void longValueWithIncorrectResponseHeaderValue() throws Exception { + public void longValueWithIncorrectResponseHeaderValue() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.mockMvc.perform(get("/persons/1")).andExpect(header().longValue("X-Rate-Limiting", 1))); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java index 0a46076404a..4b88cd19d82 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,7 @@ public class JsonPathAssertionTests { @RestController - private class MusicController { + private static class MusicController { @RequestMapping("/music/people") public MultiValueMap get() { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XmlContentAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XmlContentAssertionTests.java index a2abe1f75b3..b3afb56d146 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XmlContentAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XmlContentAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,8 @@ public class XmlContentAssertionTests { private static class MusicController { @RequestMapping(value="/music/people") - public @ResponseBody PeopleWrapper getPeople() { + @ResponseBody + public PeopleWrapper getPeople() { List composers = Arrays.asList( new Person("Johann Sebastian Bach").setSomeDouble(21), diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XpathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XpathAssertionTests.java index 7ea60cbb964..5d3ae150813 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XpathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/XpathAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,7 +171,8 @@ public class XpathAssertionTests { private static class MusicController { @RequestMapping(value="/music/people") - public @ResponseBody PeopleWrapper getPeople() { + @ResponseBody + public PeopleWrapper getPeople() { List composers = Arrays.asList( new Person("Johann Sebastian Bach").setSomeDouble(21), @@ -219,7 +220,7 @@ public class XpathAssertionTests { @Controller - public class BlogFeedController { + public static class BlogFeedController { @RequestMapping(value="/blog.atom", method = { GET, HEAD }) @ResponseBody diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java index 00cca3fe54b..febe5f1a5f6 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/MockMvcFilterDecoratorTests.java @@ -22,7 +22,6 @@ import jakarta.servlet.DispatcherType; import jakarta.servlet.Filter; import jakarta.servlet.FilterChain; import jakarta.servlet.FilterConfig; -import jakarta.servlet.ServletException; import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import org.junit.jupiter.api.BeforeEach; @@ -289,7 +288,7 @@ public class MockMvcFilterDecoratorTests { private boolean destroy; @Override - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) { this.filterConfig = filterConfig; }