### Question:
MakeRequestServlet extends InjectedServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { try { makeRequestHandler.fetch(request, response); } catch (GadgetException e) { if (LOG.isLoggable(Level.FINEST)) { LOG.logp(Level.FINEST, classname, "doGet", MessageKeys.HTTP_ERROR_FETCHING, e); } int responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; if (e.getCode() != GadgetException.Code.INTERNAL_SERVER_ERROR) { responseCode = HttpServletResponse.SC_BAD_REQUEST; } response.sendError(responseCode, e.getMessage() != null ? e.getMessage() : ""); } }  @Inject void setMakeRequestHandler(MakeRequestHandler makeRequestHandler);  }### Answer:
@Test public void testDoGetHttpError() throws Exception { setupGet(); expect(pipeline.execute(internalRequest)).andReturn(HttpResponse.notFound()); replay(); servlet.doGet(request, recorder); assertResponseOk(HttpResponse.SC_NOT_FOUND, ""); }
@Test public void testDoGetException() throws Exception { setupGet(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doGet(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
@Test public void testDoPostHttpError() throws Exception { setupPost(); expect(pipeline.execute(internalRequest)).andReturn(HttpResponse.notFound()); replay(); servlet.doGet(request, recorder); assertResponseOk(HttpResponse.SC_NOT_FOUND, ""); }