@Test
public void testRemoveValue() throws TemplateModelException {

    Template template = createMock(Template.class);
    TemplateHashModel model = createMock(TemplateHashModel.class);
    TemplateModel valueModel = createMock(TemplateModel.class);
    Configuration configuration = createMock(Configuration.class);
    Writer writer = new StringWriter();
    expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
    expect(model.get("key")).andReturn(null);
    expect(template.getConfiguration()).andReturn(configuration);
    expect(configuration.getSharedVariable("key")).andReturn(null);
    replay(template, model, valueModel, configuration);
    Environment env = new Environment(template, model, writer);
    env.setVariable("key", valueModel);
    EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
    extractor.removeValue("key");
    assertNull(env.getVariable("key"));
    verify(template, model, valueModel, configuration);
}