PortletRequest extends AbstractClientRequest { public void doInclude(String path) throws IOException { try { PortletRequestDispatcher rd = getPortletContext() .getRequestDispatcher(path); if (rd == null) { throw new IOException( "No portlet request dispatcher returned for path '" + path + "'"); } rd.include(request, response); } catch (PortletException e) { throw new IOException("PortletException while including path '" + path + "'.", e); } } PortletRequest(ApplicationContext applicationContext,
            PortletContext context, javax.portlet.PortletRequest request,
            PortletResponse response, RequestDelegate requestDelegate, ResponseDelegate responseDelegate); javax.portlet.PortletRequest getRequest(); PortletResponse getResponse(); PortletContext getPortletContext(); Map<String, String> getHeader(); Addable<String> getResponseHeaders(); Map<String, String[]> getHeaderValues(); Map<String, Object> getRequestScope(); Map<String, Object> getSessionScope(); Map<String, Object> getPortletSessionScope(); @Override List<String> getAvailableScopes(); Locale getRequestLocale(); @Override Map<String, String> getParam(); @Override Map<String, String[]> getParamValues(); boolean isUserInRole(String role); @Override OutputStream getOutputStream(); @Override PrintWriter getPrintWriter(); @Override Writer getWriter(); @Override boolean isResponseCommitted(); @Override void setContentType(String contentType); void doForward(String path); void doInclude(String path); @Override Map<String, Object> getContext(String scope);  }
@Test public void testDoInclude() throws IOException, PortletException { PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class); expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd); rd.include(request, response); replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate); req.doInclude("/my/path"); verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate); }
@Test(expected = IOException.class) public void testDoIncludeNoDispatcher() throws IOException { expect(portletContext.getRequestDispatcher("/my/path")).andReturn(null); replay(applicationContext, request, response, portletContext, requestDelegate, responseDelegate); try { req.doInclude("/my/path"); } finally { verify(applicationContext, request, response, portletContext, requestDelegate, responseDelegate); } }
@Test(expected = IOException.class) public void testDoIncludePortletException() throws IOException, PortletException { PortletRequestDispatcher rd = createMock(PortletRequestDispatcher.class); expect(portletContext.getRequestDispatcher("/my/path")).andReturn(rd); rd.include(request, response); expectLastCall().andThrow(new PortletException()); replay(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate); try { req.doInclude("/my/path"); } finally { verify(applicationContext, request, response, rd, portletContext, requestDelegate, responseDelegate); } }