@Test public void doPostHttpError() throws Exception { setupPost(); expect(fixture.httpFetcher.fetch(request)).andReturn(HttpResponse.notFound()); fixture.replay(); servlet.doGet(fixture.request, recorder); assertResponseOk(HttpResponse.SC_NOT_FOUND, ""); }
@Test public void doGetNormal() throws Exception { setupGet(); expect(fixture.httpFetcher.fetch(request)).andReturn(response); fixture.replay(); servlet.doGet(fixture.request, recorder); assertResponseOk(HttpResponse.SC_OK, RESPONSE_BODY); }
@Test public void doGetException() throws Exception { setupGet(); expect(fixture.httpFetcher.fetch(request)) .andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); fixture.replay(); servlet.doGet(fixture.request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }