* @throws ServletException If something goes wrong.
*/
@Test(expected = IOException.class)
public void testDoIncludeServletException() throws IOException, ServletException {
String path = "this way";
ServletRequest enclosedRequest = createMock(ServletRequest.class);
HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
expect(servletRequest.getRequestDispatcher("this way")).andReturn(dispatcher);
dispatcher.include(eq(servletRequest), isA(ExternalWriterHttpServletResponse.class));
expectLastCall().andThrow(new ServletException());
replay(servletRequest, response, dispatcher);
expect(enclosedRequest.getRequest()).andReturn(servletRequest);
expect(enclosedRequest.getResponse()).andReturn(response);
expect(enclosedRequest.getAvailableScopes()).andReturn(Collections.singletonList("parent"));
replay(velocityContext, enclosedRequest);
context = new VelocityRequest(enclosedRequest, velocityContext, writer);
context.doInclude(path);
verify(velocityContext, enclosedRequest, servletRequest, response, dispatcher);