From aba882af4c4f7d2ec6e0b859dbffc1bcf65e000c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 4 Apr 2018 14:04:54 +0200 Subject: [PATCH] Clean up warnings in spring-webmvc --- .../handler/AbstractHandlerMethodMapping.java | 1 + .../RequestMappingInfoHandlerMapping.java | 1 + ...essageConverterMethodArgumentResolver.java | 4 +- ...stractMessageConverterMethodProcessor.java | 6 +-- ...ResponseBodyEmitterReturnValueHandler.java | 3 +- ...reamingResponseBodyReturnValueHandler.java | 3 +- .../resource/AppCacheManifestTransformer.java | 1 + .../servlet/resource/ResourceUrlProvider.java | 1 - .../web/servlet/view/xml/MarshallingView.java | 4 +- .../beans/factory/access/TestBean.java | 9 +++-- .../context/BeanThatListens.java | 6 +-- .../springframework/context/TestListener.java | 2 +- .../web/context/ContextLoaderTests.java | 40 +++++++++---------- .../support/ServletContextSupportTests.java | 6 ++- .../WebApplicationObjectSupportTests.java | 4 +- ...tationDrivenBeanDefinitionParserTests.java | 16 +++----- .../web/servlet/config/MvcNamespaceTests.java | 1 + .../DefaultServletHandlerConfigurerTests.java | 1 - .../DelegatingWebMvcConfigurationTests.java | 6 +-- .../HandlerMappingIntrospectorTests.java | 4 +- .../handler/HandlerMethodMappingTests.java | 4 +- .../handler/SimpleUrlHandlerMappingTests.java | 4 +- ...ndlerMethodMappingNamingStrategyTests.java | 7 ++-- ...equestAttributesArgumentResolverTests.java | 8 ++-- .../method/annotation/CrossOriginTests.java | 3 +- ...xceptionHandlerExceptionResolverTests.java | 2 +- ...ResolverMethodReturnValueHandlerTests.java | 3 +- .../annotation/ReactiveTypeHandlerTests.java | 5 ++- .../RequestMappingHandlerAdapterTests.java | 1 - ...equestPartMethodArgumentResolverTests.java | 18 ++++----- .../RequestResponseBodyAdviceChainTests.java | 2 - ...questResponseBodyMethodProcessorTests.java | 4 +- ...nseBodyEmitterReturnValueHandlerTests.java | 6 ++- .../ResponseEntityExceptionHandlerTests.java | 6 +-- ...nnotationControllerHandlerMethodTests.java | 4 +- .../ServletInvocableHandlerMethodTests.java | 1 + ...letModelAttributeMethodProcessorTests.java | 6 ++- .../resource/ResourceUrlProviderTests.java | 2 +- .../web/servlet/tags/MessageTagTests.java | 1 - .../form/AbstractHtmlElementTagTests.java | 1 - .../view/DummyMacroRequestContext.java | 38 +++++++++--------- .../web/servlet/view/RedirectViewTests.java | 2 +- .../web/servlet/view/ViewResolverTests.java | 22 +++++----- .../servlet/view/document/XlsViewTests.java | 5 ++- .../servlet/view/feed/AtomFeedViewTests.java | 24 ++++------- .../groovy/GroovyMarkupConfigurerTests.java | 1 + .../groovy/GroovyMarkupViewResolverTests.java | 5 ++- .../json/MappingJackson2JsonViewTests.java | 1 + .../ScriptTemplateViewResolverTests.java | 4 +- 49 files changed, 153 insertions(+), 156 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 8c71b36346..3aa4f2d7b9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -754,6 +754,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap private static class EmptyHandler { + @SuppressWarnings("unused") public void handle() { throw new UnsupportedOperationException("Not implemented"); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java index 382377ea99..6ff9c0e625 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java @@ -447,6 +447,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe return result; } + @SuppressWarnings("unused") public HttpHeaders handle() { return this.headers; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java index a378765f02..9081bae65b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -287,7 +287,7 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements @Nullable protected Object adaptArgumentIfNecessary(@Nullable Object arg, MethodParameter parameter) { if (parameter.getParameterType() == Optional.class) { - if (arg == null || (arg instanceof Collection && ((Collection) arg).isEmpty()) || + if (arg == null || (arg instanceof Collection && ((Collection) arg).isEmpty()) || (arg instanceof Object[] && ((Object[]) arg).length == 0)) { return Optional.empty(); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java index 807affee65..b9712d8b72 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java @@ -190,7 +190,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe valueType = getReturnValueType(outputValue, returnType); declaredType = getGenericType(returnType); } - + if (isResourceType(value, returnType)) { outputMessage.getHeaders().set(HttpHeaders.ACCEPT_RANGES, "bytes"); if (value != null && inputMessage.getHeaders().getFirst(HttpHeaders.RANGE) != null) { @@ -262,7 +262,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe if (genericConverter != null ? ((GenericHttpMessageConverter) converter).canWrite(declaredType, valueType, selectedMediaType) : converter.canWrite(valueType, selectedMediaType)) { - outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType, + outputValue = getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType, (Class>) converter.getClass(), inputMessage, outputMessage); if (outputValue != null) { @@ -321,7 +321,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe /** * @see #getProducibleMediaTypes(HttpServletRequest, Class, Type) */ - @SuppressWarnings({"unchecked", "unused"}) + @SuppressWarnings("unused") protected List getProducibleMediaTypes(HttpServletRequest request, Class valueClass) { return getProducibleMediaTypes(request, valueClass, null); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java index d361090cc8..0f96b85169 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -113,6 +113,7 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur } @Override + @SuppressWarnings("resource") public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandler.java index 92e076a1fc..46c259233c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -57,6 +57,7 @@ public class StreamingResponseBodyReturnValueHandler implements HandlerMethodRet } @Override + @SuppressWarnings("resource") public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index ce45ccac55..2777e13639 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -118,6 +118,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { logger.trace("Transforming resource: " + resource); } + @SuppressWarnings("resource") Scanner scanner = new Scanner(content); LineInfo previous = null; LineAggregator aggregator = new LineAggregator(resource, content); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 5b37280f69..53b828b945 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -17,7 +17,6 @@ package org.springframework.web.servlet.resource; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MarshallingView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MarshallingView.java index 83ab402e41..94a65b2826 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MarshallingView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MarshallingView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -165,7 +165,7 @@ public class MarshallingView extends AbstractView { Assert.state(this.marshaller != null, "No Marshaller set"); Class classToCheck = value.getClass(); if (value instanceof JAXBElement) { - classToCheck = ((JAXBElement) value).getDeclaredType(); + classToCheck = ((JAXBElement) value).getDeclaredType(); } return this.marshaller.supports(classToCheck); } diff --git a/spring-webmvc/src/test/java/org/springframework/beans/factory/access/TestBean.java b/spring-webmvc/src/test/java/org/springframework/beans/factory/access/TestBean.java index ac3b91c5ff..1e1ff737e8 100644 --- a/spring-webmvc/src/test/java/org/springframework/beans/factory/access/TestBean.java +++ b/spring-webmvc/src/test/java/org/springframework/beans/factory/access/TestBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -27,7 +27,7 @@ public class TestBean { private String name; - private List list; + private List list; private Object objRef; @@ -48,14 +48,14 @@ public class TestBean { /** * @return Returns the list. */ - public List getList() { + public List getList() { return list; } /** * @param list The list to set. */ - public void setList(List list) { + public void setList(List list) { this.list = list; } @@ -72,4 +72,5 @@ public class TestBean { public void setObjRef(Object object) { this.objRef = object; } + } diff --git a/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java b/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java index ab40da4b89..af07c30361 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java +++ b/spring-webmvc/src/test/java/org/springframework/context/BeanThatListens.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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; * @author Thomas Risberg * @author Juergen Hoeller */ -public class BeanThatListens implements ApplicationListener { +public class BeanThatListens implements ApplicationListener { private BeanThatBroadcasts beanThatBroadcasts; @@ -36,7 +36,7 @@ public class BeanThatListens implements ApplicationListener { public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) { this.beanThatBroadcasts = beanThatBroadcasts; - Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class); + Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class); if (!beans.isEmpty()) { throw new IllegalStateException("Shouldn't have found any BeanThatListens instances"); } diff --git a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java b/spring-webmvc/src/test/java/org/springframework/context/TestListener.java index 9020b436bb..53b5fdc6aa 100644 --- a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java +++ b/spring-webmvc/src/test/java/org/springframework/context/TestListener.java @@ -6,7 +6,7 @@ package org.springframework.context; * @author Rod Johnson * @since January 21, 2001 */ -public class TestListener implements ApplicationListener { +public class TestListener implements ApplicationListener { private int eventCount; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java index 0405f943e2..f93956d297 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -321,6 +321,7 @@ public class ContextLoaderTests { } @Test + @SuppressWarnings("resource") public void testClassPathXmlApplicationContext() throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext( "/org/springframework/web/context/WEB-INF/applicationContext.xml"); @@ -338,30 +339,25 @@ public class ContextLoaderTests { assertTrue("Has kerry", context.containsBean("kerry")); } - @Test + @Test(expected = BeanCreationException.class) + @SuppressWarnings("resource") public void testSingletonDestructionOnStartupFailure() throws IOException { - try { - new ClassPathXmlApplicationContext(new String[] { - "/org/springframework/web/context/WEB-INF/applicationContext.xml", - "/org/springframework/web/context/WEB-INF/fail.xml" }) { + new ClassPathXmlApplicationContext(new String[] { + "/org/springframework/web/context/WEB-INF/applicationContext.xml", + "/org/springframework/web/context/WEB-INF/fail.xml" }) { - @Override - public void refresh() throws BeansException { - try { - super.refresh(); - } - catch (BeanCreationException ex) { - DefaultListableBeanFactory factory = (DefaultListableBeanFactory) getBeanFactory(); - assertEquals(0, factory.getSingletonCount()); - throw ex; - } + @Override + public void refresh() throws BeansException { + try { + super.refresh(); } - }; - fail("Should have thrown BeanCreationException"); - } - catch (BeanCreationException ex) { - // expected - } + catch (BeanCreationException ex) { + DefaultListableBeanFactory factory = (DefaultListableBeanFactory) getBeanFactory(); + assertEquals(0, factory.getSingletonCount()); + throw ex; + } + } + }; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index 74277c06af..cdd2873924 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -43,6 +43,7 @@ import static org.junit.Assert.*; public class ServletContextSupportTests { @Test + @SuppressWarnings("resource") public void testServletContextAttributeFactoryBean() { MockServletContext sc = new MockServletContext(); sc.setAttribute("myAttr", "myValue"); @@ -59,6 +60,7 @@ public class ServletContextSupportTests { } @Test + @SuppressWarnings("resource") public void testServletContextAttributeFactoryBeanWithAttributeNotFound() { MockServletContext sc = new MockServletContext(); @@ -80,6 +82,7 @@ public class ServletContextSupportTests { } @Test + @SuppressWarnings("resource") public void testServletContextParameterFactoryBean() { MockServletContext sc = new MockServletContext(); sc.addInitParameter("myParam", "myValue"); @@ -96,6 +99,7 @@ public class ServletContextSupportTests { } @Test + @SuppressWarnings("resource") public void testServletContextParameterFactoryBeanWithAttributeNotFound() { MockServletContext sc = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java index 08d885396d..5be9d0c524 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -35,6 +35,7 @@ import static org.junit.Assert.*; public class WebApplicationObjectSupportTests { @Test + @SuppressWarnings("resource") public void testWebApplicationObjectSupport() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); @@ -48,6 +49,7 @@ public class WebApplicationObjectSupportTests { } @Test + @SuppressWarnings("resource") public void testWebApplicationObjectSupportWithWrongContext() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerBeanDefinition("test", new RootBeanDefinition(TestWebApplicationObject.class)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java index d96153e71d..54a7484f1e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.config; import java.util.List; import org.hamcrest.Matchers; -import org.junit.Before; import org.junit.Test; import org.springframework.beans.DirectFieldAccessor; @@ -54,18 +54,14 @@ import static org.junit.Assert.*; /** * Test fixture for the configuration in mvc-config-annotation-driven.xml. + * * @author Rossen Stoyanchev * @author Brian Clozel * @author Agim Emruli */ public class AnnotationDrivenBeanDefinitionParserTests { - private GenericWebApplicationContext appContext; - - @Before - public void setup() { - this.appContext = new GenericWebApplicationContext(); - } + private final GenericWebApplicationContext appContext = new GenericWebApplicationContext(); @Test public void testMessageCodesResolver() { @@ -191,7 +187,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { Object value = new DirectFieldAccessor(bean).getPropertyValue("responseBodyAdvice"); assertNotNull(value); assertTrue(value instanceof List); - List converters = (List) value; + List> converters = (List>) value; assertTrue(converters.get(0) instanceof JsonViewResponseBodyAdvice); } @@ -201,7 +197,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { Object value = new DirectFieldAccessor(bean).getPropertyValue("requestResponseBodyAdvice"); assertNotNull(value); assertTrue(value instanceof List); - List converters = (List) value; + List> converters = (List>) value; assertTrue(converters.get(0) instanceof JsonViewRequestBodyAdvice); assertTrue(converters.get(1) instanceof JsonViewResponseBodyAdvice); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 82bbcd1618..c3ca056928 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -347,6 +347,7 @@ public class MvcNamespaceTests { } @Test + @SuppressWarnings("unchecked") public void testResources() throws Exception { loadBeanDefinitions("mvc-config-resources.xml"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java index c50dd0a6c7..c9e89ba6a5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java @@ -60,7 +60,6 @@ public class DefaultServletHandlerConfigurerTests { @Test public void enable() throws Exception { configurer.enable(); - SimpleUrlHandlerMapping getHandlerMapping = configurer.buildHandlerMapping(); SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping(); DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java index 96a50788ed..f0a3103cf8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -27,7 +27,6 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.springframework.core.convert.ConversionService; import org.springframework.format.support.FormattingConversionService; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; @@ -48,7 +47,6 @@ import org.springframework.web.util.UrlPathHelper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.BDDMockito.given; @@ -122,7 +120,7 @@ public class DelegatingWebMvcConfigurationTests { @Test public void configureMessageConverters() { - final HttpMessageConverter customConverter = mock(HttpMessageConverter.class); + final HttpMessageConverter customConverter = mock(HttpMessageConverter.class); final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(); List configurers = new ArrayList<>(); configurers.add(new WebMvcConfigurer() { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java index 7981af3884..a75599d695 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java @@ -83,7 +83,6 @@ public class HandlerMappingIntrospectorTests { assertEquals(expected, actual); } - @Test @SuppressWarnings("deprecation") public void defaultHandlerMappings() throws Exception { StaticWebApplicationContext cxt = new StaticWebApplicationContext(); cxt.refresh(); @@ -170,7 +169,8 @@ public class HandlerMappingIntrospectorTests { } - @Configuration @SuppressWarnings({"WeakerAccess", "unused"}) + @Configuration + @SuppressWarnings({"WeakerAccess", "unused"}) static class TestConfig { @Bean diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java index 44aa956038..fed5a26a02 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java @@ -131,7 +131,7 @@ public class HandlerMethodMappingTests { // Direct URL lookup - List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); + List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); assertNotNull(directUrlMatches); assertEquals(1, directUrlMatches.size()); assertEquals(key1, directUrlMatches.get(0)); @@ -181,7 +181,7 @@ public class HandlerMethodMappingTests { // Direct URL lookup - List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); + List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1); assertNotNull(directUrlMatches); assertEquals(1, directUrlMatches.size()); assertEquals(key1, directUrlMatches.get(0)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java index a7764e0cbe..5954e9d8d0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -41,6 +41,7 @@ import static org.junit.Assert.*; public class SimpleUrlHandlerMappingTests { @Test + @SuppressWarnings("resource") public void handlerBeanNotFound() throws Exception { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext root = new XmlWebApplicationContext(); @@ -89,6 +90,7 @@ public class SimpleUrlHandlerMappingTests { assertSame(controller, hec.getHandler()); } + @SuppressWarnings("resource") private void checkMappings(String beanName) throws Exception { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext wac = new XmlWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java index fb3b4a67b9..53b57b60a2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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. @@ -35,7 +35,6 @@ import static org.junit.Assert.*; */ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests { - @Test public void getNameExplicit() { @@ -44,7 +43,7 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests { RequestMappingInfo rmi = new RequestMappingInfo("foo", null, null, null, null, null, null, null); - HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy(); + HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy(); assertEquals("foo", strategy.getName(handlerMethod, rmi)); } @@ -57,7 +56,7 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests { RequestMappingInfo rmi = new RequestMappingInfo(null, null, null, null, null, null, null, null); - HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy(); + HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy(); assertEquals("TC#handle", strategy.getName(handlerMethod, rmi)); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java index 3e95e19ad0..3b37a524f6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -131,7 +131,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests { Object actual = testResolveArgument(param, factory); assertNotNull(actual); assertEquals(Optional.class, actual.getClass()); - assertFalse(((Optional) actual).isPresent()); + assertFalse(((Optional) actual).isPresent()); Foo foo = new Foo(); this.webRequest.setAttribute("foo", foo, getScope()); @@ -139,8 +139,8 @@ public abstract class AbstractRequestAttributesArgumentResolverTests { actual = testResolveArgument(param, factory); assertNotNull(actual); assertEquals(Optional.class, actual.getClass()); - assertTrue(((Optional) actual).isPresent()); - assertSame(foo, ((Optional) actual).get()); + assertTrue(((Optional) actual).isPresent()); + assertSame(foo, ((Optional) actual).get()); } private Object testResolveArgument(MethodParameter param) throws Exception { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java index bf82711b24..8e78eb08c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,6 +76,7 @@ public class CrossOriginTests { @Before + @SuppressWarnings("resource") public void setup() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); Properties props = new Properties(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java index 9e266cefb7..5fa7d920e8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java @@ -93,8 +93,8 @@ public class ExceptionHandlerExceptionResolverTests { } - @SuppressWarnings("ConstantConditions") @Test + @SuppressWarnings("ConstantConditions") public void nullHandler() { Object handler = null; this.resolver.afterPropertiesSet(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index c7873d0eac..fe491f2280 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -125,7 +125,6 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { } @Override - @SuppressWarnings("rawtypes") public ModelAndView resolveModelAndView(Method method, Class handlerType, Object returnValue, ExtendedModelMap model, NativeWebRequest request) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java index b9f5beaf0d..f14c87a4c9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.mvc.method.annotation; import java.io.IOException; @@ -400,8 +401,10 @@ public class ReactiveTypeHandlerTests { this.value = value; } + @SuppressWarnings("unused") public String getValue() { return this.value; } } + } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index 33c5570c37..3a3b5e0182 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -385,7 +385,6 @@ public class RequestMappingHandlerAdapterTests { @ControllerAdvice private static class ResponseCodeSuppressingAdvice extends AbstractMappingJacksonResponseBodyAdvice { - @SuppressWarnings("unchecked") @Override protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java index 164e8ea58f..533a8ed268 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -326,11 +326,11 @@ public class RequestPartMethodArgumentResolverTests { Object actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", expected, ((Optional) actualValue).get()); + assertEquals("Invalid result", expected, ((Optional) actualValue).get()); actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", expected, ((Optional) actualValue).get()); + assertEquals("Invalid result", expected, ((Optional) actualValue).get()); } @Test @@ -366,11 +366,11 @@ public class RequestPartMethodArgumentResolverTests { Object actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); + assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); + assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); } @Test @@ -408,11 +408,11 @@ public class RequestPartMethodArgumentResolverTests { Object actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", expected, ((Optional) actualValue).get()); + assertEquals("Invalid result", expected, ((Optional) actualValue).get()); actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", expected, ((Optional) actualValue).get()); + assertEquals("Invalid result", expected, ((Optional) actualValue).get()); } @Test @@ -452,11 +452,11 @@ public class RequestPartMethodArgumentResolverTests { Object actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); + assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null); assertTrue(actualValue instanceof Optional); - assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); + assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get()); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java index b2056a8836..e7a6d0e2bf 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java @@ -151,7 +151,6 @@ public class RequestResponseBodyAdviceChainTests { return true; } - @SuppressWarnings("unchecked") @Override public String beforeBodyWrite(String body, MethodParameter returnType, MediaType contentType, Class> converterType, @@ -170,7 +169,6 @@ public class RequestResponseBodyAdviceChainTests { return true; } - @SuppressWarnings("unchecked") @Override public String beforeBodyWrite(String body, MethodParameter returnType, MediaType contentType, Class> converterType, diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java index 4f67ec5a9d..ec2fe4fc08 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java @@ -268,8 +268,8 @@ public class RequestResponseBodyMethodProcessorTests { this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE); List> converters = new ArrayList<>(); - HttpMessageConverter target = new MappingJackson2HttpMessageConverter(); - HttpMessageConverter proxy = ProxyFactory.getProxy(HttpMessageConverter.class, new SingletonTargetSource(target)); + HttpMessageConverter target = new MappingJackson2HttpMessageConverter(); + HttpMessageConverter proxy = ProxyFactory.getProxy(HttpMessageConverter.class, new SingletonTargetSource(target)); converters.add(proxy); RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java index 7903239575..0339cfe876 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.mvc.method.annotation; import java.util.Arrays; @@ -306,7 +307,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests { private ResponseEntity> h6() { return null; } - private ResponseEntity h7() { return null; } + private ResponseEntity h7() { return null; } private Flux h8() { return null; } @@ -315,6 +316,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests { } + @SuppressWarnings("unused") private static class SimpleBean { private Long id; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java index 8fe943cd9d..e6adfcc94e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -238,9 +238,6 @@ public class ResponseEntityExceptionHandlerTests { } - private static class TestController { - } - @ControllerAdvice private static class ApplicationExceptionHandler extends ResponseEntityExceptionHandler { @@ -253,7 +250,6 @@ public class ResponseEntityExceptionHandlerTests { } } - @SuppressWarnings("unused") void handle(String arg) { } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index a8e2cb5a06..05709b9b03 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -3033,7 +3033,6 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl public static class MyModelAndViewResolver implements ModelAndViewResolver { @Override - @SuppressWarnings("rawtypes") public ModelAndView resolveModelAndView(Method handlerMethod, Class handlerType, Object returnValue, ExtendedModelMap implicitModel, NativeWebRequest webRequest) { @@ -3048,7 +3047,6 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl throws Exception { response.getWriter().write("myValue"); } - }); } return UNRESOLVED; @@ -3143,7 +3141,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl String ARTICLES_PATH = API_V1 + "/articles"; } - public interface ResourceEndpoint { + public interface ResourceEndpoint> { Collection find(String pageable, P predicate) throws IOException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java index 67c9ca5342..31b872a2aa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java @@ -458,6 +458,7 @@ public class ServletInvocableHandlerMethodTests { this.value = value; } + @SuppressWarnings("unused") public String getValue() { return this.value; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java index 75de7e5077..bd83081b78 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -107,6 +107,7 @@ public class ServletModelAttributeMethodProcessorTests { } @Test + @SuppressWarnings("unchecked") public void createAttributeUriTemplateVarWithOptional() throws Exception { Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("testBean3", "Patty"); @@ -141,6 +142,7 @@ public class ServletModelAttributeMethodProcessorTests { } @Test + @SuppressWarnings("unchecked") public void createAttributeRequestParameterWithOptional() throws Exception { request.addParameter("testBean3", "Patty"); @@ -151,6 +153,7 @@ public class ServletModelAttributeMethodProcessorTests { } @Test + @SuppressWarnings("unchecked") public void attributesAsNullValues() throws Exception { request.addParameter("name", "Patty"); @@ -170,6 +173,7 @@ public class ServletModelAttributeMethodProcessorTests { } @Test + @SuppressWarnings("unchecked") public void attributesAsOptionalEmpty() throws Exception { request.addParameter("name", "Patty"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java index a68eb4c4d8..156c445ada 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java @@ -39,7 +39,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - /** * Unit tests for {@link ResourceUrlProvider}. * @@ -138,6 +137,7 @@ public class ResourceUrlProviderTests { } @Test // SPR-12592 + @SuppressWarnings("resource") public void initializeOnce() throws Exception { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setServletContext(new MockServletContext()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java index 20c8c612e0..3b691bf3c8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java @@ -365,7 +365,6 @@ public class MessageTagTests extends AbstractTagTests { } @Test - @SuppressWarnings("deprecation") public void nullMessageSource() throws JspException { PageContext pc = createPageContext(); ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java index 5eb1a09b2b..d54057edd7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java @@ -103,7 +103,6 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests { return (RequestContext) getPageContext().getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); } - @SuppressWarnings("deprecation") protected RequestDataValueProcessor getMockRequestDataValueProcessor() { RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class); HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java index 2e5f3f4cb6..076dbfe3dd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2018 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,9 +36,9 @@ public class DummyMacroRequestContext { private HttpServletRequest request; - private Map messageMap; + private Map messageMap; - private Map themeMessageMap; + private Map themeMessageMap; private String contextPath; @@ -48,11 +48,11 @@ public class DummyMacroRequestContext { } - public void setMessageMap(Map messageMap) { + public void setMessageMap(Map messageMap) { this.messageMap = messageMap; } - public void setThemeMessageMap(Map themeMessageMap) { + public void setThemeMessageMap(Map themeMessageMap) { this.themeMessageMap = themeMessageMap; } @@ -61,60 +61,60 @@ public class DummyMacroRequestContext { * @see org.springframework.web.servlet.support.RequestContext#getMessage(String) */ public String getMessage(String code) { - return (String) this.messageMap.get(code); + return this.messageMap.get(code); } /** * @see org.springframework.web.servlet.support.RequestContext#getMessage(String, String) */ public String getMessage(String code, String defaultMsg) { - String msg = (String) this.messageMap.get(code); + String msg = this.messageMap.get(code); return (msg != null ? msg : defaultMsg); } /** * @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List) */ - public String getMessage(String code, List args) { - return ((String) this.messageMap.get(code)) + args.toString(); + public String getMessage(String code, List args) { + return this.messageMap.get(code) + args; } /** * @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List, String) */ - public String getMessage(String code, List args, String defaultMsg) { - String msg = (String) this.messageMap.get(code); - return (msg != null ? msg + args.toString(): defaultMsg); + public String getMessage(String code, List args, String defaultMsg) { + String msg = this.messageMap.get(code); + return (msg != null ? msg + args : defaultMsg); } /** * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String) */ public String getThemeMessage(String code) { - return (String) this.themeMessageMap.get(code); + return this.themeMessageMap.get(code); } /** * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, String) */ public String getThemeMessage(String code, String defaultMsg) { - String msg = (String) this.themeMessageMap.get(code); + String msg = this.themeMessageMap.get(code); return (msg != null ? msg : defaultMsg); } /** * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List) */ - public String getThemeMessage(String code, List args) { - return ((String) this.themeMessageMap.get(code)) + args.toString(); + public String getThemeMessage(String code, List args) { + return this.themeMessageMap.get(code) + args; } /** * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String) */ - public String getThemeMessage(String code, List args, String defaultMsg) { - String msg = (String) this.themeMessageMap.get(code); - return (msg != null ? msg + args.toString(): defaultMsg); + public String getThemeMessage(String code, List args, String defaultMsg) { + String msg = this.themeMessageMap.get(code); + return (msg != null ? msg + args : defaultMsg); } public void setContextPath(String contextPath) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java index fb66f41f89..0eeddc6ff5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java @@ -137,8 +137,8 @@ public class RedirectViewTests { assertEquals("http://url.somewhere.com", response.getHeader("Location")); } - @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes") @Test + @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes") public void flashMap() throws Exception { RedirectView rv = new RedirectView(); rv.setUrl("http://url.somewhere.com/path"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java index 1374c8811d..38e6e554f9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java @@ -132,7 +132,7 @@ public class ViewResolverTests { request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver()); request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver()); - Map model = new HashMap(); + Map model = new HashMap<>(); TestBean tb = new TestBean(); model.put("tb", tb); view.render(model, request, response); @@ -184,7 +184,7 @@ public class ViewResolverTests { Properties props = new Properties(); props.setProperty("key1", "value1"); vr.setAttributes(props); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key2", new Integer(2)); vr.setAttributesMap(map); vr.setApplicationContext(wac); @@ -192,7 +192,7 @@ public class ViewResolverTests { View view = vr.resolveViewName("example1", Locale.getDefault()); assertEquals("Correct view class", JstlView.class, view.getClass()); assertEquals("Correct URL", "example1", ((InternalResourceView) view).getUrl()); - Map attributes = ((InternalResourceView) view).getStaticAttributes(); + Map attributes = ((InternalResourceView) view).getStaticAttributes(); assertEquals("value1", attributes.get("key1")); assertEquals(new Integer(2), attributes.get("key2")); @@ -207,7 +207,7 @@ public class ViewResolverTests { HttpServletResponse response = new MockHttpServletResponse(); request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver()); - Map model = new HashMap(); + Map model = new HashMap<>(); TestBean tb = new TestBean(); model.put("tb", tb); view.render(model, request, response); @@ -230,7 +230,7 @@ public class ViewResolverTests { Properties props = new Properties(); props.setProperty("key1", "value1"); vr.setAttributes(props); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key2", new Integer(2)); vr.setAttributesMap(map); vr.setExposeContextBeansAsAttributes(true); @@ -255,7 +255,7 @@ public class ViewResolverTests { request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver()); View view = vr.resolveViewName("example1", Locale.getDefault()); - view.render(new HashMap(), request, response); + view.render(new HashMap(), request, response); } @Test @@ -270,7 +270,7 @@ public class ViewResolverTests { Properties props = new Properties(); props.setProperty("key1", "value1"); vr.setAttributes(props); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key2", new Integer(2)); vr.setAttributesMap(map); vr.setExposedContextBeanNames(new String[] {"myBean2"}); @@ -295,7 +295,7 @@ public class ViewResolverTests { request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver()); View view = vr.resolveViewName("example1", Locale.getDefault()); - view.render(new HashMap(), request, response); + view.render(new HashMap(), request, response); } @Test @@ -323,7 +323,7 @@ public class ViewResolverTests { HttpServletResponse response = new MockHttpServletResponse(); request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale)); - Map model = new HashMap(); + Map model = new HashMap<>(); TestBean tb = new TestBean(); model.put("tb", tb); view.render(model, request, response); @@ -362,7 +362,7 @@ public class ViewResolverTests { HttpServletResponse response = new MockHttpServletResponse(); request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale)); - Map model = new HashMap(); + Map model = new HashMap<>(); TestBean tb = new TestBean(); model.put("tb", tb); view.render(model, request, response); @@ -396,7 +396,7 @@ public class ViewResolverTests { assertTrue("Correct URL", "/example2new.jsp".equals(((InternalResourceView) view2).getUrl())); ServletContext sc = new MockServletContext(); - Map model = new HashMap(); + Map model = new HashMap<>(); TestBean tb = new TestBean(); model.put("tb", tb); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java index 15a6bb0687..6c0427c9eb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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 @@ public class XlsViewTests { @Test + @SuppressWarnings("resource") public void testXls() throws Exception { View excelView = new AbstractXlsView() { @Override @@ -73,6 +74,7 @@ public class XlsViewTests { } @Test + @SuppressWarnings("resource") public void testXlsxView() throws Exception { View excelView = new AbstractXlsxView() { @Override @@ -96,6 +98,7 @@ public class XlsViewTests { } @Test + @SuppressWarnings("resource") public void testXlsxStreamingView() throws Exception { View excelView = new AbstractXlsxStreamingView() { @Override diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index b6829eaff7..908ec56bcc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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.web.servlet.view.feed; import com.rometools.rome.feed.atom.Content; import com.rometools.rome.feed.atom.Entry; import com.rometools.rome.feed.atom.Feed; -import org.junit.Before; import org.junit.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -28,7 +27,6 @@ import org.xmlunit.matchers.CompareMatcher; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -41,12 +39,7 @@ import static org.junit.Assert.assertThat; */ public class AtomFeedViewTests { - private AbstractAtomFeedView view; - - @Before - public void createView() throws Exception { - view = new MyAtomFeedView(); - } + private final AbstractAtomFeedView view = new MyAtomFeedView(); @Test public void render() throws Exception { @@ -65,24 +58,21 @@ public class AtomFeedViewTests { assertThat(response.getContentAsString(), isSimilarTo(expected)); } - private static CompareMatcher isSimilarTo(final String content) { - return CompareMatcher.isSimilarTo(content) - .ignoreWhitespace(); + private static CompareMatcher isSimilarTo(String content) { + return CompareMatcher.isSimilarTo(content).ignoreWhitespace(); } private static class MyAtomFeedView extends AbstractAtomFeedView { @Override - protected void buildFeedMetadata(Map model, Feed feed, HttpServletRequest request) { + protected void buildFeedMetadata(Mapmodel, Feed feed, HttpServletRequest request) { feed.setTitle("Test Feed"); } @Override - protected List buildFeedEntries(Map model, HttpServletRequest request, HttpServletResponse response) - throws Exception { + protected List buildFeedEntries(Map model, HttpServletRequest request, HttpServletResponse response) { List entries = new ArrayList<>(); - for (Iterator iterator = model.keySet().iterator(); iterator.hasNext();) { - String name = (String) iterator.next(); + for (String name : model.keySet()) { Entry entry = new Entry(); entry.setTitle(name); Content content = new Content(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java index e20888d0c7..56310fe90e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java @@ -101,6 +101,7 @@ public class GroovyMarkupConfigurerTests { } @Test + @SuppressWarnings("resource") public void parentLoader() throws Exception { this.configurer.setApplicationContext(this.applicationContext); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java index 2190e3689d..156d00b9f6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.view.groovy; import java.util.Locale; @@ -35,7 +36,7 @@ public class GroovyMarkupViewResolverTests { GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver(); Assert.assertEquals(GroovyMarkupView.class, resolver.requiredViewClass()); DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver); - Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); + Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); Assert.assertEquals(GroovyMarkupView.class, viewClass); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index 077f2dfa29..5d3718f9a5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -454,6 +454,7 @@ public class MappingJackson2JsonViewTests { @JsonFilter("myJacksonFilter") + @SuppressWarnings("unused") private static class TestSimpleBeanFiltered { private String property1; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java index fa8d4ae581..0b83221185 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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,7 +33,7 @@ public class ScriptTemplateViewResolverTests { ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver(); Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass()); DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver); - Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); + Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass"); Assert.assertEquals(ScriptTemplateView.class, viewClass); }