use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class SpringApplicationAdminMXBeanRegistrarTests method validateReadyFlag.
@Test
public void validateReadyFlag() {
final ObjectName objectName = createObjectName(OBJECT_NAME);
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
try {
assertThat(isApplicationReady(objectName)).isFalse();
} catch (Exception ex) {
throw new IllegalStateException("Could not contact spring application admin bean", ex);
}
}
});
this.context = application.run();
assertThat(isApplicationReady(objectName)).isTrue();
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class SpringApplicationAdminMXBeanRegistrarTests method shutdownApp.
@Test
public void shutdownApp() throws InstanceNotFoundException {
final ObjectName objectName = createObjectName(OBJECT_NAME);
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run();
assertThat(this.context.isRunning()).isTrue();
invokeShutdown(objectName);
assertThat(this.context.isRunning()).isFalse();
// JMX cleanup
this.thrown.expect(InstanceNotFoundException.class);
this.mBeanServer.getObjectInstance(objectName);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class AutoConfigurationReproTests method doesNotEarlyInitializeFactoryBeans.
@Test
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
SpringApplication application = new SpringApplication(EarlyInitConfig.class, PropertySourcesPlaceholderConfigurer.class, ServletWebServerFactoryAutoConfiguration.class);
this.context = application.run("--server.port=0");
String bean = (String) this.context.getBean("earlyInit");
assertThat(bean).isEqualTo("bucket");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class BasicErrorControllerDirectMockMvcTests method errorPageAvailableWithMvcIncluded.
@Test
public void errorPageAvailableWithMvcIncluded() throws Exception {
setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.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");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class BasicErrorControllerDirectMockMvcTests method errorPageNotAvailableWithWhitelabelDisabled.
@Test
public void errorPageNotAvailableWithWhitelabelDisabled() throws Exception {
setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class).run("--server.port=0", "--server.error.whitelabel.enabled=false"));
this.thrown.expect(ServletException.class);
this.mockMvc.perform(get("/error").accept(MediaType.TEXT_HTML));
}
Aggregations