use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class AnsiOutputApplicationListenerTests method disabled.
@Test
public void disabled() throws Exception {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
Map<String, Object> props = new HashMap<>();
props.put("spring.output.ansi.enabled", "never");
application.setDefaultProperties(props);
this.context = application.run();
assertThat(AnsiOutputEnabledValue.get()).isEqualTo(Enabled.NEVER);
}
use of org.springframework.boot.SpringApplication 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();
}
use of org.springframework.boot.SpringApplication 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.boot.SpringApplication in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method profileSubDocumentInDifferentProfileSpecificFile.
@Test
public void profileSubDocumentInDifferentProfileSpecificFile() throws Exception {
// gh-4132
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run("--spring.profiles.active=activeprofilewithdifferentsubdoc,activeprofilewithdifferentsubdoc2");
String property = this.context.getEnvironment().getProperty("foobar");
assertThat(property).isEqualTo("baz");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method additionalProfilesCanBeIncludedFromAnyPropertySource.
@Test
public void additionalProfilesCanBeIncludedFromAnyPropertySource() throws Exception {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run("--spring.profiles.active=myprofile", "--spring.profiles.include=dev");
String property = this.context.getEnvironment().getProperty("my.property");
assertThat(property).isEqualTo("fromdevpropertiesfile");
assertThat(this.context.getEnvironment().containsProperty("customdefault")).isFalse();
}
Aggregations