Merge branch '5.3.x'

This commit is contained in:
Sam Brannen
2022-01-10 14:21:25 +01:00
72 changed files with 334 additions and 322 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ServletWebArgumentR
import org.springframework.web.util.UrlPathHelper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
/**
* Test fixture for the configuration in mvc-config-annotation-driven.xml.
@@ -73,7 +74,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
assertThat(resolver).isNotNull();
assertThat(resolver.getClass()).isEqualTo(TestMessageCodesResolver.class);
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false);
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -145,6 +145,7 @@ import org.springframework.web.util.UrlPathHelper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
/**
* Tests loading actual MVC namespace configuration.
@@ -206,7 +207,7 @@ public class MvcNamespaceTests {
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertThat(adapter).isNotNull();
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false);
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse();
List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
assertThat(converters.size() > 0).isTrue();
@@ -321,7 +322,7 @@ public class MvcNamespaceTests {
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertThat(adapter).isNotNull();
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(true);
assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isTrue();
// default web binding initializer behavior test
MockHttpServletRequest request = new MockHttpServletRequest();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -65,7 +65,7 @@ public class CorsRegistryTests {
assertThat(config.getAllowedMethods()).isEqualTo(Collections.singletonList("DELETE"));
assertThat(config.getAllowedHeaders()).isEqualTo(Arrays.asList("header1", "header2"));
assertThat(config.getExposedHeaders()).isEqualTo(Arrays.asList("header3", "header4"));
assertThat(config.getAllowCredentials()).isEqualTo(false);
assertThat(config.getAllowCredentials()).isFalse();
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(3600));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -245,9 +245,9 @@ public class DelegatingWebMvcConfigurationTests {
webMvcConfig.mvcResourceUrlProvider());
assertThat(annotationsMapping).isNotNull();
assertThat(annotationsMapping.useRegisteredSuffixPatternMatch()).isEqualTo(true);
assertThat(annotationsMapping.useSuffixPatternMatch()).isEqualTo(true);
assertThat(annotationsMapping.useTrailingSlashMatch()).isEqualTo(false);
assertThat(annotationsMapping.useRegisteredSuffixPatternMatch()).isTrue();
assertThat(annotationsMapping.useSuffixPatternMatch()).isTrue();
assertThat(annotationsMapping.useTrailingSlashMatch()).isFalse();
configAssertion.accept(annotationsMapping.getUrlPathHelper(), annotationsMapping.getPathMatcher());
SimpleUrlHandlerMapping mapping = (SimpleUrlHandlerMapping) webMvcConfig.viewControllerHandlerMapping(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -89,6 +89,7 @@ import org.springframework.web.util.UrlPathHelper;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
import static org.mockito.Mockito.mock;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.http.MediaType.APPLICATION_XML;
@@ -241,7 +242,7 @@ public class WebMvcConfigurationSupportExtensionTests {
(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
assertThat(deferredResultInterceptors.length).isEqualTo(1);
assertThat(fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false);
assertThat(fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -157,7 +157,7 @@ public class CookieLocaleResolverTests {
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie).isNotNull();
assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie.getDomain()).isEqualTo(null);
assertThat(cookie.getDomain()).isNull();
assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH);
assertThat(cookie.getSecure()).isFalse();
@@ -243,7 +243,7 @@ public class CookieLocaleResolverTests {
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie).isNotNull();
assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie.getDomain()).isEqualTo(null);
assertThat(cookie.getDomain()).isNull();
assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH);
assertThat(cookie.getSecure()).isFalse();
assertThat(cookie.getValue()).isEqualTo("de-AT");
@@ -269,7 +269,7 @@ public class CookieLocaleResolverTests {
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie).isNotNull();
assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
assertThat(cookie.getDomain()).isEqualTo(null);
assertThat(cookie.getDomain()).isNull();
assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH);
assertThat(cookie.getSecure()).isFalse();
assertThat(cookie.getValue()).isEqualTo("de_AT");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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 RequestMappingInfoTests {
assertThat(info.getMethodsCondition().getMethods().size()).isEqualTo(0);
assertThat(info.getParamsCondition()).isNotNull();
assertThat(info.getHeadersCondition()).isNotNull();
assertThat(info.getConsumesCondition().isEmpty()).isEqualTo(true);
assertThat(info.getProducesCondition().isEmpty()).isEqualTo(true);
assertThat(info.getConsumesCondition().isEmpty()).isTrue();
assertThat(info.getProducesCondition().isEmpty()).isTrue();
assertThat(info.getCustomCondition()).isNull();
RequestMappingInfo anotherInfo = infoBuilder.build();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ public class ExtendedServletRequestDataBinderTests {
WebDataBinder binder = new ExtendedServletRequestDataBinder(target, "");
((ServletRequestDataBinder) binder).bind(request);
assertThat(target.getName()).isEqualTo(null);
assertThat(target.getName()).isNull();
assertThat(target.getAge()).isEqualTo(0);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -139,7 +139,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest);
ModelMap model = mavContainer.getModel();
assertThat(mavContainer.getView()).isEqualTo(null);
assertThat(mavContainer.getView()).isNull();
assertThat(mavContainer.getModel().isEmpty()).isTrue();
assertThat(model).as("RedirectAttributes should not be used if controller doesn't redirect").isNotSameAs(redirectAttributes);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -247,7 +247,7 @@ public class RequestMappingHandlerAdapterTests {
assertThat(mav.getModel().get("attr1")).isEqualTo("lAttr1");
assertThat(mav.getModel().get("attr2")).isEqualTo("gAttr2");
assertThat(mav.getModel().get("attr3")).isEqualTo(null);
assertThat(mav.getModel().get("attr3")).isNull();
}
// SPR-10859

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -76,7 +76,7 @@ public class MappingJackson2JsonViewTests {
@Test
public void isExposePathVars() {
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false);
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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,6 +47,7 @@ import org.springframework.web.testfixture.servlet.MockServletContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
import static org.junit.jupiter.api.condition.JRE.JAVA_15;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
@@ -113,7 +114,7 @@ public class ScriptTemplateViewTests {
assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
assertThat(accessor.getPropertyValue("contentType")).isEqualTo(MediaType.TEXT_PLAIN_VALUE);
assertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.ISO_8859_1);
assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue();
}
@Test
@@ -301,7 +302,7 @@ public class ScriptTemplateViewTests {
assertThat(engine2).isNotNull();
assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue();
}
@Test // gh-23258
@@ -319,7 +320,7 @@ public class ScriptTemplateViewTests {
assertThat(engine2).isNotNull();
assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(false);
assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isFalse();
}
private interface InvocableScriptEngine extends ScriptEngine, Invocable {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ public class MappingJackson2XmlViewTests {
@Test
public void isExposePathVars() {
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false);
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -66,12 +66,12 @@ public class MarshallingViewTests {
@Test
public void isExposePathVars() {
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false);
assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse();
}
@Test
public void isExposePathVarsDefaultConstructor() {
assertThat(new MarshallingView().isExposePathVariables()).as("Must not expose path variables").isEqualTo(false);
assertThat(new MarshallingView().isExposePathVariables()).as("Must not expose path variables").isFalse();
}
@Test