### Question:
GatewayForwardingServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); redirectToContext = config.getInitParameter("redirectTo"); }  @Override void init(ServletConfig config); @Override void doGet(HttpServletRequest request,
                    HttpServletResponse response);  }### Answer:
@Test public void testRedirectDefaults() throws ServletException, IOException { IMocksControl mockControl = EasyMock.createControl(); ServletConfig config = mockControl.createMock(ServletConfig.class); ServletContext context = mockControl.createMock(ServletContext.class); HttpServletRequest request = mockControl.createMock(HttpServletRequest.class); HttpServletResponse response = mockControl.createMock(HttpServletResponse.class); RequestDispatcher dispatcher = mockControl.createMock(RequestDispatcher.class); EasyMock.expect(config.getServletName()).andStubReturn("default"); EasyMock.expect(config.getServletContext()).andStubReturn(context); EasyMock.expect(config.getInitParameter("redirectTo")).andReturn("/gateway/sandbox"); EasyMock.expect(request.getMethod()).andReturn("GET").anyTimes(); EasyMock.expect(request.getPathInfo()).andReturn("/webhdfs/v1/tmp").anyTimes(); EasyMock.expect(request.getQueryString()).andReturn("op=LISTSTATUS"); EasyMock.expect(response.getStatus()).andReturn(200).anyTimes(); EasyMock.expect(context.getContext("/gateway/sandbox")).andReturn(context); EasyMock.expect(context.getRequestDispatcher("/webhdfs/v1/tmp?op=LISTSTATUS")).andReturn(dispatcher); dispatcher.forward(request, response); EasyMock.expectLastCall().once(); context.log(EasyMock.anyObject()); EasyMock.expectLastCall().anyTimes(); mockControl.replay(); GatewayForwardingServlet servlet = new GatewayForwardingServlet(); servlet.init(config); servlet.service(request, response); mockControl.verify(); }