@Test public void testDoGetShouldSetContentTypeToTextWhenReqParamSourceIsNotTrue() throws ServletException, IOException, JsonTransformationException { given(request.getParameter("source")).willReturn(""); given(request.getHeader("User-Agent")).willReturn(null); given(stubResourceHolder.getActualStubConfigJsonObject(DEFAULT_GROUPNAME)).willReturn(jsonObject); byte[] xmlAsByteArray = "DOCUMENT".getBytes(); given(jsonBasedObjectTransformer.transform(jsonObject)).willReturn(xmlAsByteArray); given(byteArrayConverter.toString(xmlAsByteArray)).willReturn(FILE_CONTENT); underTest.doGet(request, response); verify(response).setContentType("text/plain"); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String sourceParameter = req.getParameter("groupname"); if (sourceParameter != null) { byte[] xml = getActualUsedJson(sourceParameter); if (xml != null) { setHeader(req, resp, sourceParameter); writeStubConfigToResponse(req, resp, xml); } else { writeErrorToResponse(resp); } } }
StubConfigHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String sourceParameter = req.getParameter("groupname"); if (sourceParameter != null) { byte[] xml = getActualUsedJson(sourceParameter); if (xml != null) { setHeader(req, resp, sourceParameter); writeStubConfigToResponse(req, resp, xml); } else { writeErrorToResponse(resp); } } } }
StubConfigHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String sourceParameter = req.getParameter("groupname"); if (sourceParameter != null) { byte[] xml = getActualUsedJson(sourceParameter); if (xml != null) { setHeader(req, resp, sourceParameter); writeStubConfigToResponse(req, resp, xml); } else { writeErrorToResponse(resp); } } } @Autowired  StubConfigHandlerServlet(JsonBasedObjectTransformer jsonBasedObjectTransformer, StubResourceHolder stubResourceHolder, ByteArrayConverter byteArrayConverter); }
StubConfigHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String sourceParameter = req.getParameter("groupname"); if (sourceParameter != null) { byte[] xml = getActualUsedJson(sourceParameter); if (xml != null) { setHeader(req, resp, sourceParameter); writeStubConfigToResponse(req, resp, xml); } else { writeErrorToResponse(resp); } } } @Autowired  StubConfigHandlerServlet(JsonBasedObjectTransformer jsonBasedObjectTransformer, StubResourceHolder stubResourceHolder, ByteArrayConverter byteArrayConverter);  }
StubConfigHandlerServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String sourceParameter = req.getParameter("groupname"); if (sourceParameter != null) { byte[] xml = getActualUsedJson(sourceParameter); if (xml != null) { setHeader(req, resp, sourceParameter); writeStubConfigToResponse(req, resp, xml); } else { writeErrorToResponse(resp); } } } @Autowired  StubConfigHandlerServlet(JsonBasedObjectTransformer jsonBasedObjectTransformer, StubResourceHolder stubResourceHolder, ByteArrayConverter byteArrayConverter);   }