ConfigurableEnvironment environment = new StandardEnvironment();
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("spring.pidfile", file.getAbsolutePath());
environment.getPropertySources().addLast(propertySource);
ApplicationEnvironmentPreparedEvent event = new ApplicationEnvironmentPreparedEvent(
new SpringApplication(), new String[] {}, environment);
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file)), isEmptyString());
listener.setTriggerEventType(ApplicationEnvironmentPreparedEvent.class);
listener.onApplicationEvent(event);