use of java.io.FileReader in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method overridePidFileWithSpring.
@Test
public void overridePidFileWithSpring() throws Exception {
File file = this.temporaryFolder.newFile();
SpringApplicationEvent event = createPreparedEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isNotEmpty();
}
use of java.io.FileReader 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 java.io.FileReader in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method tryEnvironmentPreparedEvent.
@Test
public void tryEnvironmentPreparedEvent() throws Exception {
File file = this.temporaryFolder.newFile();
SpringApplicationEvent event = createEnvironmentPreparedEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isEmpty();
listener.setTriggerEventType(ApplicationEnvironmentPreparedEvent.class);
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isNotEmpty();
}
use of java.io.FileReader in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method tryReadyEvent.
@Test
public void tryReadyEvent() throws Exception {
File file = this.temporaryFolder.newFile();
SpringApplicationEvent event = createReadyEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isEmpty();
listener.setTriggerEventType(ApplicationReadyEvent.class);
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file))).isNotEmpty();
}
use of java.io.FileReader in project spring-boot by spring-projects.
the class Log4J2LoggingSystemTests method exceptionsIncludeClassPackaging.
@Test
public void exceptionsIncludeClassPackaging() throws Exception {
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(null, null, getLogFile(null, tmpDir()));
Matcher<String> expectedOutput = containsString("[junit-");
this.output.expect(expectedOutput);
this.logger.warn("Expected exception", new RuntimeException("Expected"));
String fileContents = FileCopyUtils.copyToString(new FileReader(new File(tmpDir() + "/spring.log")));
assertThat(fileContents).is(Matched.by(expectedOutput));
}
Aggregations