Browse Source

Polishing and removal of "this." for method invocations

pull/35405/head
Sam Brannen 6 months ago
parent
commit
18d6a55e3e
  1. 6
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java
  2. 10
      spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java
  3. 2
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
  4. 4
      spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java
  5. 6
      spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java
  6. 16
      spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java
  7. 7
      spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java
  8. 4
      spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java
  9. 2
      spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java
  10. 4
      spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java
  11. 2
      spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java
  12. 4
      spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java
  13. 4
      spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java
  14. 2
      spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
  15. 8
      spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java
  16. 16
      spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java
  17. 4
      spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java
  18. 42
      spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java
  19. 4
      spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java
  20. 4
      spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java
  21. 8
      spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java
  22. 6
      spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java
  23. 8
      spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java
  24. 4
      spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java
  25. 4
      spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java
  26. 4
      spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java
  27. 10
      spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java
  28. 4
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java
  29. 5
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java
  30. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
  31. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java
  32. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java
  33. 6
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java
  34. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java
  35. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java
  36. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java
  37. 28
      spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java

6
spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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

10
spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -71,6 +72,7 @@ class FactoryBeanLookupTests {
Foo foo = beanFactory.getBean("fooFactory", Foo.class);
assertThat(foo).isNotNull();
}
}
class FooFactoryBean extends AbstractFactoryBean<Foo> {

2
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java

@ -2453,7 +2453,7 @@ class AutowiredAnnotationBeanPostProcessorTests { @@ -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);

4
spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}

6
spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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");
}

16
spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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);

7
spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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() {

4
spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java vendored

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}

2
spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java

@ -170,7 +170,7 @@ class PropertySourcesPlaceholderConfigurerTests { @@ -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");

4
spring-core/src/main/java/org/springframework/aot/hint/AbstractTypeReference.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

2
spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java vendored

@ -198,7 +198,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -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);
}
}

4
spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");
}

4
spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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;

2
spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java

@ -276,7 +276,7 @@ class VariableAndFunctionTests extends AbstractExpressionTests { @@ -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))

8
spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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(() ->

16
spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -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";

4
spring-test/src/test/java/org/springframework/test/util/subpackage/PersonEntity.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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)

42
spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 @@ -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
*
* <p>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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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)));

4
spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}

4
spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotAcceptableException.java

@ -1,5 +1,5 @@ @@ -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 @@ -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;
}

8
spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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"));
}
}

6
spring-web/src/main/java/org/springframework/web/util/WhatWgUrlParser.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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

8
spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java

@ -1,5 +1,5 @@ @@ -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<PathPattern> { @@ -435,7 +435,7 @@ public class PathPattern implements Comparable<PathPattern> {
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<PathPattern> { @@ -465,8 +465,8 @@ public class PathPattern implements Comparable<PathPattern> {
"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);

4
spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -615,7 +615,7 @@ class Jackson2ObjectMapperBuilderTests {
@Override
public String getModuleName() {
return this.getClass().getSimpleName();
return getClass().getSimpleName();
}
@Override

4
spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -358,7 +358,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
@Override
public String getModuleName() {
return this.getClass().getSimpleName();
return getClass().getSimpleName();
}
@Override

4
spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

10
spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java

@ -428,7 +428,9 @@ public class ResourceWebHandler implements WebHandler, InitializingBean { @@ -428,7 +428,9 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
public Mono<Void> 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 { @@ -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();
}

4
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

5
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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

4
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java

@ -597,8 +597,8 @@ public class ResourceHttpRequestHandler extends WebContentGenerator @@ -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;

4
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

4
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

6
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -62,8 +62,8 @@ class RequestResponseBodyAdviceChainTests {
private Class<? extends HttpMessageConverter<?>> 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());

4
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

4
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

4
spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -117,7 +117,7 @@ class InputTagTests extends AbstractFormTagTests {
final String NAME = "Rob \"I Love Cafés\" Harrop";
final String HTML_ESCAPED_NAME = "Rob &quot;I Love Cafés&quot; Harrop";
this.getPageContext().getResponse().setCharacterEncoding("UTF-8");
getPageContext().getResponse().setCharacterEncoding("UTF-8");
this.tag.setPath("name");
this.rob.setName(NAME);

28
spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -110,7 +110,7 @@ class PasswordInputTagTests extends InputTagTests {
}
private PasswordInputTag getPasswordTag() {
return (PasswordInputTag) this.getTag();
return (PasswordInputTag) getTag();
}
}

Loading…
Cancel
Save