commit
369542106f
|
@ -168,13 +168,13 @@ class LoggingApplicationListenerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@ClassPathExclusions("janino-*.jar")
|
||||
void tryingToUseJaninoWhenItIsNotOnTheClasspathFailsGracefully(CapturedOutput output) {
|
||||
addPropertiesToEnvironment(this.context, "logging.config=classpath:logback-janino.xml");
|
||||
void throwableFromInitializeResultsInGracefulFailure(CapturedOutput output) {
|
||||
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, BrokenInitializationLoggingSystem.class.getName());
|
||||
multicastEvent(this.listener,
|
||||
new ApplicationStartingEvent(this.bootstrapContext, new SpringApplication(), NO_ARGS));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> this.listener.initialize(this.context.getEnvironment(), this.context.getClassLoader()));
|
||||
assertThat(output)
|
||||
.contains("Logging system failed to initialize using configuration from 'classpath:logback-janino.xml'");
|
||||
assertThat(output).contains("Deliberately broken");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -712,6 +712,38 @@ class LoggingApplicationListenerTests {
|
|||
|
||||
}
|
||||
|
||||
static final class BrokenInitializationLoggingSystem extends LoggingSystem {
|
||||
|
||||
BrokenInitializationLoggingSystem(ClassLoader classLoader) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeInitialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(LoggingInitializationContext initializationContext, String configLocation,
|
||||
LogFile logFile) {
|
||||
throw new Error("Deliberately broken");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogLevel(String loggerName, LogLevel level) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoggerConfiguration> getLoggerConfigurations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggerConfiguration getLoggerConfiguration(String loggerName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(WebServerStyleLifecycle.class)
|
||||
static class TestConfiguration {
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%property{LOG_FILE} [%t] ${PID:-????} %c{1}: %m%n BOOTBOOT</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
|
||||
<evaluator>
|
||||
<expression>return level <= DEBUG;</expression>
|
||||
</evaluator>
|
||||
<OnMismatch>DENY</OnMismatch>
|
||||
<OnMatch>NEUTRAL</OnMatch>
|
||||
</filter>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</configuration>
|
Loading…
Reference in New Issue