@@ -168,13 +168,13 @@ void overrideConfigLocation() {
168
168
}
169
169
170
170
@ Test
171
- @ ClassPathExclusions ("janino-*.jar" )
172
- void tryingToUseJaninoWhenItIsNotOnTheClasspathFailsGracefully (CapturedOutput output ) {
173
- addPropertiesToEnvironment (this .context , "logging.config=classpath:logback-janino.xml" );
171
+ void throwableFromInitializeResultsInGracefulFailure (CapturedOutput output ) {
172
+ System .setProperty (LoggingSystem .SYSTEM_PROPERTY , BrokenInitializationLoggingSystem .class .getName ());
173
+ multicastEvent (this .listener ,
174
+ new ApplicationStartingEvent (this .bootstrapContext , new SpringApplication (), NO_ARGS ));
174
175
assertThatIllegalStateException ()
175
176
.isThrownBy (() -> this .listener .initialize (this .context .getEnvironment (), this .context .getClassLoader ()));
176
- assertThat (output )
177
- .contains ("Logging system failed to initialize using configuration from 'classpath:logback-janino.xml'" );
177
+ assertThat (output ).contains ("Deliberately broken" );
178
178
}
179
179
180
180
@ Test
@@ -712,6 +712,38 @@ public void cleanUp() {
712
712
713
713
}
714
714
715
+ static final class BrokenInitializationLoggingSystem extends LoggingSystem {
716
+
717
+ BrokenInitializationLoggingSystem (ClassLoader classLoader ) {
718
+
719
+ }
720
+
721
+ @ Override
722
+ public void beforeInitialize () {
723
+ }
724
+
725
+ @ Override
726
+ public void initialize (LoggingInitializationContext initializationContext , String configLocation ,
727
+ LogFile logFile ) {
728
+ throw new Error ("Deliberately broken" );
729
+ }
730
+
731
+ @ Override
732
+ public void setLogLevel (String loggerName , LogLevel level ) {
733
+ }
734
+
735
+ @ Override
736
+ public List <LoggerConfiguration > getLoggerConfigurations () {
737
+ return null ;
738
+ }
739
+
740
+ @ Override
741
+ public LoggerConfiguration getLoggerConfiguration (String loggerName ) {
742
+ return null ;
743
+ }
744
+
745
+ }
746
+
715
747
@ Configuration
716
748
@ Import (WebServerStyleLifecycle .class )
717
749
static class TestConfiguration {
0 commit comments