@Test(expected = FreemarkerRequestException.class)
public void testGetValueException() throws TemplateModelException {

    Template template = createMock(Template.class);
    TemplateHashModel model = createMock(TemplateHashModel.class);
    TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
    Configuration configuration = createMock(Configuration.class);
    ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
    Writer writer = new StringWriter();
    expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
    expect(model.get("key")).andThrow(new TemplateModelException());
    replay(template, model, valueModel, configuration, objectWrapper);
    try {
        Environment env = new Environment(template, model, writer);
        EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
        extractor.getValue("key");
    } finally {
        verify(template, model, valueModel, configuration, objectWrapper);
    }
}