@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 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 contentTypeHeader() {
   String contentType = "test/plain";
   request.addHeader("Content-Type", contentType);
   assertEquals(contentType, request.getContentType());
   assertEquals(contentType, request.getHeader("Content-Type"));
   assertNull(request.getCharacterEncoding());
 }
  // gh-3920
  @Test
  public void usesAcceptMediaForContentNegotiation() throws Exception {
    MockHttpServletRequest request =
        formLogin("/login")
            .user("username", "admin")
            .password("password", "secret")
            .buildRequest(this.servletContext);

    assertThat(request.getHeader("Accept")).isEqualTo(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
  }
  @Test
  public void headers() throws Exception {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setContentType(MediaType.APPLICATION_JSON);
    httpHeaders.put("foo", Arrays.asList("bar", "baz"));
    this.builder.headers(httpHeaders);

    MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
    List<String> headers = Collections.list(request.getHeaders("foo"));

    assertEquals(2, headers.size());
    assertEquals("bar", headers.get(0));
    assertEquals("baz", headers.get(1));
    assertEquals(MediaType.APPLICATION_JSON.toString(), request.getHeader("Content-Type"));
  }