DispatchRenderer implements Renderer { @Override public void render(String path, Request request) throws IOException { if (path == null) { throw new CannotRenderException("Cannot dispatch a null path"); } DispatchRequest dispatchRequest = getDispatchRequest(request); if (dispatchRequest == null) { throw new CannotRenderException("Cannot dispatch outside of a web environment"); } dispatchRequest.dispatch(path); }  @Override void render(String path, Request request); boolean isRenderable(String path, Request request);  }
@Test public void testWrite() throws IOException { DispatchRequest requestContext = createMock(DispatchRequest.class); requestContext.dispatch("/myTemplate.jsp"); replay(requestContext); renderer.render("/myTemplate.jsp", requestContext); verify(requestContext); }
@Test(expected = CannotRenderException.class) public void testWriteNull() throws IOException { DispatchRequest requestContext = createMock(DispatchRequest.class); replay(requestContext); renderer.render(null, requestContext); verify(requestContext); }