Clean up warnings in spring-webmvc
This commit is contained in:
@@ -754,6 +754,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
|||||||
|
|
||||||
private static class EmptyHandler {
|
private static class EmptyHandler {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void handle() {
|
public void handle() {
|
||||||
throw new UnsupportedOperationException("Not implemented");
|
throw new UnsupportedOperationException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -447,6 +447,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public HttpHeaders handle() {
|
public HttpHeaders handle() {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -287,7 +287,7 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected Object adaptArgumentIfNecessary(@Nullable Object arg, MethodParameter parameter) {
|
protected Object adaptArgumentIfNecessary(@Nullable Object arg, MethodParameter parameter) {
|
||||||
if (parameter.getParameterType() == Optional.class) {
|
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)) {
|
(arg instanceof Object[] && ((Object[]) arg).length == 0)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
|||||||
valueType = getReturnValueType(outputValue, returnType);
|
valueType = getReturnValueType(outputValue, returnType);
|
||||||
declaredType = getGenericType(returnType);
|
declaredType = getGenericType(returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isResourceType(value, returnType)) {
|
if (isResourceType(value, returnType)) {
|
||||||
outputMessage.getHeaders().set(HttpHeaders.ACCEPT_RANGES, "bytes");
|
outputMessage.getHeaders().set(HttpHeaders.ACCEPT_RANGES, "bytes");
|
||||||
if (value != null && inputMessage.getHeaders().getFirst(HttpHeaders.RANGE) != null) {
|
if (value != null && inputMessage.getHeaders().getFirst(HttpHeaders.RANGE) != null) {
|
||||||
@@ -262,7 +262,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
|||||||
if (genericConverter != null ?
|
if (genericConverter != null ?
|
||||||
((GenericHttpMessageConverter) converter).canWrite(declaredType, valueType, selectedMediaType) :
|
((GenericHttpMessageConverter) converter).canWrite(declaredType, valueType, selectedMediaType) :
|
||||||
converter.canWrite(valueType, selectedMediaType)) {
|
converter.canWrite(valueType, selectedMediaType)) {
|
||||||
outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
|
outputValue = getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
|
||||||
(Class<? extends HttpMessageConverter<?>>) converter.getClass(),
|
(Class<? extends HttpMessageConverter<?>>) converter.getClass(),
|
||||||
inputMessage, outputMessage);
|
inputMessage, outputMessage);
|
||||||
if (outputValue != null) {
|
if (outputValue != null) {
|
||||||
@@ -321,7 +321,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
|||||||
/**
|
/**
|
||||||
* @see #getProducibleMediaTypes(HttpServletRequest, Class, Type)
|
* @see #getProducibleMediaTypes(HttpServletRequest, Class, Type)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "unused"})
|
@SuppressWarnings("unused")
|
||||||
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass) {
|
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass) {
|
||||||
return getProducibleMediaTypes(request, valueClass, null);
|
return getProducibleMediaTypes(request, valueClass, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -113,6 +113,7 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
|
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
|
||||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -57,6 +57,7 @@ public class StreamingResponseBodyReturnValueHandler implements HandlerMethodRet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
|
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
|
||||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
|||||||
logger.trace("Transforming resource: " + resource);
|
logger.trace("Transforming resource: " + resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
Scanner scanner = new Scanner(content);
|
Scanner scanner = new Scanner(content);
|
||||||
LineInfo previous = null;
|
LineInfo previous = null;
|
||||||
LineAggregator aggregator = new LineAggregator(resource, content);
|
LineAggregator aggregator = new LineAggregator(resource, content);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.springframework.web.servlet.resource;
|
package org.springframework.web.servlet.resource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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");
|
Assert.state(this.marshaller != null, "No Marshaller set");
|
||||||
Class<?> classToCheck = value.getClass();
|
Class<?> classToCheck = value.getClass();
|
||||||
if (value instanceof JAXBElement) {
|
if (value instanceof JAXBElement) {
|
||||||
classToCheck = ((JAXBElement) value).getDeclaredType();
|
classToCheck = ((JAXBElement<?>) value).getDeclaredType();
|
||||||
}
|
}
|
||||||
return this.marshaller.supports(classToCheck);
|
return this.marshaller.supports(classToCheck);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 String name;
|
||||||
|
|
||||||
private List list;
|
private List<?> list;
|
||||||
|
|
||||||
private Object objRef;
|
private Object objRef;
|
||||||
|
|
||||||
@@ -48,14 +48,14 @@ public class TestBean {
|
|||||||
/**
|
/**
|
||||||
* @return Returns the list.
|
* @return Returns the list.
|
||||||
*/
|
*/
|
||||||
public List getList() {
|
public List<?> getList() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param list The list to set.
|
* @param list The list to set.
|
||||||
*/
|
*/
|
||||||
public void setList(List list) {
|
public void setList(List<?> list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,4 +72,5 @@ public class TestBean {
|
|||||||
public void setObjRef(Object object) {
|
public void setObjRef(Object object) {
|
||||||
this.objRef = object;
|
this.objRef = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 Thomas Risberg
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public class BeanThatListens implements ApplicationListener {
|
public class BeanThatListens implements ApplicationListener<ApplicationEvent> {
|
||||||
|
|
||||||
private BeanThatBroadcasts beanThatBroadcasts;
|
private BeanThatBroadcasts beanThatBroadcasts;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class BeanThatListens implements ApplicationListener {
|
|||||||
|
|
||||||
public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) {
|
public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) {
|
||||||
this.beanThatBroadcasts = beanThatBroadcasts;
|
this.beanThatBroadcasts = beanThatBroadcasts;
|
||||||
Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class);
|
Map<String, BeanThatListens> beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class);
|
||||||
if (!beans.isEmpty()) {
|
if (!beans.isEmpty()) {
|
||||||
throw new IllegalStateException("Shouldn't have found any BeanThatListens instances");
|
throw new IllegalStateException("Shouldn't have found any BeanThatListens instances");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package org.springframework.context;
|
|||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @since January 21, 2001
|
* @since January 21, 2001
|
||||||
*/
|
*/
|
||||||
public class TestListener implements ApplicationListener {
|
public class TestListener implements ApplicationListener<ApplicationEvent> {
|
||||||
|
|
||||||
private int eventCount;
|
private int eventCount;
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -321,6 +321,7 @@ public class ContextLoaderTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testClassPathXmlApplicationContext() throws IOException {
|
public void testClassPathXmlApplicationContext() throws IOException {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"/org/springframework/web/context/WEB-INF/applicationContext.xml");
|
"/org/springframework/web/context/WEB-INF/applicationContext.xml");
|
||||||
@@ -338,30 +339,25 @@ public class ContextLoaderTests {
|
|||||||
assertTrue("Has kerry", context.containsBean("kerry"));
|
assertTrue("Has kerry", context.containsBean("kerry"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BeanCreationException.class)
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testSingletonDestructionOnStartupFailure() throws IOException {
|
public void testSingletonDestructionOnStartupFailure() throws IOException {
|
||||||
try {
|
new ClassPathXmlApplicationContext(new String[] {
|
||||||
new ClassPathXmlApplicationContext(new String[] {
|
"/org/springframework/web/context/WEB-INF/applicationContext.xml",
|
||||||
"/org/springframework/web/context/WEB-INF/applicationContext.xml",
|
"/org/springframework/web/context/WEB-INF/fail.xml" }) {
|
||||||
"/org/springframework/web/context/WEB-INF/fail.xml" }) {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh() throws BeansException {
|
public void refresh() throws BeansException {
|
||||||
try {
|
try {
|
||||||
super.refresh();
|
super.refresh();
|
||||||
}
|
|
||||||
catch (BeanCreationException ex) {
|
|
||||||
DefaultListableBeanFactory factory = (DefaultListableBeanFactory) getBeanFactory();
|
|
||||||
assertEquals(0, factory.getSingletonCount());
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
catch (BeanCreationException ex) {
|
||||||
fail("Should have thrown BeanCreationException");
|
DefaultListableBeanFactory factory = (DefaultListableBeanFactory) getBeanFactory();
|
||||||
}
|
assertEquals(0, factory.getSingletonCount());
|
||||||
catch (BeanCreationException ex) {
|
throw ex;
|
||||||
// expected
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class ServletContextSupportTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testServletContextAttributeFactoryBean() {
|
public void testServletContextAttributeFactoryBean() {
|
||||||
MockServletContext sc = new MockServletContext();
|
MockServletContext sc = new MockServletContext();
|
||||||
sc.setAttribute("myAttr", "myValue");
|
sc.setAttribute("myAttr", "myValue");
|
||||||
@@ -59,6 +60,7 @@ public class ServletContextSupportTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testServletContextAttributeFactoryBeanWithAttributeNotFound() {
|
public void testServletContextAttributeFactoryBeanWithAttributeNotFound() {
|
||||||
MockServletContext sc = new MockServletContext();
|
MockServletContext sc = new MockServletContext();
|
||||||
|
|
||||||
@@ -80,6 +82,7 @@ public class ServletContextSupportTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testServletContextParameterFactoryBean() {
|
public void testServletContextParameterFactoryBean() {
|
||||||
MockServletContext sc = new MockServletContext();
|
MockServletContext sc = new MockServletContext();
|
||||||
sc.addInitParameter("myParam", "myValue");
|
sc.addInitParameter("myParam", "myValue");
|
||||||
@@ -96,6 +99,7 @@ public class ServletContextSupportTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testServletContextParameterFactoryBeanWithAttributeNotFound() {
|
public void testServletContextParameterFactoryBeanWithAttributeNotFound() {
|
||||||
MockServletContext sc = new MockServletContext();
|
MockServletContext sc = new MockServletContext();
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class WebApplicationObjectSupportTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testWebApplicationObjectSupport() {
|
public void testWebApplicationObjectSupport() {
|
||||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||||
wac.setServletContext(new MockServletContext());
|
wac.setServletContext(new MockServletContext());
|
||||||
@@ -48,6 +49,7 @@ public class WebApplicationObjectSupportTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testWebApplicationObjectSupportWithWrongContext() {
|
public void testWebApplicationObjectSupportWithWrongContext() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerBeanDefinition("test", new RootBeanDefinition(TestWebApplicationObject.class));
|
ac.registerBeanDefinition("test", new RootBeanDefinition(TestWebApplicationObject.class));
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.servlet.config;
|
package org.springframework.web.servlet.config;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
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.
|
* Test fixture for the configuration in mvc-config-annotation-driven.xml.
|
||||||
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Agim Emruli
|
* @author Agim Emruli
|
||||||
*/
|
*/
|
||||||
public class AnnotationDrivenBeanDefinitionParserTests {
|
public class AnnotationDrivenBeanDefinitionParserTests {
|
||||||
|
|
||||||
private GenericWebApplicationContext appContext;
|
private final GenericWebApplicationContext appContext = new GenericWebApplicationContext();
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
this.appContext = new GenericWebApplicationContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMessageCodesResolver() {
|
public void testMessageCodesResolver() {
|
||||||
@@ -191,7 +187,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("responseBodyAdvice");
|
Object value = new DirectFieldAccessor(bean).getPropertyValue("responseBodyAdvice");
|
||||||
assertNotNull(value);
|
assertNotNull(value);
|
||||||
assertTrue(value instanceof List);
|
assertTrue(value instanceof List);
|
||||||
List<ResponseBodyAdvice> converters = (List<ResponseBodyAdvice>) value;
|
List<ResponseBodyAdvice<?>> converters = (List<ResponseBodyAdvice<?>>) value;
|
||||||
assertTrue(converters.get(0) instanceof JsonViewResponseBodyAdvice);
|
assertTrue(converters.get(0) instanceof JsonViewResponseBodyAdvice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +197,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||||||
Object value = new DirectFieldAccessor(bean).getPropertyValue("requestResponseBodyAdvice");
|
Object value = new DirectFieldAccessor(bean).getPropertyValue("requestResponseBodyAdvice");
|
||||||
assertNotNull(value);
|
assertNotNull(value);
|
||||||
assertTrue(value instanceof List);
|
assertTrue(value instanceof List);
|
||||||
List<ResponseBodyAdvice> converters = (List<ResponseBodyAdvice>) value;
|
List<ResponseBodyAdvice<?>> converters = (List<ResponseBodyAdvice<?>>) value;
|
||||||
assertTrue(converters.get(0) instanceof JsonViewRequestBodyAdvice);
|
assertTrue(converters.get(0) instanceof JsonViewRequestBodyAdvice);
|
||||||
assertTrue(converters.get(1) instanceof JsonViewResponseBodyAdvice);
|
assertTrue(converters.get(1) instanceof JsonViewResponseBodyAdvice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ public class MvcNamespaceTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void testResources() throws Exception {
|
public void testResources() throws Exception {
|
||||||
loadBeanDefinitions("mvc-config-resources.xml");
|
loadBeanDefinitions("mvc-config-resources.xml");
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class DefaultServletHandlerConfigurerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void enable() throws Exception {
|
public void enable() throws Exception {
|
||||||
configurer.enable();
|
configurer.enable();
|
||||||
SimpleUrlHandlerMapping getHandlerMapping = configurer.buildHandlerMapping();
|
|
||||||
SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
|
SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
|
||||||
DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");
|
DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
|
||||||
import org.springframework.format.support.FormattingConversionService;
|
import org.springframework.format.support.FormattingConversionService;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
@@ -122,7 +120,7 @@ public class DelegatingWebMvcConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void configureMessageConverters() {
|
public void configureMessageConverters() {
|
||||||
final HttpMessageConverter customConverter = mock(HttpMessageConverter.class);
|
final HttpMessageConverter<?> customConverter = mock(HttpMessageConverter.class);
|
||||||
final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
||||||
List<WebMvcConfigurer> configurers = new ArrayList<>();
|
List<WebMvcConfigurer> configurers = new ArrayList<>();
|
||||||
configurers.add(new WebMvcConfigurer() {
|
configurers.add(new WebMvcConfigurer() {
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ public class HandlerMappingIntrospectorTests {
|
|||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @SuppressWarnings("deprecation")
|
|
||||||
public void defaultHandlerMappings() throws Exception {
|
public void defaultHandlerMappings() throws Exception {
|
||||||
StaticWebApplicationContext cxt = new StaticWebApplicationContext();
|
StaticWebApplicationContext cxt = new StaticWebApplicationContext();
|
||||||
cxt.refresh();
|
cxt.refresh();
|
||||||
@@ -170,7 +169,8 @@ public class HandlerMappingIntrospectorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration @SuppressWarnings({"WeakerAccess", "unused"})
|
@Configuration
|
||||||
|
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||||
static class TestConfig {
|
static class TestConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class HandlerMethodMappingTests {
|
|||||||
|
|
||||||
// Direct URL lookup
|
// Direct URL lookup
|
||||||
|
|
||||||
List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1);
|
List<String> directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1);
|
||||||
assertNotNull(directUrlMatches);
|
assertNotNull(directUrlMatches);
|
||||||
assertEquals(1, directUrlMatches.size());
|
assertEquals(1, directUrlMatches.size());
|
||||||
assertEquals(key1, directUrlMatches.get(0));
|
assertEquals(key1, directUrlMatches.get(0));
|
||||||
@@ -181,7 +181,7 @@ public class HandlerMethodMappingTests {
|
|||||||
|
|
||||||
// Direct URL lookup
|
// Direct URL lookup
|
||||||
|
|
||||||
List directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1);
|
List<String> directUrlMatches = this.mapping.getMappingRegistry().getMappingsByUrl(key1);
|
||||||
assertNotNull(directUrlMatches);
|
assertNotNull(directUrlMatches);
|
||||||
assertEquals(1, directUrlMatches.size());
|
assertEquals(1, directUrlMatches.size());
|
||||||
assertEquals(key1, directUrlMatches.get(0));
|
assertEquals(key1, directUrlMatches.get(0));
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class SimpleUrlHandlerMappingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void handlerBeanNotFound() throws Exception {
|
public void handlerBeanNotFound() throws Exception {
|
||||||
MockServletContext sc = new MockServletContext("");
|
MockServletContext sc = new MockServletContext("");
|
||||||
XmlWebApplicationContext root = new XmlWebApplicationContext();
|
XmlWebApplicationContext root = new XmlWebApplicationContext();
|
||||||
@@ -89,6 +90,7 @@ public class SimpleUrlHandlerMappingTests {
|
|||||||
assertSame(controller, hec.getHandler());
|
assertSame(controller, hec.getHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
private void checkMappings(String beanName) throws Exception {
|
private void checkMappings(String beanName) throws Exception {
|
||||||
MockServletContext sc = new MockServletContext("");
|
MockServletContext sc = new MockServletContext("");
|
||||||
XmlWebApplicationContext wac = new XmlWebApplicationContext();
|
XmlWebApplicationContext wac = new XmlWebApplicationContext();
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNameExplicit() {
|
public void getNameExplicit() {
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ public class RequestMappingInfoHandlerMethodMappingNamingStrategyTests {
|
|||||||
|
|
||||||
RequestMappingInfo rmi = new RequestMappingInfo("foo", null, null, null, null, null, null, null);
|
RequestMappingInfo rmi = new RequestMappingInfo("foo", null, null, null, null, null, null, null);
|
||||||
|
|
||||||
HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
|
HandlerMethodMappingNamingStrategy<RequestMappingInfo> strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
|
||||||
|
|
||||||
assertEquals("foo", strategy.getName(handlerMethod, rmi));
|
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);
|
RequestMappingInfo rmi = new RequestMappingInfo(null, null, null, null, null, null, null, null);
|
||||||
|
|
||||||
HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
|
HandlerMethodMappingNamingStrategy<RequestMappingInfo> strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
|
||||||
|
|
||||||
assertEquals("TC#handle", strategy.getName(handlerMethod, rmi));
|
assertEquals("TC#handle", strategy.getName(handlerMethod, rmi));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
Object actual = testResolveArgument(param, factory);
|
||||||
assertNotNull(actual);
|
assertNotNull(actual);
|
||||||
assertEquals(Optional.class, actual.getClass());
|
assertEquals(Optional.class, actual.getClass());
|
||||||
assertFalse(((Optional) actual).isPresent());
|
assertFalse(((Optional<?>) actual).isPresent());
|
||||||
|
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
this.webRequest.setAttribute("foo", foo, getScope());
|
this.webRequest.setAttribute("foo", foo, getScope());
|
||||||
@@ -139,8 +139,8 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
|
|||||||
actual = testResolveArgument(param, factory);
|
actual = testResolveArgument(param, factory);
|
||||||
assertNotNull(actual);
|
assertNotNull(actual);
|
||||||
assertEquals(Optional.class, actual.getClass());
|
assertEquals(Optional.class, actual.getClass());
|
||||||
assertTrue(((Optional) actual).isPresent());
|
assertTrue(((Optional<?>) actual).isPresent());
|
||||||
assertSame(foo, ((Optional) actual).get());
|
assertSame(foo, ((Optional<?>) actual).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object testResolveArgument(MethodParameter param) throws Exception {
|
private Object testResolveArgument(MethodParameter param) throws Exception {
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -76,6 +76,7 @@ public class CrossOriginTests {
|
|||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void setup() {
|
public void setup() {
|
||||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ public class ExceptionHandlerExceptionResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
public void nullHandler() {
|
public void nullHandler() {
|
||||||
Object handler = null;
|
Object handler = null;
|
||||||
this.resolver.afterPropertiesSet();
|
this.resolver.afterPropertiesSet();
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -125,7 +125,6 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public ModelAndView resolveModelAndView(Method method, Class<?> handlerType, Object returnValue,
|
public ModelAndView resolveModelAndView(Method method, Class<?> handlerType, Object returnValue,
|
||||||
ExtendedModelMap model, NativeWebRequest request) {
|
ExtendedModelMap model, NativeWebRequest request) {
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.servlet.mvc.method.annotation;
|
package org.springframework.web.servlet.mvc.method.annotation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -400,8 +401,10 @@ public class ReactiveTypeHandlerTests {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -385,7 +385,6 @@ public class RequestMappingHandlerAdapterTests {
|
|||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
private static class ResponseCodeSuppressingAdvice extends AbstractMappingJacksonResponseBodyAdvice {
|
private static class ResponseCodeSuppressingAdvice extends AbstractMappingJacksonResponseBodyAdvice {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType,
|
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType,
|
||||||
MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
|
MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
Object actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
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);
|
actualValue = resolver.resolveArgument(optionalMultipartFile, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
assertTrue(actualValue instanceof Optional);
|
||||||
assertEquals("Invalid result", expected, ((Optional) actualValue).get());
|
assertEquals("Invalid result", expected, ((Optional<?>) actualValue).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -366,11 +366,11 @@ public class RequestPartMethodArgumentResolverTests {
|
|||||||
|
|
||||||
Object actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null);
|
Object actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
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);
|
actualValue = resolver.resolveArgument(optionalMultipartFileList, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
assertTrue(actualValue instanceof Optional);
|
||||||
assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get());
|
assertEquals("Invalid result", Collections.singletonList(expected), ((Optional<?>) actualValue).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -408,11 +408,11 @@ public class RequestPartMethodArgumentResolverTests {
|
|||||||
|
|
||||||
Object actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null);
|
Object actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
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);
|
actualValue = resolver.resolveArgument(optionalPart, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
assertTrue(actualValue instanceof Optional);
|
||||||
assertEquals("Invalid result", expected, ((Optional) actualValue).get());
|
assertEquals("Invalid result", expected, ((Optional<?>) actualValue).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -452,11 +452,11 @@ public class RequestPartMethodArgumentResolverTests {
|
|||||||
|
|
||||||
Object actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
|
Object actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
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);
|
actualValue = resolver.resolveArgument(optionalPartList, null, webRequest, null);
|
||||||
assertTrue(actualValue instanceof Optional);
|
assertTrue(actualValue instanceof Optional);
|
||||||
assertEquals("Invalid result", Collections.singletonList(expected), ((Optional) actualValue).get());
|
assertEquals("Invalid result", Collections.singletonList(expected), ((Optional<?>) actualValue).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ public class RequestResponseBodyAdviceChainTests {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public String beforeBodyWrite(String body, MethodParameter returnType,
|
public String beforeBodyWrite(String body, MethodParameter returnType,
|
||||||
MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
|
MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
|
||||||
@@ -170,7 +169,6 @@ public class RequestResponseBodyAdviceChainTests {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public String beforeBodyWrite(String body, MethodParameter returnType,
|
public String beforeBodyWrite(String body, MethodParameter returnType,
|
||||||
MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
|
MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
|
||||||
|
|||||||
@@ -268,8 +268,8 @@ public class RequestResponseBodyMethodProcessorTests {
|
|||||||
this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
|
||||||
List<HttpMessageConverter<?>> converters = new ArrayList<>();
|
List<HttpMessageConverter<?>> converters = new ArrayList<>();
|
||||||
HttpMessageConverter target = new MappingJackson2HttpMessageConverter();
|
HttpMessageConverter<Object> target = new MappingJackson2HttpMessageConverter();
|
||||||
HttpMessageConverter proxy = ProxyFactory.getProxy(HttpMessageConverter.class, new SingletonTargetSource(target));
|
HttpMessageConverter<?> proxy = ProxyFactory.getProxy(HttpMessageConverter.class, new SingletonTargetSource(target));
|
||||||
converters.add(proxy);
|
converters.add(proxy);
|
||||||
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
|
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.servlet.mvc.method.annotation;
|
package org.springframework.web.servlet.mvc.method.annotation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -306,7 +307,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests {
|
|||||||
|
|
||||||
private ResponseEntity<AtomicReference<String>> h6() { return null; }
|
private ResponseEntity<AtomicReference<String>> h6() { return null; }
|
||||||
|
|
||||||
private ResponseEntity h7() { return null; }
|
private ResponseEntity<?> h7() { return null; }
|
||||||
|
|
||||||
private Flux<String> h8() { return null; }
|
private Flux<String> h8() { return null; }
|
||||||
|
|
||||||
@@ -315,6 +316,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class SimpleBean {
|
private static class SimpleBean {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
@ControllerAdvice
|
||||||
private static class ApplicationExceptionHandler extends ResponseEntityExceptionHandler {
|
private static class ApplicationExceptionHandler extends ResponseEntityExceptionHandler {
|
||||||
|
|
||||||
@@ -253,7 +250,6 @@ public class ResponseEntityExceptionHandlerTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
void handle(String arg) {
|
void handle(String arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3033,7 +3033,6 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
|||||||
public static class MyModelAndViewResolver implements ModelAndViewResolver {
|
public static class MyModelAndViewResolver implements ModelAndViewResolver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public ModelAndView resolveModelAndView(Method handlerMethod, Class<?> handlerType, Object returnValue,
|
public ModelAndView resolveModelAndView(Method handlerMethod, Class<?> handlerType, Object returnValue,
|
||||||
ExtendedModelMap implicitModel, NativeWebRequest webRequest) {
|
ExtendedModelMap implicitModel, NativeWebRequest webRequest) {
|
||||||
|
|
||||||
@@ -3048,7 +3047,6 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
response.getWriter().write("myValue");
|
response.getWriter().write("myValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return UNRESOLVED;
|
return UNRESOLVED;
|
||||||
@@ -3143,7 +3141,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
|||||||
String ARTICLES_PATH = API_V1 + "/articles";
|
String ARTICLES_PATH = API_V1 + "/articles";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ResourceEndpoint<E extends Entity, P extends EntityPredicate> {
|
public interface ResourceEndpoint<E extends Entity, P extends EntityPredicate<?>> {
|
||||||
|
|
||||||
Collection<E> find(String pageable, P predicate) throws IOException;
|
Collection<E> find(String pageable, P predicate) throws IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -458,6 +458,7 @@ public class ServletInvocableHandlerMethodTests {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -107,6 +107,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void createAttributeUriTemplateVarWithOptional() throws Exception {
|
public void createAttributeUriTemplateVarWithOptional() throws Exception {
|
||||||
Map<String, String> uriTemplateVars = new HashMap<>();
|
Map<String, String> uriTemplateVars = new HashMap<>();
|
||||||
uriTemplateVars.put("testBean3", "Patty");
|
uriTemplateVars.put("testBean3", "Patty");
|
||||||
@@ -141,6 +142,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void createAttributeRequestParameterWithOptional() throws Exception {
|
public void createAttributeRequestParameterWithOptional() throws Exception {
|
||||||
request.addParameter("testBean3", "Patty");
|
request.addParameter("testBean3", "Patty");
|
||||||
|
|
||||||
@@ -151,6 +153,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void attributesAsNullValues() throws Exception {
|
public void attributesAsNullValues() throws Exception {
|
||||||
request.addParameter("name", "Patty");
|
request.addParameter("name", "Patty");
|
||||||
|
|
||||||
@@ -170,6 +173,7 @@ public class ServletModelAttributeMethodProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void attributesAsOptionalEmpty() throws Exception {
|
public void attributesAsOptionalEmpty() throws Exception {
|
||||||
request.addParameter("name", "Patty");
|
request.addParameter("name", "Patty");
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link ResourceUrlProvider}.
|
* Unit tests for {@link ResourceUrlProvider}.
|
||||||
*
|
*
|
||||||
@@ -138,6 +137,7 @@ public class ResourceUrlProviderTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-12592
|
@Test // SPR-12592
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void initializeOnce() throws Exception {
|
public void initializeOnce() throws Exception {
|
||||||
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||||
context.setServletContext(new MockServletContext());
|
context.setServletContext(new MockServletContext());
|
||||||
|
|||||||
@@ -365,7 +365,6 @@ public class MessageTagTests extends AbstractTagTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void nullMessageSource() throws JspException {
|
public void nullMessageSource() throws JspException {
|
||||||
PageContext pc = createPageContext();
|
PageContext pc = createPageContext();
|
||||||
ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext)
|
ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext)
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests {
|
|||||||
return (RequestContext) getPageContext().getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE);
|
return (RequestContext) getPageContext().getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
protected RequestDataValueProcessor getMockRequestDataValueProcessor() {
|
protected RequestDataValueProcessor getMockRequestDataValueProcessor() {
|
||||||
RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
|
RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
|
||||||
HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
|
HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 HttpServletRequest request;
|
||||||
|
|
||||||
private Map messageMap;
|
private Map<String, String> messageMap;
|
||||||
|
|
||||||
private Map themeMessageMap;
|
private Map<String, String> themeMessageMap;
|
||||||
|
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
|
|
||||||
@@ -48,11 +48,11 @@ public class DummyMacroRequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMessageMap(Map messageMap) {
|
public void setMessageMap(Map<String, String> messageMap) {
|
||||||
this.messageMap = messageMap;
|
this.messageMap = messageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThemeMessageMap(Map themeMessageMap) {
|
public void setThemeMessageMap(Map<String, String> themeMessageMap) {
|
||||||
this.themeMessageMap = themeMessageMap;
|
this.themeMessageMap = themeMessageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,60 +61,60 @@ public class DummyMacroRequestContext {
|
|||||||
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String)
|
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String)
|
||||||
*/
|
*/
|
||||||
public String getMessage(String code) {
|
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)
|
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String, String)
|
||||||
*/
|
*/
|
||||||
public String getMessage(String code, String defaultMsg) {
|
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);
|
return (msg != null ? msg : defaultMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List)
|
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List)
|
||||||
*/
|
*/
|
||||||
public String getMessage(String code, List args) {
|
public String getMessage(String code, List<?> args) {
|
||||||
return ((String) this.messageMap.get(code)) + args.toString();
|
return this.messageMap.get(code) + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List, String)
|
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List, String)
|
||||||
*/
|
*/
|
||||||
public String getMessage(String code, List args, String defaultMsg) {
|
public String getMessage(String code, List<?> args, String defaultMsg) {
|
||||||
String msg = (String) this.messageMap.get(code);
|
String msg = this.messageMap.get(code);
|
||||||
return (msg != null ? msg + args.toString(): defaultMsg);
|
return (msg != null ? msg + args : defaultMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String)
|
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String)
|
||||||
*/
|
*/
|
||||||
public String getThemeMessage(String code) {
|
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)
|
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, String)
|
||||||
*/
|
*/
|
||||||
public String getThemeMessage(String code, String defaultMsg) {
|
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);
|
return (msg != null ? msg : defaultMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List)
|
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List)
|
||||||
*/
|
*/
|
||||||
public String getThemeMessage(String code, List args) {
|
public String getThemeMessage(String code, List<?> args) {
|
||||||
return ((String) this.themeMessageMap.get(code)) + args.toString();
|
return this.themeMessageMap.get(code) + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String)
|
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String)
|
||||||
*/
|
*/
|
||||||
public String getThemeMessage(String code, List args, String defaultMsg) {
|
public String getThemeMessage(String code, List<?> args, String defaultMsg) {
|
||||||
String msg = (String) this.themeMessageMap.get(code);
|
String msg = this.themeMessageMap.get(code);
|
||||||
return (msg != null ? msg + args.toString(): defaultMsg);
|
return (msg != null ? msg + args : defaultMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContextPath(String contextPath) {
|
public void setContextPath(String contextPath) {
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ public class RedirectViewTests {
|
|||||||
assertEquals("http://url.somewhere.com", response.getHeader("Location"));
|
assertEquals("http://url.somewhere.com", response.getHeader("Location"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
|
||||||
public void flashMap() throws Exception {
|
public void flashMap() throws Exception {
|
||||||
RedirectView rv = new RedirectView();
|
RedirectView rv = new RedirectView();
|
||||||
rv.setUrl("http://url.somewhere.com/path");
|
rv.setUrl("http://url.somewhere.com/path");
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class ViewResolverTests {
|
|||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
||||||
request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
|
request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
|
||||||
Map model = new HashMap();
|
Map<String, Object> model = new HashMap<>();
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
model.put("tb", tb);
|
model.put("tb", tb);
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
@@ -184,7 +184,7 @@ public class ViewResolverTests {
|
|||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("key1", "value1");
|
props.setProperty("key1", "value1");
|
||||||
vr.setAttributes(props);
|
vr.setAttributes(props);
|
||||||
Map map = new HashMap();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("key2", new Integer(2));
|
map.put("key2", new Integer(2));
|
||||||
vr.setAttributesMap(map);
|
vr.setAttributesMap(map);
|
||||||
vr.setApplicationContext(wac);
|
vr.setApplicationContext(wac);
|
||||||
@@ -192,7 +192,7 @@ public class ViewResolverTests {
|
|||||||
View view = vr.resolveViewName("example1", Locale.getDefault());
|
View view = vr.resolveViewName("example1", Locale.getDefault());
|
||||||
assertEquals("Correct view class", JstlView.class, view.getClass());
|
assertEquals("Correct view class", JstlView.class, view.getClass());
|
||||||
assertEquals("Correct URL", "example1", ((InternalResourceView) view).getUrl());
|
assertEquals("Correct URL", "example1", ((InternalResourceView) view).getUrl());
|
||||||
Map attributes = ((InternalResourceView) view).getStaticAttributes();
|
Map<String, Object> attributes = ((InternalResourceView) view).getStaticAttributes();
|
||||||
assertEquals("value1", attributes.get("key1"));
|
assertEquals("value1", attributes.get("key1"));
|
||||||
assertEquals(new Integer(2), attributes.get("key2"));
|
assertEquals(new Integer(2), attributes.get("key2"));
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ public class ViewResolverTests {
|
|||||||
HttpServletResponse response = new MockHttpServletResponse();
|
HttpServletResponse response = new MockHttpServletResponse();
|
||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
||||||
Map model = new HashMap();
|
Map<String, Object> model = new HashMap<>();
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
model.put("tb", tb);
|
model.put("tb", tb);
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
@@ -230,7 +230,7 @@ public class ViewResolverTests {
|
|||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("key1", "value1");
|
props.setProperty("key1", "value1");
|
||||||
vr.setAttributes(props);
|
vr.setAttributes(props);
|
||||||
Map map = new HashMap();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("key2", new Integer(2));
|
map.put("key2", new Integer(2));
|
||||||
vr.setAttributesMap(map);
|
vr.setAttributesMap(map);
|
||||||
vr.setExposeContextBeansAsAttributes(true);
|
vr.setExposeContextBeansAsAttributes(true);
|
||||||
@@ -255,7 +255,7 @@ public class ViewResolverTests {
|
|||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
||||||
View view = vr.resolveViewName("example1", Locale.getDefault());
|
View view = vr.resolveViewName("example1", Locale.getDefault());
|
||||||
view.render(new HashMap(), request, response);
|
view.render(new HashMap<String, Object>(), request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -270,7 +270,7 @@ public class ViewResolverTests {
|
|||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("key1", "value1");
|
props.setProperty("key1", "value1");
|
||||||
vr.setAttributes(props);
|
vr.setAttributes(props);
|
||||||
Map map = new HashMap();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("key2", new Integer(2));
|
map.put("key2", new Integer(2));
|
||||||
vr.setAttributesMap(map);
|
vr.setAttributesMap(map);
|
||||||
vr.setExposedContextBeanNames(new String[] {"myBean2"});
|
vr.setExposedContextBeanNames(new String[] {"myBean2"});
|
||||||
@@ -295,7 +295,7 @@ public class ViewResolverTests {
|
|||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
|
||||||
View view = vr.resolveViewName("example1", Locale.getDefault());
|
View view = vr.resolveViewName("example1", Locale.getDefault());
|
||||||
view.render(new HashMap(), request, response);
|
view.render(new HashMap<String, Object>(), request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -323,7 +323,7 @@ public class ViewResolverTests {
|
|||||||
HttpServletResponse response = new MockHttpServletResponse();
|
HttpServletResponse response = new MockHttpServletResponse();
|
||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
|
||||||
Map model = new HashMap();
|
Map<String, Object> model = new HashMap<>();
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
model.put("tb", tb);
|
model.put("tb", tb);
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
@@ -362,7 +362,7 @@ public class ViewResolverTests {
|
|||||||
HttpServletResponse response = new MockHttpServletResponse();
|
HttpServletResponse response = new MockHttpServletResponse();
|
||||||
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||||
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
|
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
|
||||||
Map model = new HashMap();
|
Map<String, Object> model = new HashMap<>();
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
model.put("tb", tb);
|
model.put("tb", tb);
|
||||||
view.render(model, request, response);
|
view.render(model, request, response);
|
||||||
@@ -396,7 +396,7 @@ public class ViewResolverTests {
|
|||||||
assertTrue("Correct URL", "/example2new.jsp".equals(((InternalResourceView) view2).getUrl()));
|
assertTrue("Correct URL", "/example2new.jsp".equals(((InternalResourceView) view2).getUrl()));
|
||||||
|
|
||||||
ServletContext sc = new MockServletContext();
|
ServletContext sc = new MockServletContext();
|
||||||
Map model = new HashMap();
|
Map<String, Object> model = new HashMap<>();
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
model.put("tb", tb);
|
model.put("tb", tb);
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -50,6 +50,7 @@ public class XlsViewTests {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testXls() throws Exception {
|
public void testXls() throws Exception {
|
||||||
View excelView = new AbstractXlsView() {
|
View excelView = new AbstractXlsView() {
|
||||||
@Override
|
@Override
|
||||||
@@ -73,6 +74,7 @@ public class XlsViewTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testXlsxView() throws Exception {
|
public void testXlsxView() throws Exception {
|
||||||
View excelView = new AbstractXlsxView() {
|
View excelView = new AbstractXlsxView() {
|
||||||
@Override
|
@Override
|
||||||
@@ -96,6 +98,7 @@ public class XlsViewTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void testXlsxStreamingView() throws Exception {
|
public void testXlsxStreamingView() throws Exception {
|
||||||
View excelView = new AbstractXlsxStreamingView() {
|
View excelView = new AbstractXlsxStreamingView() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.Content;
|
||||||
import com.rometools.rome.feed.atom.Entry;
|
import com.rometools.rome.feed.atom.Entry;
|
||||||
import com.rometools.rome.feed.atom.Feed;
|
import com.rometools.rome.feed.atom.Feed;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
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.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -41,12 +39,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
*/
|
*/
|
||||||
public class AtomFeedViewTests {
|
public class AtomFeedViewTests {
|
||||||
|
|
||||||
private AbstractAtomFeedView view;
|
private final AbstractAtomFeedView view = new MyAtomFeedView();
|
||||||
|
|
||||||
@Before
|
|
||||||
public void createView() throws Exception {
|
|
||||||
view = new MyAtomFeedView();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void render() throws Exception {
|
public void render() throws Exception {
|
||||||
@@ -65,24 +58,21 @@ public class AtomFeedViewTests {
|
|||||||
assertThat(response.getContentAsString(), isSimilarTo(expected));
|
assertThat(response.getContentAsString(), isSimilarTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CompareMatcher isSimilarTo(final String content) {
|
private static CompareMatcher isSimilarTo(String content) {
|
||||||
return CompareMatcher.isSimilarTo(content)
|
return CompareMatcher.isSimilarTo(content).ignoreWhitespace();
|
||||||
.ignoreWhitespace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MyAtomFeedView extends AbstractAtomFeedView {
|
private static class MyAtomFeedView extends AbstractAtomFeedView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildFeedMetadata(Map model, Feed feed, HttpServletRequest request) {
|
protected void buildFeedMetadata(Map<String, Object>model, Feed feed, HttpServletRequest request) {
|
||||||
feed.setTitle("Test Feed");
|
feed.setTitle("Test Feed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Entry> buildFeedEntries(Map model, HttpServletRequest request, HttpServletResponse response)
|
protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
|
||||||
throws Exception {
|
|
||||||
List<Entry> entries = new ArrayList<>();
|
List<Entry> entries = new ArrayList<>();
|
||||||
for (Iterator iterator = model.keySet().iterator(); iterator.hasNext();) {
|
for (String name : model.keySet()) {
|
||||||
String name = (String) iterator.next();
|
|
||||||
Entry entry = new Entry();
|
Entry entry = new Entry();
|
||||||
entry.setTitle(name);
|
entry.setTitle(name);
|
||||||
Content content = new Content();
|
Content content = new Content();
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public class GroovyMarkupConfigurerTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public void parentLoader() throws Exception {
|
public void parentLoader() throws Exception {
|
||||||
|
|
||||||
this.configurer.setApplicationContext(this.applicationContext);
|
this.configurer.setApplicationContext(this.applicationContext);
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.servlet.view.groovy;
|
package org.springframework.web.servlet.view.groovy;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -35,7 +36,7 @@ public class GroovyMarkupViewResolverTests {
|
|||||||
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
|
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
|
||||||
Assert.assertEquals(GroovyMarkupView.class, resolver.requiredViewClass());
|
Assert.assertEquals(GroovyMarkupView.class, resolver.requiredViewClass());
|
||||||
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
|
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
|
||||||
Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass");
|
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
|
||||||
Assert.assertEquals(GroovyMarkupView.class, viewClass);
|
Assert.assertEquals(GroovyMarkupView.class, viewClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ public class MappingJackson2JsonViewTests {
|
|||||||
|
|
||||||
|
|
||||||
@JsonFilter("myJacksonFilter")
|
@JsonFilter("myJacksonFilter")
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class TestSimpleBeanFiltered {
|
private static class TestSimpleBeanFiltered {
|
||||||
|
|
||||||
private String property1;
|
private String property1;
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
|
||||||
Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
|
Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
|
||||||
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
|
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
|
||||||
Class viewClass = (Class) viewAccessor.getPropertyValue("viewClass");
|
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
|
||||||
Assert.assertEquals(ScriptTemplateView.class, viewClass);
|
Assert.assertEquals(ScriptTemplateView.class, viewClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user