Example usage for org.springframework.boot SpringApplication SpringApplication

List of usage examples for org.springframework.boot SpringApplication SpringApplication

Introduction

In this page you can find the example usage for org.springframework.boot SpringApplication SpringApplication.

Prototype

SpringApplication

Source Link

Usage

From source file:org.springframework.boot.logging.LoggingApplicationListenerTests.java

@Before
public void init() throws SecurityException, IOException {
    LogManager.getLogManager()//from w  ww.  j a  v a2s.c o  m
            .readConfiguration(JavaLoggingSystem.class.getResourceAsStream("logging.properties"));
    this.initializer.onApplicationEvent(new ApplicationStartedEvent(new SpringApplication(), NO_ARGS));
    new File("target/foo.log").delete();
    new File(tmpDir() + "/spring.log").delete();
}

From source file:org.springframework.boot.logging.LoggingApplicationListenerTests.java

@Test
public void shutdownHookIsNotRegisteredByDefault() throws Exception {
    TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
    System.setProperty(LoggingSystem.class.getName(), TestShutdownHandlerLoggingSystem.class.getName());
    listener.onApplicationEvent(new ApplicationStartedEvent(new SpringApplication(), NO_ARGS));
    listener.initialize(this.context.getEnvironment(), this.context.getClassLoader());
    assertThat(listener.shutdownHook, is(nullValue()));
}

From source file:org.springframework.boot.logging.LoggingApplicationListenerTests.java

@Test
public void shutdownHookCanBeRegistered() throws Exception {
    TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
    System.setProperty(LoggingSystem.class.getName(), TestShutdownHandlerLoggingSystem.class.getName());
    EnvironmentTestUtils.addEnvironment(this.context, "logging.register_shutdown_hook:true");
    listener.onApplicationEvent(new ApplicationStartedEvent(new SpringApplication(), NO_ARGS));
    listener.initialize(this.context.getEnvironment(), this.context.getClassLoader());
    assertThat(listener.shutdownHook, is(not(nullValue())));
    listener.shutdownHook.start();/*from www . j  a  va 2  s  .c  o  m*/
    assertThat(TestShutdownHandlerLoggingSystem.shutdownLatch.await(30, TimeUnit.SECONDS), is(true));
}