Example usage for org.springframework.context.support GenericXmlApplicationContext setEnvironment

List of usage examples for org.springframework.context.support GenericXmlApplicationContext setEnvironment

Introduction

In this page you can find the example usage for org.springframework.context.support GenericXmlApplicationContext setEnvironment.

Prototype

@Override
public void setEnvironment(ConfigurableEnvironment environment) 

Source Link

Document

Delegates the given environment to underlying XmlBeanDefinitionReader .

Usage

From source file:org.cloudfoundry.identity.uaa.test.ParentContextLoader.java

@Override
protected void customizeContext(GenericApplicationContext context) {
    GenericXmlApplicationContext parent = new GenericXmlApplicationContext();
    parent.setEnvironment(TestProfileEnvironment.getEnvironment());
    parent.load(parentLocation);//from w  w w .  ja  v a2 s  .co m
    parent.refresh();
    super.customizeContext(context);
    context.setParent(parent);
}

From source file:it.tidalwave.northernwind.util.test.TestHelper.java

/*******************************************************************************************************************
 *
 ******************************************************************************************************************/
@Nonnull//from  w w  w  .ja  va 2s.  c  o  m
private ApplicationContext createSpringContext(final @Nonnull Map<String, Object> properties,
        final @Nonnull Collection<String> configurationFiles) {
    configurationFiles.add(test.getClass().getSimpleName() + "/TestBeans.xml");

    if (properties.isEmpty()) {
        return new ClassPathXmlApplicationContext(configurationFiles.toArray(new String[0]));
    } else {
        final StandardEnvironment environment = new StandardEnvironment();
        environment.getPropertySources().addFirst(new MapPropertySource("test", properties));
        final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
        context.setEnvironment(environment);
        context.load(configurationFiles.toArray(new String[0]));
        context.refresh();
        return context;
    }
}