@Test
public void testSetValue() throws TemplateModelException {

    Template template = createMock(Template.class);
    TemplateHashModel model = createMock(TemplateHashModel.class);
    TemplateModel valueModel = createMock(TemplateModel.class);
    Configuration configuration = createMock(Configuration.class);
    ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
    Writer writer = new StringWriter();
    expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
    expect(template.getObjectWrapper()).andReturn(objectWrapper);
    expect(objectWrapper.wrap("value")).andReturn(valueModel);
    replay(template, model, valueModel, configuration, objectWrapper);
    Environment env = new Environment(template, model, writer);
    EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
    extractor.setValue("key", "value");
    assertEquals(valueModel, env.getVariable("key"));
    verify(template, model, valueModel, configuration, objectWrapper);
}