ContentNegotiatingViewResolver properly handles invalid accept headers (SPR-7712)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package org.springframework.web.servlet.view;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -37,6 +28,7 @@ import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
@@ -48,6 +40,9 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@@ -191,6 +186,14 @@ public class ContentNegotiatingViewResolverTests {
|
||||
verify(viewResolverMock, viewMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveViewNameWithInvalidAcceptHeader() throws Exception {
|
||||
request.addHeader("Accept", "application");
|
||||
|
||||
View result = viewResolver.resolveViewName("test", Locale.ENGLISH);
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveViewNameWithRequestParameter() throws Exception {
|
||||
request.addParameter("format", "xls");
|
||||
|
||||
Reference in New Issue
Block a user