@Test
public void testRender() throws IOException {

    Request request = createMock(Request.class);
    StringWriter writer = new StringWriter();
    ApplicationContext applicationContext = createMock(ApplicationContext.class);
    ApplicationResource applicationResource = createMock(ApplicationResource.class);
    Map<String,Object> context = Collections.singletonMap("testKey", (Object)"test value");
    expect(applicationContext.getResource(isA(String.class))).andReturn(applicationResource).anyTimes();
    expect(request.getAvailableScopes()).andReturn(Arrays.asList(Request.REQUEST_SCOPE, "session", Request.APPLICATION_SCOPE));
    expect(request.getContext(Request.REQUEST_SCOPE)).andReturn(context);
    expect(request.getContext("session")).andReturn(Collections.<String,Object>emptyMap());
    expect(request.getContext(Request.APPLICATION_SCOPE)).andReturn(Collections.<String,Object>emptyMap());
    expect(request.getWriter()).andReturn(writer).anyTimes();
    replay(request, applicationContext, applicationResource);
    Renderer renderer = new MustacheRenderer(new DefaultMustacheFactory() {
            @Override
            public Reader getReader(String path) {
                return new InputStreamReader(getClass().getResourceAsStream(path), Charset.forName("utf-8"));
            }
        });
    renderer.render("/test.html", request);
    verify(request, applicationContext, applicationResource);
    assertEquals("test template with test value", writer.toString());
}