ServletRequest extends AbstractClientRequest { public void doForward(String path) throws IOException { if (response.isCommitted()) { doInclude(path); } else { forward(path); } } ServletRequest(
            ApplicationContext applicationContext,
            HttpServletRequest request, HttpServletResponse response); Map<String, String> getHeader(); Addable<String> getResponseHeaders(); Map<String, String[]> getHeaderValues(); Map<String, String> getParam(); @SuppressWarnings("unchecked") Map<String, String[]> getParamValues(); @Override Map<String, Object> getContext(String scope); Map<String, Object> getRequestScope(); Map<String, Object> getSessionScope(); @Override List<String> getAvailableScopes(); void doForward(String path); void doInclude(String path); OutputStream getOutputStream(); Writer getWriter(); PrintWriter getPrintWriter(); boolean isResponseCommitted(); void setContentType(String contentType); Locale getRequestLocale(); HttpServletRequest getRequest(); HttpServletResponse getResponse(); boolean isUserInRole(String role);  }
@Test public void testDoForward() throws ServletException, IOException { RequestDispatcher rd = createMock(RequestDispatcher.class); expect(response.isCommitted()).andReturn(false); expect(request.getRequestDispatcher("/my/path")).andReturn(rd); rd.forward(request, response); replay(applicationContext, request, response, rd); req.doForward("/my/path"); verify(applicationContext, request, response, rd); }
@Test(expected = IOException.class) public void testDoForwardNoDispatcher() throws IOException { expect(response.isCommitted()).andReturn(false); expect(request.getRequestDispatcher("/my/path")).andReturn(null); replay(applicationContext, request, response); try { req.doForward("/my/path"); } finally { verify(applicationContext, request, response); } }
@Test public void testDoForwardInclude() throws ServletException, IOException { RequestDispatcher rd = createMock(RequestDispatcher.class); expect(response.isCommitted()).andReturn(true); expect(request.getRequestDispatcher("/my/path")).andReturn(rd); rd.include(request, response); replay(applicationContext, request, response, rd); req.doForward("/my/path"); verify(applicationContext, request, response, rd); }