Remove code deprecated in 2.x and add since and forRemoval attributes

Closes gh-32548
Closes gh-32549
This commit is contained in:
Andy Wilkinson
2022-09-30 12:02:16 +01:00
parent 03b3a772c9
commit 51df7813a5
52 changed files with 85 additions and 560 deletions

View File

@@ -21,14 +21,6 @@ import javax.sql.DataSource;
import org.jooq.ConnectionProvider;
import org.jooq.DSLContext;
import org.jooq.ExecuteListenerProvider;
import org.jooq.ExecutorProvider;
import org.jooq.RecordListenerProvider;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordUnmapperProvider;
import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionProvider;
import org.jooq.VisitListenerProvider;
import org.jooq.conf.Settings;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultConfiguration;
import org.jooq.impl.DefaultDSLContext;
@@ -45,7 +37,6 @@ import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfigu
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.transaction.PlatformTransactionManager;
@@ -104,50 +95,6 @@ public class JooqAutoConfiguration {
return configuration;
}
@Bean
@Deprecated
public DefaultConfigurationCustomizer jooqProvidersDefaultConfigurationCustomizer(
ObjectProvider<TransactionProvider> transactionProvider,
ObjectProvider<RecordMapperProvider> recordMapperProvider,
ObjectProvider<RecordUnmapperProvider> recordUnmapperProvider, ObjectProvider<Settings> settings,
ObjectProvider<RecordListenerProvider> recordListenerProviders,
ObjectProvider<VisitListenerProvider> visitListenerProviders,
ObjectProvider<TransactionListenerProvider> transactionListenerProviders,
ObjectProvider<ExecutorProvider> executorProvider) {
return new OrderedDefaultConfigurationCustomizer((configuration) -> {
transactionProvider.ifAvailable(configuration::set);
recordMapperProvider.ifAvailable(configuration::set);
recordUnmapperProvider.ifAvailable(configuration::set);
settings.ifAvailable(configuration::set);
executorProvider.ifAvailable(configuration::set);
configuration.set(recordListenerProviders.orderedStream().toArray(RecordListenerProvider[]::new));
configuration.set(visitListenerProviders.orderedStream().toArray(VisitListenerProvider[]::new));
configuration.setTransactionListenerProvider(
transactionListenerProviders.orderedStream().toArray(TransactionListenerProvider[]::new));
});
}
}
private static class OrderedDefaultConfigurationCustomizer implements DefaultConfigurationCustomizer, Ordered {
private final DefaultConfigurationCustomizer delegate;
OrderedDefaultConfigurationCustomizer(DefaultConfigurationCustomizer delegate) {
this.delegate = delegate;
}
@Override
public void customize(DefaultConfiguration configuration) {
this.delegate.customize(configuration);
}
@Override
public int getOrder() {
return 0;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-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.
@@ -257,13 +257,13 @@ public class LiquibaseProperties {
this.labelFilter = labelFilter;
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@DeprecatedConfigurationProperty(replacement = "spring.liquibase.label-filter")
public String getLabels() {
return getLabelFilter();
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
public void setLabels(String labels) {
setLabelFilter(labels);
}

View File

@@ -22,7 +22,6 @@ import java.time.Duration;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.neo4j.driver.AuthToken;
@@ -72,17 +71,13 @@ public class Neo4jAutoConfiguration {
}
URI determineServerUri(Neo4jProperties properties, Environment environment) {
return getOrFallback(properties.getUri(), () -> {
URI deprecatedProperty = environment.getProperty("spring.data.neo4j.uri", URI.class);
return (deprecatedProperty != null) ? deprecatedProperty : DEFAULT_SERVER_URI;
});
URI uri = properties.getUri();
return (uri != null) ? uri : DEFAULT_SERVER_URI;
}
AuthToken mapAuthToken(Neo4jProperties.Authentication authentication, Environment environment) {
String username = getOrFallback(authentication.getUsername(),
() -> environment.getProperty("spring.data.neo4j.username", String.class));
String password = getOrFallback(authentication.getPassword(),
() -> environment.getProperty("spring.data.neo4j.password", String.class));
String username = authentication.getUsername();
String password = authentication.getPassword();
String kerberosTicket = authentication.getKerberosTicket();
String realm = authentication.getRealm();
@@ -103,13 +98,6 @@ public class Neo4jAutoConfiguration {
return AuthTokens.none();
}
private <T> T getOrFallback(T value, Supplier<T> fallback) {
if (value != null) {
return value;
}
return fallback.get();
}
Config mapDriverConfig(Neo4jProperties properties, List<ConfigBuilderCustomizer> customizers) {
Config.ConfigBuilder builder = Config.builder();
configurePoolSettings(builder, properties.getPool());

View File

@@ -1400,13 +1400,13 @@ public class ServerProperties {
this.initialBufferSize = initialBufferSize;
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@DeprecatedConfigurationProperty(reason = "Deprecated for removal in Reactor Netty")
public DataSize getMaxChunkSize() {
return this.maxChunkSize;
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
public void setMaxChunkSize(DataSize maxChunkSize) {
this.maxChunkSize = maxChunkSize;
}

View File

@@ -102,7 +102,7 @@ public class NettyWebServerFactoryCustomizer
}));
}
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
private void maxChunkSize(PropertyMapper propertyMapper, HttpRequestDecoderSpec httpRequestDecoderSpec,
ServerProperties.Netty nettyProperties) {
propertyMapper.from(nettyProperties.getMaxChunkSize()).whenNonNull()

View File

@@ -175,7 +175,6 @@ public class WebMvcAutoConfiguration {
// Defined as a nested config to ensure WebMvcConfigurer is not read when not
// on the classpath
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@Import(EnableWebMvcConfiguration.class)
@EnableConfigurationProperties({ WebMvcProperties.class, WebProperties.class })
@@ -212,7 +211,6 @@ public class WebMvcAutoConfiguration {
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizerProvider.getIfAvailable();
this.dispatcherServletPath = dispatcherServletPath;
this.servletRegistrations = servletRegistrations;
this.mvcProperties.checkConfiguration();
}
@Override
@@ -246,9 +244,6 @@ public class WebMvcAutoConfiguration {
if (this.mvcProperties.getPathmatch()
.getMatchingStrategy() == WebMvcProperties.MatchingStrategy.ANT_PATH_MATCHER) {
configurer.setPathMatcher(new AntPathMatcher());
configurer.setUseSuffixPatternMatch(this.mvcProperties.getPathmatch().isUseSuffixPattern());
configurer.setUseRegisteredSuffixPatternMatch(
this.mvcProperties.getPathmatch().isUseRegisteredSuffixPattern());
this.dispatcherServletPath.ifAvailable((dispatcherPath) -> {
String servletUrlMapping = dispatcherPath.getServletUrlMapping();
if (servletUrlMapping.equals("/") && singleDispatcherServlet()) {
@@ -268,7 +263,6 @@ public class WebMvcAutoConfiguration {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
WebMvcProperties.Contentnegotiation contentnegotiation = this.mvcProperties.getContentnegotiation();
configurer.favorPathExtension(contentnegotiation.isFavorPathExtension());
configurer.favorParameter(contentnegotiation.isFavorParameter());
if (contentnegotiation.getParameterName() != null) {
configurer.parameterName(contentnegotiation.getParameterName());
@@ -417,7 +411,7 @@ public class WebMvcAutoConfiguration {
return adapter;
}
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
private void setIgnoreDefaultModelOnRedirect(RequestMappingHandlerAdapter adapter) {
adapter.setIgnoreDefaultModelOnRedirect(
this.mvcProperties == null || this.mvcProperties.isIgnoreDefaultModelOnRedirect());
@@ -460,7 +454,7 @@ public class WebMvcAutoConfiguration {
@Override
@Bean
@ConditionalOnMissingBean(name = DispatcherServlet.THEME_RESOLVER_BEAN_NAME)
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = false)
@SuppressWarnings("deprecation")
public org.springframework.web.servlet.ThemeResolver themeResolver() {
return super.themeResolver();

View File

@@ -22,7 +22,6 @@ import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.context.properties.IncompatibleConfigurationException;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.validation.DefaultMessageCodesResolver;
@@ -115,28 +114,17 @@ public class WebMvcProperties {
this.messageCodesResolverFormat = messageCodesResolverFormat;
}
@Deprecated
@DeprecatedConfigurationProperty(replacement = "spring.mvc.format.date")
public String getDateFormat() {
return this.format.getDate();
}
@Deprecated
public void setDateFormat(String dateFormat) {
this.format.setDate(dateFormat);
}
public Format getFormat() {
return this.format;
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@DeprecatedConfigurationProperty(reason = "Deprecated for removal in Spring MVC")
public boolean isIgnoreDefaultModelOnRedirect() {
return this.ignoreDefaultModelOnRedirect;
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect) {
this.ignoreDefaultModelOnRedirect = ignoreDefaultModelOnRedirect;
}
@@ -225,19 +213,6 @@ public class WebMvcProperties {
return this.pathmatch;
}
public void checkConfiguration() {
if (this.getPathmatch().getMatchingStrategy() == MatchingStrategy.PATH_PATTERN_PARSER) {
if (this.getPathmatch().isUseSuffixPattern()) {
throw new IncompatibleConfigurationException("spring.mvc.pathmatch.matching-strategy",
"spring.mvc.pathmatch.use-suffix-pattern");
}
if (this.getPathmatch().isUseRegisteredSuffixPattern()) {
throw new IncompatibleConfigurationException("spring.mvc.pathmatch.matching-strategy",
"spring.mvc.pathmatch.use-registered-suffix-pattern");
}
}
}
public static class Async {
/**
@@ -351,13 +326,6 @@ public class WebMvcProperties {
public static class Contentnegotiation {
/**
* Whether the path extension in the URL path should be used to determine the
* requested media type. If enabled a request "/users.pdf" will be interpreted as
* a request for "application/pdf" regardless of the 'Accept' header.
*/
private boolean favorPathExtension = false;
/**
* Whether a request parameter ("format" by default) should be used to determine
* the requested media type.
@@ -375,18 +343,6 @@ public class WebMvcProperties {
*/
private String parameterName;
@DeprecatedConfigurationProperty(
reason = "Use of path extensions for request mapping and for content negotiation is discouraged.")
@Deprecated
public boolean isFavorPathExtension() {
return this.favorPathExtension;
}
@Deprecated
public void setFavorPathExtension(boolean favorPathExtension) {
this.favorPathExtension = favorPathExtension;
}
public boolean isFavorParameter() {
return this.favorParameter;
}
@@ -420,22 +376,6 @@ public class WebMvcProperties {
*/
private MatchingStrategy matchingStrategy = MatchingStrategy.PATH_PATTERN_PARSER;
/**
* Whether to use suffix pattern match (".*") when matching patterns to requests.
* If enabled a method mapped to "/users" also matches to "/users.*". Enabling
* this option is not compatible with the PathPatternParser matching strategy.
*/
private boolean useSuffixPattern = false;
/**
* Whether suffix pattern matching should work only against extensions registered
* with "spring.mvc.contentnegotiation.media-types.*". This is generally
* recommended to reduce ambiguity and to avoid issues such as when a "." appears
* in the path for other reasons. Enabling this option is not compatible with the
* PathPatternParser matching strategy.
*/
private boolean useRegisteredSuffixPattern = false;
public MatchingStrategy getMatchingStrategy() {
return this.matchingStrategy;
}
@@ -444,30 +384,6 @@ public class WebMvcProperties {
this.matchingStrategy = matchingStrategy;
}
@DeprecatedConfigurationProperty(
reason = "Use of path extensions for request mapping and for content negotiation is discouraged.")
@Deprecated
public boolean isUseSuffixPattern() {
return this.useSuffixPattern;
}
@Deprecated
public void setUseSuffixPattern(boolean useSuffixPattern) {
this.useSuffixPattern = useSuffixPattern;
}
@DeprecatedConfigurationProperty(
reason = "Use of path extensions for request mapping and for content negotiation is discouraged.")
@Deprecated
public boolean isUseRegisteredSuffixPattern() {
return this.useRegisteredSuffixPattern;
}
@Deprecated
public void setUseRegisteredSuffixPattern(boolean useRegisteredSuffixPattern) {
this.useRegisteredSuffixPattern = useRegisteredSuffixPattern;
}
}
public static class Format {

View File

@@ -1034,7 +1034,7 @@
"description": "Login password of the server.",
"deprecation": {
"replacement": "spring.neo4j.authentication.password",
"level": "warning"
"level": "error"
}
},
{
@@ -1059,7 +1059,7 @@
"description": "URI used by the driver. Auto-detected by default.",
"deprecation": {
"replacement": "spring.neo4j.uri",
"level": "warning"
"level": "error"
}
},
{
@@ -1077,7 +1077,7 @@
"description": "Login user of the server.",
"deprecation": {
"replacement": "spring.neo4j.authentication.username",
"level": "warning"
"level": "error"
}
},
{
@@ -2047,6 +2047,14 @@
"type": "java.lang.String",
"description": "Preferred JSON mapper to use for HTTP message conversion. By default, auto-detected according to the environment."
},
{
"name": "spring.mvc.date-format",
"type": "java.lang.String",
"description": "Date format to use, for example 'dd/MM/yyyy'.",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.mvc.favicon.enabled",
"type": "java.lang.Boolean",

View File

@@ -24,14 +24,8 @@ import org.jooq.ConverterProvider;
import org.jooq.DSLContext;
import org.jooq.ExecuteListener;
import org.jooq.ExecuteListenerProvider;
import org.jooq.ExecutorProvider;
import org.jooq.RecordListenerProvider;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordUnmapperProvider;
import org.jooq.SQLDialect;
import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionalRunnable;
import org.jooq.VisitListenerProvider;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultExecuteListenerProvider;
import org.junit.jupiter.api.Test;
@@ -153,33 +147,6 @@ class JooqAutoConfigurationTests {
});
}
@Test
@Deprecated
void customProvidersArePickedUp() {
RecordMapperProvider recordMapperProvider = mock(RecordMapperProvider.class);
RecordUnmapperProvider recordUnmapperProvider = mock(RecordUnmapperProvider.class);
RecordListenerProvider recordListenerProvider = mock(RecordListenerProvider.class);
VisitListenerProvider visitListenerProvider = mock(VisitListenerProvider.class);
TransactionListenerProvider transactionListenerProvider = mock(TransactionListenerProvider.class);
ExecutorProvider executorProvider = mock(ExecutorProvider.class);
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class, TxManagerConfiguration.class)
.withBean(RecordMapperProvider.class, () -> recordMapperProvider)
.withBean(RecordUnmapperProvider.class, () -> recordUnmapperProvider)
.withBean(RecordListenerProvider.class, () -> recordListenerProvider)
.withBean(VisitListenerProvider.class, () -> visitListenerProvider)
.withBean(TransactionListenerProvider.class, () -> transactionListenerProvider)
.withBean(ExecutorProvider.class, () -> executorProvider).run((context) -> {
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().recordMapperProvider()).isSameAs(recordMapperProvider);
assertThat(dsl.configuration().recordUnmapperProvider()).isSameAs(recordUnmapperProvider);
assertThat(dsl.configuration().executorProvider()).isSameAs(executorProvider);
assertThat(dsl.configuration().recordListenerProviders()).containsExactly(recordListenerProvider);
assertThat(dsl.configuration().visitListenerProviders()).containsExactly(visitListenerProvider);
assertThat(dsl.configuration().transactionListenerProviders())
.containsExactly(transactionListenerProvider);
});
}
@Test
void relaxedBindingOfSqlDialect() {
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class)

View File

@@ -303,7 +303,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
void overrideLabelFilterWithDeprecatedLabelsProperty() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.labels:test, production").run(assertLiquibase(

View File

@@ -131,26 +131,6 @@ class Neo4jAutoConfigurationTests {
assertThat(determineServerUri(properties, new MockEnvironment())).isEqualTo(customUri);
}
@Test
@Deprecated
void determineServerUriWithDeprecatedPropertyShouldOverrideDefault() {
URI customUri = URI.create("bolt://localhost:4242");
MockEnvironment environment = new MockEnvironment().withProperty("spring.data.neo4j.uri", customUri.toString());
assertThat(determineServerUri(new Neo4jProperties(), environment)).isEqualTo(customUri);
}
@Test
@Deprecated
void determineServerUriWithCustomUriShouldTakePrecedenceOverDeprecatedProperty() {
URI customUri = URI.create("bolt://localhost:4242");
URI anotherCustomURI = URI.create("bolt://localhost:2424");
Neo4jProperties properties = new Neo4jProperties();
properties.setUri(customUri);
MockEnvironment environment = new MockEnvironment().withProperty("spring.data.neo4j.uri",
anotherCustomURI.toString());
assertThat(determineServerUri(properties, environment)).isEqualTo(customUri);
}
@Test
void authenticationShouldDefaultToNone() {
assertThat(mapAuthToken(new Authentication())).isEqualTo(AuthTokens.none());
@@ -173,25 +153,6 @@ class Neo4jAutoConfigurationTests {
assertThat(mapAuthToken(authentication)).isEqualTo(AuthTokens.basic("Farin", "Urlaub", "Test Realm"));
}
@Test
@Deprecated
void authenticationWithUsernameUsingDeprecatedPropertiesShouldEnableBasicAuth() {
MockEnvironment environment = new MockEnvironment().withProperty("spring.data.neo4j.username", "user")
.withProperty("spring.data.neo4j.password", "secret");
assertThat(mapAuthToken(new Authentication(), environment)).isEqualTo(AuthTokens.basic("user", "secret"));
}
@Test
@Deprecated
void authenticationWithUsernameShouldTakePrecedenceOverDeprecatedPropertiesAndEnableBasicAuth() {
MockEnvironment environment = new MockEnvironment().withProperty("spring.data.neo4j.username", "user")
.withProperty("spring.data.neo4j.password", "secret");
Authentication authentication = new Authentication();
authentication.setUsername("Farin");
authentication.setPassword("Urlaub");
assertThat(mapAuthToken(authentication, environment)).isEqualTo(AuthTokens.basic("Farin", "Urlaub"));
}
@Test
void authenticationWithKerberosTicketShouldEnableKerberos() {
Authentication authentication = new Authentication();

View File

@@ -516,7 +516,8 @@ class ServerPropertiesTests {
}
@Test
@SuppressWarnings("deprecation")
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings("removal")
void nettyMaxChunkSizeMatchesHttpDecoderSpecDefault() {
assertThat(this.properties.getNetty().getMaxChunkSize().toBytes())
.isEqualTo(HttpDecoderSpec.DEFAULT_MAX_CHUNK_SIZE);

View File

@@ -147,12 +147,12 @@ class NettyWebServerFactoryCustomizerTests {
assertThat(decoder.maxInitialLineLength()).isEqualTo(nettyProperties.getMaxInitialLineLength().toBytes());
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
private void setMaxChunkSize(ServerProperties.Netty nettyProperties) {
nettyProperties.setMaxChunkSize(DataSize.ofKilobytes(16));
}
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
private void assertMaxChunkSize(ServerProperties.Netty nettyProperties, HttpRequestDecoderSpec decoder) {
assertThat(decoder.maxChunkSize()).isEqualTo(nettyProperties.getMaxChunkSize().toBytes());
}

View File

@@ -46,7 +46,6 @@ import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguratio
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.autoconfigure.validation.ValidatorAdapter;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
import org.springframework.boot.context.properties.IncompatibleConfigurationException;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
@@ -70,7 +69,6 @@ import org.springframework.format.Printer;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.util.ReflectionTestUtils;
@@ -78,10 +76,8 @@ import org.springframework.util.StringUtils;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.accept.ContentNegotiationStrategy;
import org.springframework.web.accept.ParameterContentNegotiationStrategy;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.FormContentFilter;
@@ -371,7 +367,7 @@ class WebMvcAutoConfigurationTests {
}
@Test
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings("deprecation")
void customThemeResolverWithMatchingNameReplacesDefaultThemeResolver() {
this.contextRunner.withBean("themeResolver", CustomThemeResolver.class, CustomThemeResolver::new)
@@ -382,7 +378,7 @@ class WebMvcAutoConfigurationTests {
}
@Test
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings("deprecation")
void customThemeResolverWithDifferentNameDoesNotReplaceDefaultThemeResolver() {
this.contextRunner.withBean("customThemeResolver", CustomThemeResolver.class, CustomThemeResolver::new)
@@ -430,15 +426,6 @@ class WebMvcAutoConfigurationTests {
});
}
@Test
void customDateFormatWithDeprecatedProperty() {
this.contextRunner.withPropertyValues("spring.mvc.date-format:dd*MM*yyyy").run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
Date date = Date.from(ZonedDateTime.of(1988, 6, 25, 20, 30, 0, 0, ZoneId.systemDefault()).toInstant());
assertThat(conversionService.convert(date, String.class)).isEqualTo("25*06*1988");
});
}
@Test
void defaultTimeFormat() {
this.contextRunner.run((context) -> {
@@ -570,10 +557,9 @@ class WebMvcAutoConfigurationTests {
}
@Test
@Deprecated
void customMediaTypes() {
this.contextRunner.withPropertyValues("spring.mvc.contentnegotiation.media-types.yaml:text/yaml",
"spring.mvc.contentnegotiation.favor-path-extension:true").run((context) -> {
this.contextRunner.withPropertyValues("spring.mvc.contentnegotiation.media-types.yaml:text/yaml")
.run((context) -> {
RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class);
ContentNegotiationManager contentNegotiationManager = (ContentNegotiationManager) ReflectionTestUtils
.getField(adapter, "contentNegotiationManager");
@@ -841,29 +827,6 @@ class WebMvcAutoConfigurationTests {
}));
}
@Test
@SuppressWarnings("deprecation")
void defaultPathMatching() {
this.contextRunner.run((context) -> {
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
assertThat(handlerMapping.useSuffixPatternMatch()).isFalse();
assertThat(handlerMapping.useRegisteredSuffixPatternMatch()).isFalse();
});
}
@Test
@Deprecated
@SuppressWarnings("deprecation")
void useSuffixPatternMatch() {
this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy=ant-path-matcher",
"spring.mvc.pathmatch.use-suffix-pattern:true",
"spring.mvc.pathmatch.use-registered-suffix-pattern:true").run((context) -> {
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
assertThat(handlerMapping.useSuffixPatternMatch()).isTrue();
assertThat(handlerMapping.useRegisteredSuffixPatternMatch()).isTrue();
});
}
@Test
void usePathPatternParser() {
this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy:path_pattern_parser")
@@ -873,15 +836,6 @@ class WebMvcAutoConfigurationTests {
});
}
@Test
void incompatiblePathMatchingConfiguration() {
this.contextRunner
.withPropertyValues("spring.mvc.pathmatch.matching-strategy:path_pattern_parser",
"spring.mvc.pathmatch.use-suffix-pattern:true")
.run((context) -> assertThat(context.getStartupFailure()).rootCause()
.isInstanceOf(IncompatibleConfigurationException.class));
}
@Test
void defaultContentNegotiation() {
this.contextRunner.run((context) -> {
@@ -893,19 +847,6 @@ class WebMvcAutoConfigurationTests {
}
@Test
@Deprecated
void pathExtensionContentNegotiation() {
this.contextRunner.withPropertyValues("spring.mvc.contentnegotiation.favor-path-extension:true")
.run((context) -> {
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
ContentNegotiationManager contentNegotiationManager = handlerMapping.getContentNegotiationManager();
assertThat(contentNegotiationManager.getStrategies()).hasAtLeastOneElementOfType(
WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy.class);
});
}
@Test
@Deprecated
void queryParameterContentNegotiation() {
this.contextRunner.withPropertyValues("spring.mvc.contentnegotiation.favor-parameter:true").run((context) -> {
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
@@ -925,21 +866,6 @@ class WebMvcAutoConfigurationTests {
});
}
@Test
@SuppressWarnings("deprecation")
void contentNegotiationStrategySkipsPathExtension() throws Exception {
ContentNegotiationStrategy delegate = mock(ContentNegotiationStrategy.class);
ContentNegotiationStrategy strategy = new WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy(
delegate);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(
org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class.getName() + ".SKIP",
Boolean.TRUE);
ServletWebRequest webRequest = new ServletWebRequest(request);
List<MediaType> mediaTypes = strategy.resolveMediaTypes(webRequest);
assertThat(mediaTypes).containsOnly(MediaType.ALL);
}
@Test
void requestContextFilterIsAutoConfigured() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RequestContextFilter.class));
@@ -1485,7 +1411,7 @@ class WebMvcAutoConfigurationTests {
}
@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
static class CustomThemeResolver implements org.springframework.web.servlet.ThemeResolver {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-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.
@@ -22,7 +22,6 @@ import java.util.Map;
import org.assertj.core.util.Throwables;
import org.junit.jupiter.api.Test;
import org.springframework.boot.context.properties.IncompatibleConfigurationException;
import org.springframework.boot.context.properties.bind.BindException;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
@@ -62,24 +61,6 @@ class WebMvcPropertiesTests {
(ex) -> assertThat(Throwables.getRootCause(ex)).hasMessage("Path must not contain wildcards"));
}
@Test
@SuppressWarnings("deprecation")
void incompatiblePathMatchSuffixConfig() {
this.properties.getPathmatch().setMatchingStrategy(WebMvcProperties.MatchingStrategy.PATH_PATTERN_PARSER);
this.properties.getPathmatch().setUseSuffixPattern(true);
assertThatExceptionOfType(IncompatibleConfigurationException.class)
.isThrownBy(this.properties::checkConfiguration);
}
@Test
@SuppressWarnings("deprecation")
void incompatiblePathMatchRegisteredSuffixConfig() {
this.properties.getPathmatch().setMatchingStrategy(WebMvcProperties.MatchingStrategy.PATH_PATTERN_PARSER);
this.properties.getPathmatch().setUseRegisteredSuffixPattern(true);
assertThatExceptionOfType(IncompatibleConfigurationException.class)
.isThrownBy(this.properties::checkConfiguration);
}
private void bind(String name, String value) {
bind(Collections.singletonMap(name, value));
}