@Test public void testDoGet() throws Exception { logger.info("doGet"); Server server = Help.getServer(RulesServlet.class); server.start(); try { String url = String.format("http: Help.Res r = Help.doGet(url); assertEquals(404, r.getCode()); url = String.format("http: r = Help.doGet(url); assertEquals(200, r.getCode()); } finally { server.stop(); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { logger.info(String.format("get rule %s", request.getPathInfo())); String ruleName = request.getPathInfo(); ruleName = ruleName == null ? "/" : ruleName; Result r = RulesManager.get(epService, ruleName.substring(1)); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }
RulesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { logger.info(String.format("get rule %s", request.getPathInfo())); String ruleName = request.getPathInfo(); ruleName = ruleName == null ? "/" : ruleName; Result r = RulesManager.get(epService, ruleName.substring(1)); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } }
RulesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { logger.info(String.format("get rule %s", request.getPathInfo())); String ruleName = request.getPathInfo(); ruleName = ruleName == null ? "/" : ruleName; Result r = RulesManager.get(epService, ruleName.substring(1)); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  }
RulesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { logger.info(String.format("get rule %s", request.getPathInfo())); String ruleName = request.getPathInfo(); ruleName = ruleName == null ? "/" : ruleName; Result r = RulesManager.get(epService, ruleName.substring(1)); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  @Override void init(); @Override void destroy(); @Override String getServletInfo(); }
RulesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { logger.info(String.format("get rule %s", request.getPathInfo())); String ruleName = request.getPathInfo(); ruleName = ruleName == null ? "/" : ruleName; Result r = RulesManager.get(epService, ruleName.substring(1)); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  @Override void init(); @Override void destroy(); @Override String getServletInfo();  }