use of org.springframework.boot.SpringApplication in project logback-access-spring-boot-starter by akihyro.
the class AbstractMainConfigurationFileInvalidTest method logbackAccessConfigurationExceptionWhereMainConfigurationFileIsInvalid.
/**
* Tests a Logback-access configuration exception in the case where the main configuration file is invalid.
*/
@Test
public void logbackAccessConfigurationExceptionWhereMainConfigurationFileIsInvalid() {
Map<String, Object> properties = new HashMap<>();
properties.put("server.port", findAvailableTcpPort());
SpringApplication application = new SpringApplication(contextConfiguration);
application.setDefaultProperties(properties);
Throwable throwable = catchThrowable(application::run);
Optional<LogbackAccessConfigurationException> exc = findLogbackAccessConfigurationException(throwable);
assertThat(exc).hasValueSatisfying(value -> assertThat(value).hasMessageStartingWith("Could not configure Logback-access:").hasMessageContaining("config=[classpath:logback-access.xml]").hasCauseInstanceOf(JoranException.class));
}
use of org.springframework.boot.SpringApplication in project logback-access-spring-boot-starter by akihyro.
the class AbstractTestConfigurationFileInvalidTest method logbackAccessConfigurationExceptionWhereTestConfigurationFileIsInvalid.
/**
* Tests a Logback-access configuration exception in the case where the test configuration file is invalid.
*/
@Test
public void logbackAccessConfigurationExceptionWhereTestConfigurationFileIsInvalid() {
Map<String, Object> properties = new HashMap<>();
properties.put("server.port", findAvailableTcpPort());
SpringApplication application = new SpringApplication(contextConfiguration);
application.setDefaultProperties(properties);
Throwable throwable = catchThrowable(application::run);
Optional<LogbackAccessConfigurationException> exc = findLogbackAccessConfigurationException(throwable);
assertThat(exc).hasValueSatisfying(value -> assertThat(value).hasMessageStartingWith("Could not configure Logback-access:").hasMessageContaining("config=[classpath:logback-access-test.xml]").hasCauseInstanceOf(JoranException.class));
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class AutoConfigurationReportLoggingInitializerTests method logsInfoOnErrorIfDebugDisabled.
@Test
public void logsInfoOnErrorIfDebugDisabled() {
setupLogging(false, true);
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.initializer.initialize(context);
context.register(ErrorConfig.class);
try {
context.refresh();
fail("Did not error");
} catch (Exception ex) {
this.initializer.onApplicationEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex));
}
assertThat(this.debugLog.size()).isEqualTo(0);
assertThat(this.infoLog.size()).isNotEqualTo(0);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method shutdownHookIsNotRegisteredByDefault.
@Test
public void shutdownHookIsNotRegisteredByDefault() throws Exception {
TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
System.setProperty(LoggingSystem.class.getName(), TestShutdownHandlerLoggingSystem.class.getName());
multicastEvent(listener, new ApplicationStartingEvent(new SpringApplication(), NO_ARGS));
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader());
assertThat(listener.shutdownHook).isNull();
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method shutdownHookCanBeRegistered.
@Test
public void shutdownHookCanBeRegistered() throws Exception {
TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
System.setProperty(LoggingSystem.class.getName(), TestShutdownHandlerLoggingSystem.class.getName());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.register_shutdown_hook=true");
multicastEvent(listener, new ApplicationStartingEvent(new SpringApplication(), NO_ARGS));
listener.initialize(this.context.getEnvironment(), this.context.getClassLoader());
assertThat(listener.shutdownHook).isNotNull();
listener.shutdownHook.start();
assertThat(TestShutdownHandlerLoggingSystem.shutdownLatch.await(30, TimeUnit.SECONDS)).isTrue();
}
Aggregations