MockHttpServletResponse.setIntHeader supports 'Content-Length' header as well
Issue: SPR-13752
This commit is contained in:
@@ -19,7 +19,6 @@ package org.springframework.mock.web;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -92,9 +91,7 @@ public class MockHttpServletResponseTests {
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
}
|
||||
|
||||
// SPR-12677
|
||||
|
||||
@Test
|
||||
@Test // SPR-12677
|
||||
public void contentTypeHeaderWithMoreComplexCharsetSyntax() {
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foo=bar";
|
||||
response.setHeader("Content-Type", contentType);
|
||||
@@ -141,6 +138,13 @@ public class MockHttpServletResponseTests {
|
||||
assertEquals("66", response.getHeader("Content-Length"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentLengthIntHeader() {
|
||||
response.addIntHeader("Content-Length", 66);
|
||||
assertEquals(66, response.getContentLength());
|
||||
assertEquals("66", response.getHeader("Content-Length"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpHeaderNameCasingIsPreserved() throws Exception {
|
||||
final String headerName = "Header1";
|
||||
@@ -269,20 +273,14 @@ public class MockHttpServletResponseTests {
|
||||
response.getDateHeader("Last-Modified");
|
||||
}
|
||||
|
||||
/**
|
||||
* SPR-10414
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-10414
|
||||
public void modifyStatusAfterSendError() throws IOException {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
assertEquals(response.getStatus(),HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* SPR-10414
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-10414
|
||||
@SuppressWarnings("deprecation")
|
||||
public void modifyStatusMessageAfterSendError() throws IOException {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user