use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ContextIdApplicationContextInitializerTests method testNameAndPort.
@Test
public void testNameAndPort() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, "spring.application.name=foo", "PORT=8080");
this.initializer.initialize(context);
assertThat(context.getId()).isEqualTo("foo:8080");
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ContextIdApplicationContextInitializerTests method testNameAndProfiles.
@Test
public void testNameAndProfiles() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, "spring.application.name=foo", "spring.profiles.active=spam,bar", "spring.application.index=12");
this.initializer.initialize(context);
assertThat(context.getId()).isEqualTo("foo:spam,bar:12");
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ContextIdApplicationContextInitializerTests method testCloudFoundry.
@Test
public void testCloudFoundry() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, "spring.config.name=foo", "PORT=8080", "vcap.application.name=bar", "vcap.application.instance_index=2");
this.initializer.initialize(context);
assertThat(context.getId()).isEqualTo("bar:2");
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class BeanNotOfRequiredTypeFailureAnalyzerTests method createFailure.
private Exception createFailure(Class<?> configuration) {
ConfigurableApplicationContext context = null;
try {
context = new AnnotationConfigApplicationContext(configuration);
} catch (Exception ex) {
return ex;
} finally {
if (context != null) {
context.close();
}
}
fail("Expected failure did not occur");
return null;
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method propertySourceAnnotationMultipleLocations.
@Test
public void propertySourceAnnotationMultipleLocations() throws Exception {
SpringApplication application = new SpringApplication(WithPropertySourceMultipleLocations.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("class path resource " + "[specificlocation.properties]"));
context.close();
}
Aggregations