|
|
|
@ -39,7 +39,7 @@ import org.slf4j.bridge.SLF4JBridgeHandler; |
|
|
|
import org.springframework.boot.ApplicationPid; |
|
|
|
import org.springframework.boot.ApplicationPid; |
|
|
|
import org.springframework.boot.SpringApplication; |
|
|
|
import org.springframework.boot.SpringApplication; |
|
|
|
import org.springframework.boot.context.event.ApplicationFailedEvent; |
|
|
|
import org.springframework.boot.context.event.ApplicationFailedEvent; |
|
|
|
import org.springframework.boot.context.event.ApplicationStartedEvent; |
|
|
|
import org.springframework.boot.context.event.ApplicationStartingEvent; |
|
|
|
import org.springframework.boot.logging.java.JavaLoggingSystem; |
|
|
|
import org.springframework.boot.logging.java.JavaLoggingSystem; |
|
|
|
import org.springframework.boot.testutil.InternalOutputCapture; |
|
|
|
import org.springframework.boot.testutil.InternalOutputCapture; |
|
|
|
import org.springframework.context.event.ContextClosedEvent; |
|
|
|
import org.springframework.context.event.ContextClosedEvent; |
|
|
|
@ -86,7 +86,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
LogManager.getLogManager().readConfiguration( |
|
|
|
LogManager.getLogManager().readConfiguration( |
|
|
|
JavaLoggingSystem.class.getResourceAsStream("logging.properties")); |
|
|
|
JavaLoggingSystem.class.getResourceAsStream("logging.properties")); |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
new ApplicationStartingEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
new File("target/foo.log").delete(); |
|
|
|
new File("target/foo.log").delete(); |
|
|
|
new File(tmpDir() + "/spring.log").delete(); |
|
|
|
new File(tmpDir() + "/spring.log").delete(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -342,7 +342,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
public void parseArgsDoesntReplace() throws Exception { |
|
|
|
public void parseArgsDoesntReplace() throws Exception { |
|
|
|
this.initializer.setSpringBootLogging(LogLevel.ERROR); |
|
|
|
this.initializer.setSpringBootLogging(LogLevel.ERROR); |
|
|
|
this.initializer.setParseArgs(false); |
|
|
|
this.initializer.setParseArgs(false); |
|
|
|
this.initializer.onApplicationEvent(new ApplicationStartedEvent( |
|
|
|
this.initializer.onApplicationEvent(new ApplicationStartingEvent( |
|
|
|
this.springApplication, new String[] { "--debug" })); |
|
|
|
this.springApplication, new String[] { "--debug" })); |
|
|
|
this.initializer.initialize(this.context.getEnvironment(), |
|
|
|
this.initializer.initialize(this.context.getEnvironment(), |
|
|
|
this.context.getClassLoader()); |
|
|
|
this.context.getClassLoader()); |
|
|
|
@ -387,7 +387,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
System.setProperty(LoggingSystem.class.getName(), |
|
|
|
System.setProperty(LoggingSystem.class.getName(), |
|
|
|
TestShutdownHandlerLoggingSystem.class.getName()); |
|
|
|
TestShutdownHandlerLoggingSystem.class.getName()); |
|
|
|
listener.onApplicationEvent( |
|
|
|
listener.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
new ApplicationStartingEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()); |
|
|
|
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()); |
|
|
|
assertThat(listener.shutdownHook).isNull(); |
|
|
|
assertThat(listener.shutdownHook).isNull(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -400,7 +400,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, |
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, |
|
|
|
"logging.register_shutdown_hook=true"); |
|
|
|
"logging.register_shutdown_hook=true"); |
|
|
|
listener.onApplicationEvent( |
|
|
|
listener.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
new ApplicationStartingEvent(new SpringApplication(), NO_ARGS)); |
|
|
|
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()); |
|
|
|
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()); |
|
|
|
assertThat(listener.shutdownHook).isNotNull(); |
|
|
|
assertThat(listener.shutdownHook).isNotNull(); |
|
|
|
listener.shutdownHook.start(); |
|
|
|
listener.shutdownHook.start(); |
|
|
|
@ -413,7 +413,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(this.springApplication, new String[0])); |
|
|
|
new ApplicationStartingEvent(this.springApplication, new String[0])); |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
@ -426,7 +426,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(this.springApplication, new String[0])); |
|
|
|
new ApplicationStartingEvent(this.springApplication, new String[0])); |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
@ -472,7 +472,7 @@ public class LoggingApplicationListenerTests { |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
TestCleanupLoggingSystem.class.getName()); |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
this.initializer.onApplicationEvent( |
|
|
|
new ApplicationStartedEvent(this.springApplication, new String[0])); |
|
|
|
new ApplicationStartingEvent(this.springApplication, new String[0])); |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
.getField(this.initializer, "loggingSystem"); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
assertThat(loggingSystem.cleanedUp).isFalse(); |
|
|
|
|