Suppress warnings, remove unused code, etc.

This commit is contained in:
Sam Brannen
2020-06-20 16:42:36 +02:00
parent 2f0970b184
commit 9d5881e0ad
53 changed files with 418 additions and 449 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,6 @@ import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.servlet.theme.SessionThemeResolver;
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.ResourceBundleViewResolver;
import org.springframework.web.util.WebUtils;
/**
@@ -77,6 +76,7 @@ import org.springframework.web.util.WebUtils;
public class ComplexWebApplicationContext extends StaticWebApplicationContext {
@Override
@SuppressWarnings("deprecation")
public void refresh() throws BeansException {
registerSingleton(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, SessionLocaleResolver.class);
registerSingleton(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, SessionThemeResolver.class);
@@ -126,7 +126,7 @@ public class ComplexWebApplicationContext extends StaticWebApplicationContext {
pvs = new MutablePropertyValues();
pvs.add("order", 0);
pvs.add("basename", "org.springframework.web.servlet.complexviews");
registerSingleton("viewResolver", ResourceBundleViewResolver.class, pvs);
registerSingleton("viewResolver", org.springframework.web.servlet.view.ResourceBundleViewResolver.class, pvs);
pvs = new MutablePropertyValues();
pvs.add("suffix", ".jsp");

View File

@@ -38,7 +38,6 @@ import org.springframework.web.servlet.mvc.LastModified;
import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.servlet.theme.AbstractThemeResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.XmlViewResolver;
/**
* @author Juergen Hoeller
@@ -47,6 +46,7 @@ import org.springframework.web.servlet.view.XmlViewResolver;
public class SimpleWebApplicationContext extends StaticWebApplicationContext {
@Override
@SuppressWarnings("deprecation")
public void refresh() throws BeansException {
registerSingleton("/locale.do", LocaleChecker.class);
@@ -62,7 +62,7 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
registerSingleton("viewResolver2", XmlViewResolver.class, pvs);
registerSingleton("viewResolver2", org.springframework.web.servlet.view.XmlViewResolver.class, pvs);
super.refresh();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -77,6 +77,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
}
@Test
@SuppressWarnings("deprecation")
public void testPathMatchingConfiguration() {
loadBeanDefinitions("mvc-config-path-matching.xml");
RequestMappingHandlerMapping hm = this.appContext.getBean(RequestMappingHandlerMapping.class);

View File

@@ -350,6 +350,7 @@ public class MvcNamespaceTests {
}
@Test
@SuppressWarnings("deprecation")
public void testResources() throws Exception {
loadBeanDefinitions("mvc-config-resources.xml");

View File

@@ -203,12 +203,14 @@ public class DelegatingWebMvcConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
public void configurePathMatcher() {
PathMatcher pathMatcher = mock(PathMatcher.class);
UrlPathHelper pathHelper = mock(UrlPathHelper.class);
WebMvcConfigurer configurer = new WebMvcConfigurer() {
@Override
@SuppressWarnings("deprecation")
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseRegisteredSuffixPatternMatch(true)
.setUseTrailingSlashMatch(false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -177,6 +177,7 @@ public class InterceptorRegistryTests {
}
@SuppressWarnings("deprecation")
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
PathMatcher pathMatcher = new AntPathMatcher();
List<HandlerInterceptor> result = new ArrayList<>();

View File

@@ -263,6 +263,7 @@ public class WebMvcConfigurationSupportExtensionTests {
}
@Test
@SuppressWarnings("deprecation")
public void contentNegotiation() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.json");
NativeWebRequest webRequest = new ServletWebRequest(request);

View File

@@ -52,7 +52,6 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
import org.springframework.web.testfixture.server.MockServerWebExchange;
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import org.springframework.web.testfixture.servlet.MockHttpSession;
import org.springframework.web.testfixture.servlet.MockPart;
@@ -61,7 +60,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
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.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.get;
/**
* @author Arjen Poutsma
@@ -481,10 +479,6 @@ class DefaultServerRequestTests {
Instant oneMinuteAgo = now.minus(1, ChronoUnit.MINUTES);
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, eTag);
servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, oneMinuteAgo.toEpochMilli());
MockServerWebExchange exchange = MockServerWebExchange.from(get("/")
.ifNoneMatch(eTag)
.ifModifiedSince(oneMinuteAgo.toEpochMilli())
);
DefaultServerRequest request = new DefaultServerRequest(servletRequest, this.messageConverters);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,6 @@ import org.springframework.web.util.UrlPathHelper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Test for {@link AbstractHandlerMethodMapping}.
*
@@ -271,6 +270,7 @@ public class HandlerMethodMappingTests {
}
@Override
@SuppressWarnings("deprecation")
protected Set<String> getMappingPathPatterns(String key) {
return (this.pathMatcher.isPattern(key) ? Collections.<String>emptySet() : Collections.singleton(key));
}

View File

@@ -93,6 +93,7 @@ public class SimpleUrlHandlerMappingTests {
Object otherBean = wac.getBean("otherController");
Object defaultBean = wac.getBean("starController");
HandlerMapping hm = (HandlerMapping) wac.getBean(beanName);
wac.close();
boolean usePathPatterns = (((AbstractHandlerMapping) hm).getPatternParser() != null);
MockHttpServletRequest request = PathPatternsTestUtils.initRequest("GET", "/welcome.html", usePathPatterns);

View File

@@ -108,6 +108,7 @@ class PatternsRequestConditionTests {
}
@Test
@SuppressWarnings("deprecation")
void matchSuffixPattern() {
MockHttpServletRequest request = initRequest("/foo.html");
@@ -129,6 +130,7 @@ class PatternsRequestConditionTests {
}
@Test // SPR-8410
@SuppressWarnings("deprecation")
void matchSuffixPatternUsingFileExtensions() {
PatternsRequestCondition condition = new PatternsRequestCondition(
new String[] {"/jobs/{jobName}"}, null, null, true, false, Collections.singletonList("json"));
@@ -147,6 +149,7 @@ class PatternsRequestConditionTests {
}
@Test
@SuppressWarnings("deprecation")
void matchSuffixPatternUsingFileExtensions2() {
PatternsRequestCondition condition1 = new PatternsRequestCondition(
new String[] {"/prefix"}, null, null, true, false, Collections.singletonList("json"));

View File

@@ -550,6 +550,7 @@ class RequestMappingInfoHandlerMappingTests {
}
}
@SuppressWarnings("deprecation")
private RequestMappingInfo.BuilderConfiguration getBuilderConfig() {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
if (getPatternParser() != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,7 @@ import org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrateg
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for
* {@link org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMethodMappingNamingStrategy}.
* Unit tests for {@link RequestMappingInfoHandlerMethodMappingNamingStrategy}.
*
* @author Rossen Stoyanchev
*/
@@ -37,10 +36,10 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests {
@Test
public void getNameExplicit() {
Method method = ClassUtils.getMethod(TestController.class, "handle");
HandlerMethod handlerMethod = new HandlerMethod(new TestController(), method);
@SuppressWarnings("deprecation")
RequestMappingInfo rmi = new RequestMappingInfo("foo", null, null, null, null, null, null, null);
HandlerMethodMappingNamingStrategy<RequestMappingInfo> strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
@@ -50,10 +49,10 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests {
@Test
public void getNameConvention() {
Method method = ClassUtils.getMethod(TestController.class, "handle");
HandlerMethod handlerMethod = new HandlerMethod(new TestController(), method);
@SuppressWarnings("deprecation")
RequestMappingInfo rmi = new RequestMappingInfo(null, null, null, null, null, null, null, null);
HandlerMethodMappingNamingStrategy<RequestMappingInfo> strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();

View File

@@ -82,6 +82,7 @@ class CrossOriginTests {
TestRequestMappingInfoHandlerMapping mapping2 = new TestRequestMappingInfoHandlerMapping();
wac.getAutowireCapableBeanFactory().initializeBean(mapping2, "mapping2");
wac.close();
return Stream.of(mapping1, mapping2);
}

View File

@@ -36,7 +36,6 @@ import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.ClassUtils;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.accept.PathExtensionContentNegotiationStrategy;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
@@ -82,13 +81,14 @@ public class RequestMappingHandlerMappingTests {
@Test
@SuppressWarnings("deprecation")
void useRegisteredSuffixPatternMatch() {
RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
handlerMapping.setApplicationContext(new StaticWebApplicationContext());
Map<String, MediaType> fileExtensions = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions);
org.springframework.web.accept.PathExtensionContentNegotiationStrategy strategy = new org.springframework.web.accept.PathExtensionContentNegotiationStrategy(fileExtensions);
ContentNegotiationManager manager = new ContentNegotiationManager(strategy);
handlerMapping.setContentNegotiationManager(manager);
@@ -101,9 +101,10 @@ public class RequestMappingHandlerMappingTests {
}
@Test
@SuppressWarnings("deprecation")
void useRegisteredSuffixPatternMatchInitialization() {
Map<String, MediaType> fileExtensions = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions);
org.springframework.web.accept.PathExtensionContentNegotiationStrategy strategy = new org.springframework.web.accept.PathExtensionContentNegotiationStrategy(fileExtensions);
ContentNegotiationManager manager = new ContentNegotiationManager(strategy);
final Set<String> extensions = new HashSet<>();
@@ -129,6 +130,7 @@ public class RequestMappingHandlerMappingTests {
}
@Test
@SuppressWarnings("deprecation")
void suffixPatternMatchSettings() {
RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();

View File

@@ -242,6 +242,7 @@ public class ResourceHttpRequestHandlerTests {
}
@Test // SPR-13658
@SuppressWarnings("deprecation")
public void getResourceWithRegisteredMediaType() throws Exception {
ContentNegotiationManagerFactoryBean factory = new ContentNegotiationManagerFactoryBean();
factory.addMediaType("bar", new MediaType("foo", "bar"));
@@ -263,6 +264,7 @@ public class ResourceHttpRequestHandlerTests {
}
@Test // SPR-14577
@SuppressWarnings("deprecation")
public void getMediaTypeWithFavorPathExtensionOff() throws Exception {
ContentNegotiationManagerFactoryBean factory = new ContentNegotiationManagerFactoryBean();
factory.setFavorPathExtension(false);

View File

@@ -34,7 +34,6 @@ import org.springframework.web.accept.FixedContentNegotiationStrategy;
import org.springframework.web.accept.HeaderContentNegotiationStrategy;
import org.springframework.web.accept.MappingMediaTypeFileExtensionResolver;
import org.springframework.web.accept.ParameterContentNegotiationStrategy;
import org.springframework.web.accept.PathExtensionContentNegotiationStrategy;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.support.StaticWebApplicationContext;
@@ -332,11 +331,12 @@ public class ContentNegotiatingViewResolverTests {
}
@Test
@SuppressWarnings("deprecation")
public void resolveViewNameFilenameDefaultView() throws Exception {
request.setRequestURI("/test.json");
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
PathExtensionContentNegotiationStrategy pathStrategy = new PathExtensionContentNegotiationStrategy(mapping);
org.springframework.web.accept.PathExtensionContentNegotiationStrategy pathStrategy = new org.springframework.web.accept.PathExtensionContentNegotiationStrategy(mapping);
viewResolver.setContentNegotiationManager(new ContentNegotiationManager(pathStrategy));
ViewResolver viewResolverMock1 = mock(ViewResolver.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
* @author Juergen Hoeller
* @author Sam Brannen
*/
@SuppressWarnings("deprecation")
public class ResourceBundleViewResolverTests {
/** Comes from this package */

View File

@@ -57,8 +57,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Unit tests for {@link BeanNameViewResolver}, {@link UrlBasedViewResolver},
* {@link InternalResourceViewResolver}, {@link XmlViewResolver}, and
* {@link AbstractCachingViewResolver}.
* {@link InternalResourceViewResolver}, {@link org.springframework.web.servlet.view.XmlViewResolver},
* and {@link AbstractCachingViewResolver}.
*
* @author Juergen Hoeller
* @author Chris Beams
@@ -399,11 +399,12 @@ public class ViewResolverTests {
}
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolver() throws Exception {
this.wac.registerSingleton("testBean", TestBean.class);
this.wac.refresh();
TestBean testBean = (TestBean) this.wac.getBean("testBean");
XmlViewResolver vr = new XmlViewResolver();
org.springframework.web.servlet.view.XmlViewResolver vr = new org.springframework.web.servlet.view.XmlViewResolver();
vr.setLocation(new ClassPathResource("org/springframework/web/servlet/view/views.xml"));
vr.setApplicationContext(this.wac);
@@ -438,33 +439,35 @@ public class ViewResolverTests {
}
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolverDefaultLocation() {
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
@Override
protected Resource getResourceByPath(String path) {
assertThat(XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
assertThat(org.springframework.web.servlet.view.XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
return super.getResourceByPath(path);
}
};
wac.setServletContext(this.sc);
wac.refresh();
XmlViewResolver vr = new XmlViewResolver();
org.springframework.web.servlet.view.XmlViewResolver vr = new org.springframework.web.servlet.view.XmlViewResolver();
vr.setApplicationContext(wac);
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(vr::afterPropertiesSet);
}
@Test
@SuppressWarnings("deprecation")
public void xmlViewResolverWithoutCache() throws Exception {
StaticWebApplicationContext wac = new StaticWebApplicationContext() {
@Override
protected Resource getResourceByPath(String path) {
assertThat(XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
assertThat(org.springframework.web.servlet.view.XmlViewResolver.DEFAULT_LOCATION.equals(path)).as("Correct default location").isTrue();
return super.getResourceByPath(path);
}
};
wac.setServletContext(this.sc);
wac.refresh();
XmlViewResolver vr = new XmlViewResolver();
org.springframework.web.servlet.view.XmlViewResolver vr = new org.springframework.web.servlet.view.XmlViewResolver();
vr.setCache(false);
vr.setApplicationContext(wac);
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->