use of org.springframework.boot.context.event.ApplicationStartingEvent in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method withNoEnvironment.
@Test
public void withNoEnvironment() throws Exception {
File file = this.temporaryFolder.newFile();
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.setTriggerEventType(ApplicationStartingEvent.class);
listener.onApplicationEvent(new ApplicationStartingEvent(new SpringApplication(), new String[] {}));
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isNotEmpty();
}
use of org.springframework.boot.context.event.ApplicationStartingEvent in project spring-boot by spring-projects.
the class RestartApplicationListenerTests method testInitialize.
private void testInitialize(boolean failed) {
Restarter.clearInstance();
RestartApplicationListener listener = new RestartApplicationListener();
SpringApplication application = new SpringApplication();
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
listener.onApplicationEvent(new ApplicationStartingEvent(application, ARGS));
assertThat(Restarter.getInstance()).isNotEqualTo(nullValue());
assertThat(Restarter.getInstance().isFinished()).isFalse();
listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
if (failed) {
listener.onApplicationEvent(new ApplicationFailedEvent(application, ARGS, context, new RuntimeException()));
} else {
listener.onApplicationEvent(new ApplicationReadyEvent(application, ARGS, context));
}
}
use of org.springframework.boot.context.event.ApplicationStartingEvent in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method parseArgsDoesntReplace.
@Test
public void parseArgsDoesntReplace() throws Exception {
this.initializer.setSpringBootLogging(LogLevel.ERROR);
this.initializer.setParseArgs(false);
multicastEvent(new ApplicationStartingEvent(this.springApplication, new String[] { "--debug" }));
this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader());
this.logger.debug("testatdebug");
assertThat(this.outputCapture.toString()).doesNotContain("testatdebug");
}
use of org.springframework.boot.context.event.ApplicationStartingEvent in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method init.
@Before
public void init() throws SecurityException, IOException {
LogManager.getLogManager().readConfiguration(JavaLoggingSystem.class.getResourceAsStream("logging.properties"));
multicastEvent(new ApplicationStartingEvent(new SpringApplication(), NO_ARGS));
new File("target/foo.log").delete();
new File(tmpDir() + "/spring.log").delete();
}
use of org.springframework.boot.context.event.ApplicationStartingEvent in project spring-boot by spring-projects.
the class LoggingApplicationListenerTests method closingContextCleansUpLoggingSystem.
@Test
public void closingContextCleansUpLoggingSystem() {
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, TestCleanupLoggingSystem.class.getName());
multicastEvent(new ApplicationStartingEvent(this.springApplication, new String[0]));
TestCleanupLoggingSystem loggingSystem = (TestCleanupLoggingSystem) ReflectionTestUtils.getField(this.initializer, "loggingSystem");
assertThat(loggingSystem.cleanedUp).isFalse();
multicastEvent(new ContextClosedEvent(this.context));
assertThat(loggingSystem.cleanedUp).isTrue();
}
Aggregations