Search in sources :

Example 41 with SpringApplication

use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.

the class RestartApplicationListenerTests method testInitialize.

private void testInitialize(boolean failed) {
    Restarter.clearInstance();
    RestartApplicationListener listener = new RestartApplicationListener();
    SpringApplication application = new SpringApplication();
    ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
    listener.onApplicationEvent(new ApplicationStartingEvent(application, ARGS));
    assertThat(Restarter.getInstance()).isNotEqualTo(nullValue());
    assertThat(Restarter.getInstance().isFinished()).isFalse();
    listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
    if (failed) {
        listener.onApplicationEvent(new ApplicationFailedEvent(application, ARGS, context, new RuntimeException()));
    } else {
        listener.onApplicationEvent(new ApplicationReadyEvent(application, ARGS, context));
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ApplicationFailedEvent(org.springframework.boot.context.event.ApplicationFailedEvent) SpringApplication(org.springframework.boot.SpringApplication) ApplicationReadyEvent(org.springframework.boot.context.event.ApplicationReadyEvent) ApplicationPreparedEvent(org.springframework.boot.context.event.ApplicationPreparedEvent) ApplicationStartingEvent(org.springframework.boot.context.event.ApplicationStartingEvent)

Example 42 with SpringApplication

use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.

the class RestartScopeInitializerTests method runApplication.

private ConfigurableApplicationContext runApplication() {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    return application.run();
}
Also used : SpringApplication(org.springframework.boot.SpringApplication)

Example 43 with SpringApplication

use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.

the class DevToolPropertiesIntegrationTests method postProcessWhenRestarterDisabledAndRemoteSecretNotSetShouldNotAddPropertySource.

@Test
public void postProcessWhenRestarterDisabledAndRemoteSecretNotSetShouldNotAddPropertySource() throws Exception {
    Restarter.clearInstance();
    Restarter.disable();
    SpringApplication application = new SpringApplication(BeanConditionConfiguration.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    this.context = application.run();
    this.thrown.expect(NoSuchBeanDefinitionException.class);
    this.context.getBean(MyBean.class);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Example 44 with SpringApplication

use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.

the class DevToolPropertiesIntegrationTests method classPropertyConditionIsAffectedByDevToolProperties.

@Test
public void classPropertyConditionIsAffectedByDevToolProperties() {
    SpringApplication application = new SpringApplication(ClassConditionConfiguration.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    this.context = application.run();
    this.context.getBean(ClassConditionConfiguration.class);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Example 45 with SpringApplication

use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.

the class DevToolPropertiesIntegrationTests method postProcessWhenRestarterDisabledAndRemoteSecretSetShouldAddPropertySource.

@Test
public void postProcessWhenRestarterDisabledAndRemoteSecretSetShouldAddPropertySource() throws Exception {
    Restarter.clearInstance();
    Restarter.disable();
    SpringApplication application = new SpringApplication(BeanConditionConfiguration.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    application.setDefaultProperties(Collections.<String, Object>singletonMap("spring.devtools.remote.secret", "donttell"));
    this.context = application.run();
    this.context.getBean(MyBean.class);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Aggregations

SpringApplication (org.springframework.boot.SpringApplication)64 Test (org.junit.Test)45 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)14 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)7 HashMap (java.util.HashMap)6 ApplicationStartingEvent (org.springframework.boot.context.event.ApplicationStartingEvent)5 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)4 ApplicationFailedEvent (org.springframework.boot.context.event.ApplicationFailedEvent)4 JoranException (ch.qos.logback.core.joran.spi.JoranException)3 ObjectName (javax.management.ObjectName)3 ApplicationPreparedEvent (org.springframework.boot.context.event.ApplicationPreparedEvent)3 ApplicationReadyEvent (org.springframework.boot.context.event.ApplicationReadyEvent)3 JavaLoggingSystem (org.springframework.boot.logging.java.JavaLoggingSystem)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 StandardEnvironment (org.springframework.core.env.StandardEnvironment)3 File (java.io.File)2 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)2 ApplicationEnvironmentPreparedEvent (org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent)2 AbstractLoggingSystem (org.springframework.boot.logging.AbstractLoggingSystem)2 LoggingSystem (org.springframework.boot.logging.LoggingSystem)2