use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method createReadyEvent.
private SpringApplicationEvent createReadyEvent(String propName, String propValue) {
ConfigurableEnvironment environment = createEnvironment(propName, propValue);
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
given(context.getEnvironment()).willReturn(environment);
return new ApplicationReadyEvent(new SpringApplication(), new String[] {}, context);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class LiquibaseServiceLocatorApplicationListenerTests method replacesServiceLocator.
@Test
public void replacesServiceLocator() throws Exception {
SpringApplication application = new SpringApplication(Conf.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run();
ServiceLocator instance = ServiceLocator.getInstance();
Field field = ReflectionUtils.findField(ServiceLocator.class, "classResolver");
field.setAccessible(true);
Object resolver = field.get(instance);
assertThat(resolver).isInstanceOf(SpringPackageScanClassResolver.class);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method createPreparedEvent.
private SpringApplicationEvent createPreparedEvent(String propName, String propValue) {
ConfigurableEnvironment environment = createEnvironment(propName, propValue);
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
given(context.getEnvironment()).willReturn(environment);
return new ApplicationPreparedEvent(new SpringApplication(), new String[] {}, context);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class AutoConfigurationReportLoggingInitializerTests method logsInfoOnErrorIfDebugDisabled.
@Test
public void logsInfoOnErrorIfDebugDisabled() {
setupLogging(false, true);
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()).isEqualTo(0);
assertThat(this.infoLog.size()).isNotEqualTo(0);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class BasicErrorControllerDirectMockMvcTests method errorControllerWithAop.
@Test
public void errorControllerWithAop() throws Exception {
setup((ConfigurableWebApplicationContext) new SpringApplication(WithAopConfiguration.class).run("--server.port=0"));
MvcResult response = this.mockMvc.perform(get("/error").accept(MediaType.TEXT_HTML)).andExpect(status().is5xxServerError()).andReturn();
String content = response.getResponse().getContentAsString();
assertThat(content).contains("status=999");
}
Aggregations