@Test public void staticApplicationContext() { StaticApplicationContext ctx = new StaticApplicationContext(); assertHasStandardEnvironment(ctx); registerEnvironmentBeanDefinition(ctx); ctx.setEnvironment(prodEnv); ctx.refresh(); assertHasEnvironment(ctx, prodEnv); assertEnvironmentBeanRegistered(ctx); assertEnvironmentAwareInvoked(ctx, prodEnv); }
private void maybeSetBeanFactory(ConfigurableApplicationContext context, ConfigurationPropertiesBindingPostProcessor post) { StaticApplicationContext other = new StaticApplicationContext(); other.setEnvironment(context.getEnvironment()); other.registerSingleton(ConfigurationBeanFactoryMetadata.class.getName(), ConfigurationBeanFactoryMetadata.class); other.setParent(context); post.setApplicationContext(other); }