@Test public void createPidFile() throws Exception { File file = this.temporaryFolder.newFile(); ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file); listener.onApplicationEvent(EVENT); assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString())); }
@Test public void overridePidFile() throws Exception { File file = this.temporaryFolder.newFile(); System.setProperty("PIDFILE", this.temporaryFolder.newFile().getAbsolutePath()); ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file); listener.onApplicationEvent(EVENT); assertThat( FileCopyUtils.copyToString(new FileReader(System.getProperty("PIDFILE"))), not(isEmptyString())); }
@Before @After public void resetListener() { System.clearProperty("PIDFILE"); ApplicationPidFileWriter.reset(); }