ServletHelpers { public static void doForbidden(HttpServletResponse response) { doForbidden(response, ForbiddenReason.NONE); }  static void doForbidden(HttpServletResponse response); static void doForbidden(HttpServletResponse response, ForbiddenReason reason); static void doAuthPrompt(String realm, HttpServletResponse response); static void sendJSONResponse(HttpServletResponse response, boolean value); static void sendJSONResponse(HttpServletResponse response, String json); static JSONObject readObject(BufferedReader reader); static void writeEmpty(PrintWriter out); static void writeObject(Converters converters, JsonConvertOptions options, PrintWriter out, Object data); static Map populateTableMapForXl(List listEntry); static Map populateErrorTableMapForXl(List listEntry); static String generateCsvString(Map xlData); static List flatten(List list); static Set flatten(Set set); static String removeNoisyString(Object value); static InputStream loadFile(String path);  }
@Test public void testDoForbiddenResponseWithCustomReason() throws IOException { HttpServletResponse httpResponse = mock(HttpServletResponse.class); ServletHelpers.doForbidden(httpResponse, ForbiddenReason.HOST_NOT_ALLOWED); verify(httpResponse).setStatus(HttpServletResponse.SC_FORBIDDEN); verify(httpResponse).setContentLength(0); verify(httpResponse).setHeader(HEADER_HAWTIO_FORBIDDEN_REASON, ForbiddenReason.HOST_NOT_ALLOWED.name()); verify(httpResponse).flushBuffer(); }
@Test public void testDoForbidden() throws IOException { HttpServletResponse httpResponse = mock(HttpServletResponse.class); ServletHelpers.doForbidden(httpResponse); verify(httpResponse).setStatus(HttpServletResponse.SC_FORBIDDEN); verify(httpResponse).setContentLength(0); verify(httpResponse).setHeader(HEADER_HAWTIO_FORBIDDEN_REASON, ForbiddenReason.NONE.name()); verify(httpResponse).flushBuffer(); }