### Question:
HttpRequestHandler extends SimpleChannelUpstreamHandler { protected HttpResponse handleToken(HttpRequest request) { HttpResponse response = null; String contentType = request.headers().get(HttpHeaders.Names.CONTENT_TYPE); if (contentType != null && contentType.contains(HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED)) { try { AccessToken accessToken = auth.issueAccessToken(request); if (accessToken != null) { ObjectMapper mapper = new ObjectMapper(); String jsonString = mapper.writeValueAsString(accessToken); log.debug("access token:" + jsonString); response = Response.createOkResponse(jsonString); accessTokensLog.debug("token {}", jsonString); } } catch (OAuthException ex) { response = Response.createOAuthExceptionResponse(ex); invokeExceptionHandler(ex, request); } catch (JsonGenerationException e1) { log.error("error handle token", e1); invokeExceptionHandler(e1, request); } catch (JsonMappingException e1) { log.error("error handle token", e1); invokeExceptionHandler(e1, request); } catch (IOException e1) { log.error("error handle token", e1); invokeExceptionHandler(e1, request); } if (response == null) { response = Response.createBadRequestResponse(Response.CANNOT_ISSUE_TOKEN); } } else { response = Response.createResponse(HttpResponseStatus.BAD_REQUEST, Response.UNSUPPORTED_MEDIA_TYPE); } return response; }  @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent e);  }### Answer:
@Test public void when_content_type_is_not_application_form_urlencoded_on_post_tokens_return_400_and_unsupported_metida_type() throws Exception { HttpRequest req = mock(HttpRequest.class); HttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaders.Names.CONTENT_TYPE, "application/json"); willReturn(headers).given(req).headers(); HttpResponse response = handler.handleToken(req); assertEquals(response.getStatus(), HttpResponseStatus.BAD_REQUEST); assertEquals(response.getContent().toString(CharsetUtil.UTF_8), Response.UNSUPPORTED_MEDIA_TYPE); }