ServletRequest extends AbstractClientRequest { public void doInclude(String path) throws IOException { RequestDispatcher rd = request.getRequestDispatcher(path); if (rd == null) { throw new IOException("No request dispatcher returned for path '" + path + "'"); } try { rd.include(request, response); } catch (ServletException ex) { throw ServletUtil.wrapServletException(ex, "ServletException including path '" + 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 testDoInclude() throws IOException, ServletException { RequestDispatcher rd = createMock(RequestDispatcher.class); expect(request.getRequestDispatcher("/my/path")).andReturn(rd); rd.include(request, response); replay(applicationContext, request, response, rd); req.doInclude("/my/path"); verify(applicationContext, request, response, rd); }
@Test(expected = IOException.class) public void testDoIncludeNoDispatcher() throws IOException { expect(request.getRequestDispatcher("/my/path")).andReturn(null); replay(applicationContext, request, response); try { req.doInclude("/my/path"); } finally { verify(applicationContext, request, response); } }
@Test(expected = IOException.class) public void testDoIncludeServletException() throws IOException, ServletException { RequestDispatcher rd = createMock(RequestDispatcher.class); expect(request.getRequestDispatcher("/my/path")).andReturn(rd); rd.include(request, response); expectLastCall().andThrow(new ServletException()); replay(applicationContext, request, response, rd); try { req.doInclude("/my/path"); } finally { verify(applicationContext, request, response, rd); } }