diff --git a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java index ed5ba5ffc9b..27c71573e18 100644 --- a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.util.Map; import org.springframework.lang.Nullable; /** - * Abstract superclass for counting advices etc. + * Abstract superclass for counting advice, etc. * * @author Rod Johnson * @author Chris Beams @@ -62,7 +62,7 @@ public class MethodCounter implements Serializable { */ @Override public boolean equals(@Nullable Object other) { - return (other != null && other.getClass() == this.getClass()); + return (other != null && getClass() == other.getClass()); } @Override diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java index a8546f37481..9e8ba7b7099 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,14 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams */ class FactoryBeanLookupTests { - private BeanFactory beanFactory; + + private final BeanFactory beanFactory = new DefaultListableBeanFactory(); + @BeforeEach void setUp() { - beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions( - new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass())); + new ClassPathResource("FactoryBeanLookupTests-context.xml", getClass())); } @Test @@ -71,6 +72,7 @@ class FactoryBeanLookupTests { Foo foo = beanFactory.getBean("fooFactory", Foo.class); assertThat(foo).isNotNull(); } + } class FooFactoryBean extends AbstractFactoryBean { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index dd7d68b1900..3712f6b4b86 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -2453,7 +2453,7 @@ class AutowiredAnnotationBeanPostProcessorTests { } @Test - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) void genericsBasedConstructorInjectionWithNonTypedTarget() { RootBeanDefinition bd = new RootBeanDefinition(RepositoryConstructorInjectionBean.class); bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java index 01d387a95ab..a39e09a9b5f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ class PropertyPlaceholderConfigurerTests { .getBeanDefinition()); PropertyPlaceholderConfigurer pc = new PropertyPlaceholderConfigurer(); - Resource resource = new ClassPathResource("PropertyPlaceholderConfigurerTests.properties", this.getClass()); + Resource resource = new ClassPathResource("PropertyPlaceholderConfigurerTests.properties", getClass()); pc.setLocation(resource); pc.postProcessBeanFactory(bf); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 8544568823f..db16b7062e8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ class DuplicateBeanIdTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf); assertThatException().as("duplicate ids in same nesting level").isThrownBy(() -> - reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-sameLevel-context.xml", this.getClass()))); + reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-sameLevel-context.xml", getClass()))); } @Test @@ -54,7 +54,7 @@ class DuplicateBeanIdTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.setAllowBeanDefinitionOverriding(true); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf); - reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-multiLevel-context.xml", this.getClass())); + reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-multiLevel-context.xml", getClass())); TestBean testBean = bf.getBean(TestBean.class); // there should be only one assertThat(testBean.getName()).isEqualTo("nested"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java index 4efa9b5dd38..5474e81d578 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ class NestedBeansElementAttributeRecursionTests { void defaultLazyInit() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", getClass())); assertLazyInits(bf); } @@ -47,7 +47,7 @@ class NestedBeansElementAttributeRecursionTests { XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf); xmlBeanDefinitionReader.setValidating(false); xmlBeanDefinitionReader.loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", getClass())); assertLazyInits(bf); } @@ -70,7 +70,7 @@ class NestedBeansElementAttributeRecursionTests { void defaultMerge() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", getClass())); assertMerge(bf); } @@ -81,7 +81,7 @@ class NestedBeansElementAttributeRecursionTests { XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf); xmlBeanDefinitionReader.setValidating(false); xmlBeanDefinitionReader.loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", getClass())); assertMerge(bf); } @@ -109,7 +109,7 @@ class NestedBeansElementAttributeRecursionTests { void defaultAutowireCandidates() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-autowire-candidates-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-autowire-candidates-context.xml", getClass())); assertAutowireCandidates(bf); } @@ -120,7 +120,7 @@ class NestedBeansElementAttributeRecursionTests { XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf); xmlBeanDefinitionReader.setValidating(false); xmlBeanDefinitionReader.loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-autowire-candidates-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-autowire-candidates-context.xml", getClass())); assertAutowireCandidates(bf); } @@ -149,7 +149,7 @@ class NestedBeansElementAttributeRecursionTests { void initMethod() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( - new ClassPathResource("NestedBeansElementAttributeRecursionTests-init-destroy-context.xml", this.getClass())); + new ClassPathResource("NestedBeansElementAttributeRecursionTests-init-destroy-context.xml", getClass())); InitDestroyBean beanA = bf.getBean("beanA", InitDestroyBean.class); InitDestroyBean beanB = bf.getBean("beanB", InitDestroyBean.class); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java index 38e90b31810..03ce5b9bd1d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,15 +26,14 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; - /** * Tests for new nested beans element support in Spring XML * * @author Chris Beams */ class NestedBeansElementTests { - private final Resource XML = - new ClassPathResource("NestedBeansElementTests-context.xml", this.getClass()); + + private final Resource XML = new ClassPathResource("NestedBeansElementTests-context.xml", getClass()); @Test void getBean_withoutActiveProfile() { diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java index 06ff77d58a4..20f780fa3aa 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author 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 @@ class SimpleKeyGeneratorTests { private Object generateKey(Object[] arguments) { - Method method = ReflectionUtils.findMethod(this.getClass(), "generateKey", Object[].class); + Method method = ReflectionUtils.findMethod(getClass(), "generateKey", Object[].class); return this.generator.generate(this, method, arguments); } diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index 71c9eeea73b..1da2ffabab4 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -170,7 +170,7 @@ class PropertySourcesPlaceholderConfigurerTests { .getBeanDefinition()); PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); - Resource resource = new ClassPathResource("PropertySourcesPlaceholderConfigurerTests.properties", this.getClass()); + Resource resource = new ClassPathResource("PropertySourcesPlaceholderConfigurerTests.properties", getClass()); ppc.setLocation(resource); ppc.postProcessBeanFactory(bf); assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("foo"); diff --git a/spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java b/spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java index 77c78341674..cf27ed9e0d6 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public abstract class AbstractTypeReference implements TypeReference { @Override public int compareTo(TypeReference other) { - return this.getCanonicalName().compareToIgnoreCase(other.getCanonicalName()); + return getCanonicalName().compareToIgnoreCase(other.getCanonicalName()); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java index a13c40a74fb..3d3566c79d1 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java @@ -198,7 +198,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe public void validateRequiredProperties() { MissingRequiredPropertiesException ex = new MissingRequiredPropertiesException(); for (String key : this.requiredProperties) { - if (this.getProperty(key) == null) { + if (getProperty(key) == null) { ex.addMissingRequiredProperty(key); } } diff --git a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java index 107e0bd16b0..7c89894c680 100644 --- a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -228,7 +228,7 @@ class ClassUtilsTests { @Test void getShortNameAsProperty() { - String shortName = ClassUtils.getShortNameAsProperty(this.getClass()); + String shortName = ClassUtils.getShortNameAsProperty(getClass()); assertThat(shortName).as("Class name did not match").isEqualTo("classUtilsTests"); } diff --git a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java index 1a96590db74..afeb96110fb 100644 --- a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -382,7 +382,7 @@ class CollectionUtilsTests { if (this == rhs) { return true; } - if (rhs == null || this.getClass() != rhs.getClass()) { + if (rhs == null || getClass() != rhs.getClass()) { return false; } Instance instance = (Instance) rhs; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java index 4e5e22df0c5..0648b93b34a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java @@ -276,7 +276,7 @@ class VariableAndFunctionTests extends AbstractExpressionTests { @Test void functionMethodMustBeStatic() throws Exception { - context.registerFunction("nonStatic", this.getClass().getMethod("nonStatic")); + context.registerFunction("nonStatic", getClass().getMethod("nonStatic")); SpelExpression expression = parser.parseRaw("#nonStatic()"); assertThatExceptionOfType(SpelEvaluationException.class) .isThrownBy(() -> expression.getValue(context)) diff --git a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java index 3dee45d9b93..7542c68155b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author 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 @@ class MappingJackson2MessageConverterTests { @Test void toTextMessageWithReturnType() throws JMSException, NoSuchMethodException { - Method method = this.getClass().getDeclaredMethod("summary"); + Method method = getClass().getDeclaredMethod("summary"); MethodParameter returnType = new MethodParameter(method, -1); testToTextMessageWithReturnType(returnType); verify(sessionMock).createTextMessage("{\"name\":\"test\"}"); @@ -188,7 +188,7 @@ class MappingJackson2MessageConverterTests { @Test void toTextMessageWithReturnTypeAndNoJsonView() throws JMSException, NoSuchMethodException { - Method method = this.getClass().getDeclaredMethod("none"); + Method method = getClass().getDeclaredMethod("none"); MethodParameter returnType = new MethodParameter(method, -1); testToTextMessageWithReturnType(returnType); @@ -197,7 +197,7 @@ class MappingJackson2MessageConverterTests { @Test void toTextMessageWithReturnTypeAndMultipleJsonViews() throws NoSuchMethodException { - Method method = this.getClass().getDeclaredMethod("invalid"); + Method method = getClass().getDeclaredMethod("invalid"); MethodParameter returnType = new MethodParameter(method, -1); assertThatIllegalArgumentException().isThrownBy(() -> diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java index 0c412d4c615..248fd909935 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,9 +59,9 @@ import static org.mockito.Mockito.verify; * @author Sebastien Deleuze */ @ExtendWith(MockitoExtension.class) -public class SubscriptionMethodReturnValueHandlerTests { +class SubscriptionMethodReturnValueHandlerTests { - public static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8); + private static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8); private static final String PAYLOAD = "payload"; @@ -95,16 +95,16 @@ public class SubscriptionMethodReturnValueHandlerTests { jsonMessagingTemplate.setMessageConverter(new MappingJackson2MessageConverter()); this.jsonHandler = new SubscriptionMethodReturnValueHandler(jsonMessagingTemplate); - Method method = this.getClass().getDeclaredMethod("getData"); + Method method = getClass().getDeclaredMethod("getData"); this.subscribeEventReturnType = new MethodParameter(method, -1); - method = this.getClass().getDeclaredMethod("getDataAndSendTo"); + method = getClass().getDeclaredMethod("getDataAndSendTo"); this.subscribeEventSendToReturnType = new MethodParameter(method, -1); - method = this.getClass().getDeclaredMethod("handle"); + method = getClass().getDeclaredMethod("handle"); this.messageMappingReturnType = new MethodParameter(method, -1); - method = this.getClass().getDeclaredMethod("getJsonView"); + method = getClass().getDeclaredMethod("getJsonView"); this.subscribeEventJsonViewReturnType = new MethodParameter(method, -1); } @@ -144,7 +144,7 @@ public class SubscriptionMethodReturnValueHandlerTests { @Test @SuppressWarnings({ "unchecked", "rawtypes" }) - public void testHeadersPassedToMessagingTemplate() throws Exception { + void testHeadersPassedToMessagingTemplate() throws Exception { String sessionId = "sess1"; String subscriptionId = "subs1"; String destination = "/dest"; diff --git a/spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java b/spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java index e247e92d85e..186dbaa5bb3 100644 --- a/spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java +++ b/spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,7 +110,7 @@ public class PersonEntity extends PersistentEntity implements Person { public String toString() { // @formatter:off return new ToStringCreator(this) - .append("id", this.getId()) + .append("id", getId()) .append("name", this.name) .append("age", this.age) .append("eyeColor", this.eyeColor) diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java index 82c1d5a0dc4..d28d6fe7a26 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author 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.web.client.samples; import java.io.IOException; import java.util.Collections; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; @@ -46,27 +45,22 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat /** * Examples to demonstrate writing client-side REST tests with Spring MVC Test. - * While the tests in this class invoke the RestTemplate directly, in actual + * + *

While the tests in this class invoke the RestTemplate directly, in actual * tests the RestTemplate may likely be invoked indirectly, i.e. through client * code. * * @author Rossen Stoyanchev */ -public class SampleTests { +class SampleTests { - private MockRestServiceServer mockServer; + private final RestTemplate restTemplate = new RestTemplate(); - private RestTemplate restTemplate; + private final MockRestServiceServer mockServer = MockRestServiceServer.bindTo(this.restTemplate).ignoreExpectOrder(true).build(); - @BeforeEach - public void setup() { - this.restTemplate = new RestTemplate(); - this.mockServer = MockRestServiceServer.bindTo(this.restTemplate).ignoreExpectOrder(true).build(); - } @Test - public void performGet() { - + void performGet() { String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) @@ -83,8 +77,7 @@ public class SampleTests { } @Test - public void performGetManyTimes() { - + void performGetManyTimes() { String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; this.mockServer.expect(manyTimes(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) @@ -105,8 +98,7 @@ public class SampleTests { } @Test - public void expectNever() { - + void expectNever() { String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; this.mockServer.expect(once(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) @@ -120,8 +112,7 @@ public class SampleTests { } @Test - public void expectNeverViolated() { - + void expectNeverViolated() { String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; this.mockServer.expect(once(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) @@ -135,9 +126,8 @@ public class SampleTests { } @Test - public void performGetWithResponseBodyFromFile() { - - Resource responseBody = new ClassPathResource("ludwig.json", this.getClass()); + void performGetWithResponseBodyFromFile() { + Resource responseBody = new ClassPathResource("ludwig.json", getClass()); this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); @@ -152,8 +142,7 @@ public class SampleTests { } @Test - public void verify() { - + void verify() { this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess("1", MediaType.TEXT_PLAIN)); @@ -183,9 +172,8 @@ public class SampleTests { } @Test // SPR-14694 - public void repeatedAccessToResponseViaResource() { - - Resource resource = new ClassPathResource("ludwig.json", this.getClass()); + void repeatedAccessToResponseViaResource() { + Resource resource = new ClassPathResource("ludwig.json", getClass()); RestTemplate restTemplate = new RestTemplate(); restTemplate.setInterceptors(Collections.singletonList(new ContentInterceptor(resource))); 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 bc89c421981..8499c11baaa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -257,7 +257,7 @@ class PrintingResultHandlerTests { this.mvcResult.setHandler(handlerMethod); this.handler.handle(mvcResult); - assertValue("Handler", "Type", this.getClass().getName()); + assertValue("Handler", "Type", getClass().getName()); assertValue("Handler", "Method", handlerMethod); } diff --git a/spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java b/spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java index 1eff5410f17..d102f286102 100644 --- a/spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java +++ b/spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author 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 HttpMediaTypeNotAcceptableException extends HttpMediaTypeException return HttpHeaders.EMPTY; } HttpHeaders headers = new HttpHeaders(); - headers.setAccept(this.getSupportedMediaTypes()); + headers.setAccept(getSupportedMediaTypes()); return headers; } diff --git a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java index b0243ef603b..5644b332fd1 100644 --- a/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java +++ b/spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -237,7 +237,7 @@ public class InMemoryWebSessionStore implements WebSessionStore { InMemoryWebSessionStore.this.sessions.remove(currentId); String newId = String.valueOf(idGenerator.generateId()); this.id.set(newId); - InMemoryWebSessionStore.this.sessions.put(this.getId(), this); + InMemoryWebSessionStore.this.sessions.put(this.id.get(), this); return Mono.empty(); }) .subscribeOn(Schedulers.boundedElastic()) @@ -266,11 +266,11 @@ public class InMemoryWebSessionStore implements WebSessionStore { if (isStarted()) { // Save - InMemoryWebSessionStore.this.sessions.put(this.getId(), this); + InMemoryWebSessionStore.this.sessions.put(this.id.get(), this); // Unless it was invalidated if (this.state.get().equals(State.EXPIRED)) { - InMemoryWebSessionStore.this.sessions.remove(this.getId()); + InMemoryWebSessionStore.this.sessions.remove(this.id.get()); return Mono.error(new IllegalStateException("Session was invalidated")); } } diff --git a/spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java b/spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java index 44cb470d30e..5f0e6ade2d8 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java +++ b/spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -2040,7 +2040,7 @@ final class WhatWgUrlParser { if (obj == this) { return true; } - if (obj == null || obj.getClass() != this.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } UrlRecord that = (UrlRecord) obj; @@ -2322,7 +2322,7 @@ final class WhatWgUrlParser { @Override public boolean equals(Object obj) { - return obj == this || obj != null && obj.getClass() == this.getClass(); + return obj == this || obj != null && getClass() == obj.getClass(); } @Override diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 906b33de174..62da496dd3e 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -435,7 +435,7 @@ public class PathPattern implements Comparable { if (this.endsWithSeparatorWildcard) { String prefix = this.patternString.length() > 2 ? this.patternString.substring(0, this.patternString.length() - 2) : - String.valueOf(this.getSeparator()); + String.valueOf(getSeparator()); return this.parser.parse(concat(prefix, otherPattern.patternString)); } @@ -465,8 +465,8 @@ public class PathPattern implements Comparable { "Cannot combine patterns: " + this.patternString + " and " + otherPattern); } - String firstPath = this.patternString.substring(0, this.patternString.lastIndexOf(this.getSeparator())); - String secondPath = otherPattern.patternString.substring(0, otherPattern.patternString.lastIndexOf(this.getSeparator())); + String firstPath = this.patternString.substring(0, this.patternString.lastIndexOf(getSeparator())); + String secondPath = otherPattern.patternString.substring(0, otherPattern.patternString.lastIndexOf(getSeparator())); if (!this.parser.parse(firstPath).matches(PathContainer.parsePath(secondPath))) { throw new IllegalArgumentException( "Cannot combine patterns: " + this.patternString + " and " + otherPattern); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index b8c927bac51..bad20abb123 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -615,7 +615,7 @@ class Jackson2ObjectMapperBuilderTests { @Override public String getModuleName() { - return this.getClass().getSimpleName(); + return getClass().getSimpleName(); } @Override diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java index 5e3a55c0187..3d4972b8c5a 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -358,7 +358,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { @Override public String getModuleName() { - return this.getClass().getSimpleName(); + return getClass().getSimpleName(); } @Override diff --git a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java index a60dc55c200..f77feb43da1 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class CompositeUriComponentsContributorTests { resolvers.add(new RequestParamMethodArgumentResolver(true)); CompositeUriComponentsContributor contributor = new CompositeUriComponentsContributor(resolvers); - Method method = ClassUtils.getMethod(this.getClass(), "handleRequest", String.class, String.class, String.class); + Method method = ClassUtils.getMethod(getClass(), "handleRequest", String.class, String.class, String.class); assertThat(contributor.supportsParameter(new MethodParameter(method, 0))).isTrue(); assertThat(contributor.supportsParameter(new MethodParameter(method, 1))).isTrue(); assertThat(contributor.supportsParameter(new MethodParameter(method, 2))).isFalse(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java index d58fdbd9aa5..83ef3a92ccc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java @@ -428,7 +428,9 @@ public class ResourceWebHandler implements WebHandler, InitializingBean { public Mono handle(ServerWebExchange exchange) { return getResource(exchange) .switchIfEmpty(Mono.defer(() -> { - logger.debug(exchange.getLogPrefix() + "Resource not found"); + if (logger.isDebugEnabled()) { + logger.debug(exchange.getLogPrefix() + "Resource not found"); + } return Mono.error(new NoResourceFoundException(getResourcePath(exchange))); })) .flatMap(resource -> { @@ -446,10 +448,12 @@ public class ResourceWebHandler implements WebHandler, InitializingBean { } // Header phase - String eTagValue = (this.getEtagGenerator() != null) ? this.getEtagGenerator().apply(resource) : null; + String eTagValue = (getEtagGenerator() != null) ? getEtagGenerator().apply(resource) : null; Instant lastModified = isUseLastModified() ? Instant.ofEpochMilli(resource.lastModified()) : Instant.MIN; if (exchange.checkNotModified(eTagValue, lastModified)) { - logger.trace(exchange.getLogPrefix() + "Resource not modified"); + if (logger.isTraceEnabled()) { + logger.trace(exchange.getLogPrefix() + "Resource not modified"); + } return Mono.empty(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index 1e622521c26..933ba03f16c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ class MatrixVariablesMapMethodArgumentResolverTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); - private final ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); + private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); @BeforeEach diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index 3e8525ca7c2..95a0075f90f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class MatrixVariablesMethodArgumentResolverTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/")); - private ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); + private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); @BeforeEach @@ -65,7 +65,6 @@ class MatrixVariablesMethodArgumentResolverTests { @Test void supportsParameter() { - assertThat(this.resolver.supportsParameter(this.testMethod.arg(String.class))).isFalse(); assertThat(this.resolver.supportsParameter(this.testMethod diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index c4bafd0ae36..ba1b56338f6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -597,8 +597,8 @@ public class ResourceHttpRequestHandler extends WebContentGenerator prepareResponse(response); // Header phase - String eTagValue = (this.getEtagGenerator() != null) ? this.getEtagGenerator().apply(resource) : null; - long lastModified = (this.isUseLastModified()) ? resource.lastModified() : -1; + String eTagValue = (getEtagGenerator() != null ? getEtagGenerator().apply(resource) : null); + long lastModified = (isUseLastModified() ? resource.lastModified() : -1); if (new ServletWebRequest(request, response).checkNotModified(eTagValue, lastModified)) { logger.trace("Resource not modified"); return; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index aaed9261185..0cae5daf819 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class MatrixVariablesMapMethodArgumentResolverTests { private MockHttpServletRequest request; - private final ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); + private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); @BeforeEach diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index 142d30f79c3..424b36cd4f9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class MatrixVariablesMethodArgumentResolverTests { private MockHttpServletRequest request; - private ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); + private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); @BeforeEach diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java index c2bbb5a5776..de245502a08 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author 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,8 +62,8 @@ class RequestResponseBodyAdviceChainTests { private Class> converterType = StringHttpMessageConverter.class; - private MethodParameter paramType = new MethodParameter(ClassUtils.getMethod(this.getClass(), "handle", String.class), 0); - private MethodParameter returnType = new MethodParameter(ClassUtils.getMethod(this.getClass(), "handle", String.class), -1); + private MethodParameter paramType = new MethodParameter(ClassUtils.getMethod(getClass(), "handle", String.class), 0); + private MethodParameter returnType = new MethodParameter(ClassUtils.getMethod(getClass(), "handle", String.class), -1); private ServerHttpRequest request = new ServletServerHttpRequest(new MockHttpServletRequest()); private ServerHttpResponse response = new ServletServerHttpResponse(new MockHttpServletResponse()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java index 79bbffa587f..d5d8c442fdd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class UriComponentsBuilderMethodArgumentResolverTests { this.servletRequest = new MockHttpServletRequest(); this.webRequest = new ServletWebRequest(this.servletRequest); - Method method = this.getClass().getDeclaredMethod( + Method method = getClass().getDeclaredMethod( "handle", UriComponentsBuilder.class, ServletUriComponentsBuilder.class, int.class); this.builderParam = new MethodParameter(method, 0); this.servletBuilderParam = new MethodParameter(method, 1); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java index 36e335deb8d..91958511a2c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,7 +175,7 @@ class DefaultHandlerExceptionResolverTests { void handleMethodArgumentNotValid() throws Exception { BeanPropertyBindingResult errors = new BeanPropertyBindingResult(new TestBean(), "testBean"); errors.rejectValue("name", "invalid"); - MethodParameter parameter = new MethodParameter(this.getClass().getMethod("handle", String.class), 0); + MethodParameter parameter = new MethodParameter(getClass().getMethod("handle", String.class), 0); MethodArgumentNotValidException ex = new MethodArgumentNotValidException(parameter, errors); ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex); assertThat(mav).as("No ModelAndView returned").isNotNull(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java index c93f9fdb7d0..8cd3d901e04 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ class InputTagTests extends AbstractFormTagTests { final String NAME = "Rob \"I Love Cafés\" Harrop"; final String HTML_ESCAPED_NAME = "Rob "I Love Cafés" Harrop"; - this.getPageContext().getResponse().setCharacterEncoding("UTF-8"); + getPageContext().getResponse().setCharacterEncoding("UTF-8"); this.tag.setPath("name"); this.rob.setName(NAME); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java index cb1cfaacbb7..c7525140083 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author 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,9 +33,9 @@ class PasswordInputTagTests extends InputTagTests { @Test // SPR-2866 void passwordValueIsNotRenderedByDefault() throws Exception { - this.getTag().setPath("name"); + getTag().setPath("name"); - assertThat(this.getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); + assertThat(getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); String output = getOutput(); assertTagOpened(output); @@ -47,10 +47,10 @@ class PasswordInputTagTests extends InputTagTests { @Test // SPR-2866 void passwordValueIsRenderedIfShowPasswordAttributeIsSetToTrue() throws Exception { - this.getTag().setPath("name"); - this.getPasswordTag().setShowPassword(true); + getTag().setPath("name"); + getPasswordTag().setShowPassword(true); - assertThat(this.getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); + assertThat(getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); String output = getOutput(); assertTagOpened(output); @@ -62,10 +62,10 @@ class PasswordInputTagTests extends InputTagTests { @Test // >SPR-2866 void passwordValueIsNotRenderedIfShowPasswordAttributeIsSetToFalse() throws Exception { - this.getTag().setPath("name"); - this.getPasswordTag().setShowPassword(false); + getTag().setPath("name"); + getPasswordTag().setShowPassword(false); - assertThat(this.getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); + assertThat(getTag().doStartTag()).isEqualTo(Tag.SKIP_BODY); String output = getOutput(); assertTagOpened(output); @@ -78,14 +78,14 @@ class PasswordInputTagTests extends InputTagTests { @Test @Override public void dynamicTypeAttribute() { - assertThatIllegalArgumentException().isThrownBy(() -> - this.getTag().setDynamicAttribute(null, "type", "email")) - .withMessage("Attribute type=\"email\" is not allowed"); + assertThatIllegalArgumentException() + .isThrownBy(() -> getTag().setDynamicAttribute(null, "type", "email")) + .withMessage("Attribute type=\"email\" is not allowed"); } @Override protected void assertValueAttribute(String output, String expectedValue) { - if (this.getPasswordTag().isShowPassword()) { + if (getPasswordTag().isShowPassword()) { super.assertValueAttribute(output, expectedValue); } else { @@ -110,7 +110,7 @@ class PasswordInputTagTests extends InputTagTests { } private PasswordInputTag getPasswordTag() { - return (PasswordInputTag) this.getTag(); + return (PasswordInputTag) getTag(); } }