### Question:
MqHandler implements Handler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (maps.size() == 0) { synchronized (this) { if (maps.size() == 0) { mqClientStatController=MqSpringUtil.getBean(MqClientStatController.class); if(mqClientStatController==null) { mqClientStatController=new MqClientStatController(); } initMap(); } } } if (maps.containsKey(request.getRequestURI())) { response.setContentType("text/html;charset=UTF-8"); StringBuilder sbHtml = new StringBuilder(); sbHtml.append( "<!doctype html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>"); try { sbHtml.append(maps.get(request.getRequestURI()).invoke(mqClientStatController).toString()); sbHtml.append("</body></html>"); response.getWriter().write(sbHtml.toString()); response.flushBuffer(); } catch (Exception e) { } } }  @Override void addLifeCycleListener(Listener arg0); @Override boolean isFailed(); @Override boolean isRunning(); @Override boolean isStarted(); @Override boolean isStarting(); @Override boolean isStopped(); @Override boolean isStopping(); @Override void removeLifeCycleListener(Listener arg0); @Override void start(); @Override void stop(); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); @Override void setServer(Server server); @Override Server getServer(); @Override void destroy();  }### Answer:
@Test public void handleTest() throws IOException, ServletException { MqClientStatController mqClientStatController=new MqClientStatController(); MqHandler mqHandler=new MqHandler(); ReflectionTestUtils.setField(mqHandler, "mqClientStatController", mqClientStatController); Request request=mock(Request.class); HttpServletRequest httpServletRequest=mock(HttpServletRequest.class); HttpServletResponse httpServletResponse=mock(HttpServletResponse.class); when(httpServletRequest.getRequestURI()).thenReturn("/mq/client/hs"); PrintWriter printWriter=mock(PrintWriter.class); when(httpServletResponse.getWriter()).thenReturn(printWriter); mqHandler.handle("", request, httpServletRequest, httpServletResponse); verify(printWriter).write(anyString()); }