use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method init.
@BeforeEach
void init(CapturedOutput output) throws IOException {
this.systemPropertyNames = new HashSet<>(System.getProperties().keySet());
this.output = output;
this.logFile = new File(this.tempDir.toFile(), "foo.log");
LogManager.getLogManager().readConfiguration(JavaLoggingSystem.class.getResourceAsStream("logging.properties"));
multicastEvent(new ApplicationStartingEvent(this.bootstrapContext, new SpringApplication(), NO_ARGS));
new File(this.tempDir.toFile(), "spring.log").delete();
ConfigurableEnvironment environment = this.context.getEnvironment();
ConfigurationPropertySources.attach(environment);
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class StartupTimeMetricsListenerTests method metricRecordedWithoutMainAppClassTag.
@Test
void metricRecordedWithoutMainAppClassTag() {
SpringApplication application = mock(SpringApplication.class);
this.listener.onApplicationEvent(new ApplicationStartedEvent(application, null, null, Duration.ofSeconds(2)));
TimeGauge applicationStartedGague = this.registry.find("application.started.time").timeGauge();
assertThat(applicationStartedGague).isNotNull();
assertThat(applicationStartedGague.getId().getTags()).isEmpty();
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ConditionEvaluationReportLoggingListenerTests method noErrorIfNotInitialized.
@Test
void noErrorIfNotInitialized(CapturedOutput output) {
this.initializer.onApplicationEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], null, new RuntimeException("Planned")));
assertThat(output).contains("Unable to provide the conditions report");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class ConditionEvaluationReportLoggingListenerTests method logsDebugOnError.
@Test
void logsDebugOnError(CapturedOutput output) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.initializer.initialize(context);
context.register(ErrorConfig.class);
assertThatExceptionOfType(Exception.class).isThrownBy(context::refresh).satisfies((ex) -> withDebugLogging(() -> this.initializer.onApplicationEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex))));
assertThat(output).contains("CONDITIONS EVALUATION REPORT");
}
use of org.springframework.boot.SpringApplication in project spring-boot by spring-projects.
the class RemoteUrlPropertyExtractorTests method doTest.
private ApplicationContext doTest(String... args) {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.addListeners(new RemoteUrlPropertyExtractor());
return application.run(args);
}
Aggregations