use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class DelegatingApplicationListenerTests method orderedInitialize.
@Test
void orderedInitialize() {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "context.listener.classes=" + MockInitB.class.getName() + "," + MockInitA.class.getName());
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new DefaultBootstrapContext(), new SpringApplication(), new String[0], this.context.getEnvironment()));
this.context.getBeanFactory().registerSingleton("testListener", this.listener);
this.context.refresh();
assertThat(this.context.getBeanFactory().getSingleton("a")).isEqualTo("a");
assertThat(this.context.getBeanFactory().getSingleton("b")).isEqualTo("b");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class LocalDevToolsAutoConfigurationTests method initializeAndRun.
private ConfigurableApplicationContext initializeAndRun(Class<?> config, Map<String, Object> properties, String... args) {
Restarter.initialize(new String[0], false, new MockRestartInitializer(), false);
SpringApplication application = new SpringApplication(config);
application.setDefaultProperties(getDefaultProperties(properties));
return application.run(args);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class DevToolPropertiesIntegrationTests method postProcessEnablesIncludeStackTraceProperty.
@Test
void postProcessEnablesIncludeStackTraceProperty() throws Exception {
SpringApplication application = new SpringApplication(TestConfiguration.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = getContext(application::run);
ConfigurableEnvironment environment = this.context.getEnvironment();
String includeStackTrace = environment.getProperty("server.error.include-stacktrace");
assertThat(includeStackTrace).isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString());
String includeMessage = environment.getProperty("server.error.include-message");
assertThat(includeMessage).isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString());
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class DevToolPropertiesIntegrationTests method beanMethodPropertyConditionIsAffectedByDevToolProperties.
@Test
void beanMethodPropertyConditionIsAffectedByDevToolProperties() throws Exception {
SpringApplication application = new SpringApplication(BeanConditionConfiguration.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = getContext(application::run);
this.context.getBean(MyBean.class);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ConfigurationPropertiesTests method loadWhenEnvironmentPrefixSetShouldBind.
@Test
@SuppressWarnings("unchecked")
void loadWhenEnvironmentPrefixSetShouldBind() {
MutablePropertySources sources = this.context.getEnvironment().getPropertySources();
sources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, new SystemEnvironmentPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, Collections.singletonMap("MY_SPRING_FOO_NAME", "Jane")));
SpringApplication application = new SpringApplication(PrefixConfiguration.class);
application.setApplicationContextFactory((webApplicationType) -> ConfigurationPropertiesTests.this.context);
application.setEnvironmentPrefix("my");
application.setEnvironment(this.context.getEnvironment());
application.run();
BasicProperties bean = this.context.getBean(BasicProperties.class);
assertThat(bean.name).isEqualTo("Jane");
}
Aggregations