StringRenderer implements Renderer { @Override public void render(String value, Request request) throws IOException { if (value == null) { throw new CannotRenderException("Cannot render a null string"); } request.getWriter().write(value); }  @Override void render(String value, Request request); boolean isRenderable(String value, Request request);  }
@Test public void testWrite() throws IOException { StringWriter writer = new StringWriter(); Request requestContext = createMock(Request.class); expect(requestContext.getWriter()).andReturn(writer); replay(requestContext); renderer.render("Result", requestContext); writer.close(); assertEquals("Not written 'Result'", "Result", writer.toString()); verify(requestContext); }