### Question:
GetRootServlet extends BaseHttpServlet implements IHopServerPlugin { public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { if ( isJettyMode() && !request.getRequestURI().equals( CONTEXT_PATH ) ) { response.sendError( HttpServletResponse.SC_NOT_FOUND ); return; } if ( log.isDebug() ) { logDebug( BaseMessages.getString( PKG, "GetRootServlet.RootRequested" ) ); } response.setContentType( "text/html;charset=UTF-8" ); response.setStatus( HttpServletResponse.SC_OK ); PrintWriter out = response.getWriter(); out.println( "<HTML>" ); out.println( "<HEAD><TITLE>" + BaseMessages.getString( PKG, "GetRootServlet.HopHopServer.Title" ) + "</TITLE>" ); out.println( "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" ); out.println( "</HEAD>" ); out.println( "<BODY>" ); out.println( "<H2>" + BaseMessages.getString( PKG, "GetRootServlet.HopServerMenu" ) + "</H2>" ); out.println( "<p>" ); out.println( "<a href=\"" + convertContextPath( GetStatusServlet.CONTEXT_PATH ) + "\">" + BaseMessages.getString( PKG, "GetRootServlet.ShowStatus" ) + "</a><br>" ); out.println( "<p>" ); out.println( "</BODY>" ); out.println( "</HTML>" ); } GetRootServlet(); void doGet( HttpServletRequest request, HttpServletResponse response ); String toString(); String getService(); String getContextPath(); static final String CONTEXT_PATH; }### Answer:
@Test public void testDoGetReturn404StatusCode() throws ServletException, IOException { GetRootServlet servlet = new GetRootServlet(); servlet.setJettyMode( true ); HttpServletRequest request = when( mock( HttpServletRequest.class ).getRequestURI() ).thenReturn( "/wrong_path" ).getMock(); HttpServletResponse response = mock( HttpServletResponse.class ); servlet.doGet( request, response ); verify( response ).sendError( HttpServletResponse.SC_NOT_FOUND ); }