use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method propertySourceAnnotationWithPlaceholder.
@Test
public void propertySourceAnnotationWithPlaceholder() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, "source.location=specificlocation");
SpringApplication application = new SpringApplication(WithPropertySourcePlaceholders.class);
application.setEnvironment(this.environment);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
assertThat(property).isEqualTo("fromspecificlocation");
assertThat(context.getEnvironment()).has(matchingPropertySource("class path resource " + "[specificlocation.properties]"));
context.close();
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method propertySourceAnnotation.
@Test
public void propertySourceAnnotation() throws Exception {
SpringApplication application = new SpringApplication(WithPropertySource.class);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
assertThat(property).isEqualTo("fromspecificlocation");
property = context.getEnvironment().getProperty("my.property");
assertThat(property).isEqualTo("fromapplicationproperties");
assertThat(context.getEnvironment()).has(matchingPropertySource("class path resource " + "[specificlocation.properties]"));
context.close();
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method propertySourceAnnotationMultipleLocationsAndName.
@Test
public void propertySourceAnnotationMultipleLocationsAndName() throws Exception {
SpringApplication application = new SpringApplication(WithPropertySourceMultipleLocationsAndName.class);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
assertThat(property).isEqualTo("frommorepropertiesfile");
assertThat(context.getEnvironment()).has(matchingPropertySource("foo"));
context.close();
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class LoggingApplicationListenerIntegrationTests method loggingSystemRegisteredInTheContext.
@Test
public void loggingSystemRegisteredInTheContext() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class).web(WebApplicationType.NONE).run();
try {
SampleService service = context.getBean(SampleService.class);
assertThat(service.loggingSystem).isNotNull();
} finally {
context.close();
}
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class EnableCachingTests method bothSetOnlyResolverIsUsed.
@Test
public void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator());
context.close();
}
Aggregations