@Test public void setCharacterEncodingThenContentType() { request.setCharacterEncoding("UTF-8"); request.setContentType("test/plain"); assertEquals("test/plain", request.getContentType()); assertEquals("test/plain;charset=UTF-8", request.getHeader("Content-Type")); assertEquals("UTF-8", request.getCharacterEncoding()); }
@Test public void contentTypeHeader() { String contentType = "test/plain"; request.addHeader("Content-Type", contentType); assertEquals(contentType, request.getContentType()); assertEquals(contentType, request.getHeader("Content-Type")); assertNull(request.getCharacterEncoding()); }
@Test public void contentTypeHeaderUTF8() { String contentType = "test/plain;charset=UTF-8"; request.addHeader("Content-Type", contentType); assertEquals(contentType, request.getContentType()); assertEquals(contentType, request.getHeader("Content-Type")); assertEquals("UTF-8", request.getCharacterEncoding()); }
@Test public void characterEncoding() throws Exception { String encoding = "UTF-8"; this.builder.characterEncoding(encoding); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); assertEquals(encoding, request.getCharacterEncoding()); }