### Question:
LoginServlet extends HttpServlet { @Override protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException { try { request.setCharacterEncoding(StandardCharsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { throw new ServletException(e); } if (request.getContentType() != null && !MediaType.APPLICATION_WWW_FORM.equals(ContentType.readMediaType(request.getContentType()))) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "The only content type supported by this service is application/x-www-form-urlencoded. The content-type request header needs to be set accordingly."); } response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); } else { handleLogin(request, response); } }  String dropPassword(final String content);  }### Answer:
@Test public void should_send_error_415_when_login_with_wrong_content_type() throws Exception { final LoginServlet servlet = spy(new LoginServlet()); doReturn("application/json").when(req).getContentType(); servlet.doPost(req, resp); verify(resp).setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); }