use of org.springframework.boot.SpringApplication 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.boot.SpringApplication in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method profileSubDocumentInSameProfileSpecificFile.
@Test
public void profileSubDocumentInSameProfileSpecificFile() throws Exception {
// gh-340
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run("--spring.profiles.active=activeprofilewithsubdoc");
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 DelegatingApplicationListenerTests method orderedInitialize.
@Test
public void orderedInitialize() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "context.listener.classes=" + MockInitB.class.getName() + "," + MockInitA.class.getName());
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(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 jphp by jphp-compiler.
the class PWebServer method __construct.
@Signature
public void __construct(Invoker invoker) {
application = new SpringApplication(WebServerConfig.class);
defaultProperties = new HashMap<>();
defaultProperties.put("_server.id", id);
defaultProperties.put("server.port", 8080);
application.setDefaultProperties(defaultProperties);
onRequest = invoker;
importAutoloaders = true;
isolated = true;
hotReload = true;
WebServerController.registerServer(this);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class AutoConfigurationReportLoggingInitializerTests method logsDebugOnError.
@Test
public void logsDebugOnError() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.initializer.initialize(context);
context.register(ErrorConfig.class);
try {
context.refresh();
fail("Did not error");
} catch (Exception ex) {
this.initializer.onApplicationEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex));
}
assertThat(this.debugLog.size()).isNotEqualTo(0);
assertThat(this.infoLog.size()).isEqualTo(0);
}
Aggregations