Remove assumption in test about /tmp location

pull/452/head
Dave Syer 11 years ago
parent 8168e8a327
commit da7d543305

@ -72,7 +72,7 @@ public class LoggingApplicationListenerTests {
this.initializer.onApplicationEvent(new ApplicationStartedEvent( this.initializer.onApplicationEvent(new ApplicationStartedEvent(
new SpringApplication(), NO_ARGS)); new SpringApplication(), NO_ARGS));
new File("target/foo.log").delete(); new File("target/foo.log").delete();
new File("/tmp/spring.log").delete(); new File(tmpDir() + "/spring.log").delete();
} }
@After @After
@ -85,6 +85,10 @@ public class LoggingApplicationListenerTests {
} }
} }
private String tmpDir() {
return this.context.getEnvironment().resolvePlaceholders("${java.io.tmpdir}");
}
@Test @Test
public void baseConfigLocation() { public void baseConfigLocation() {
this.initializer.initialize(this.context.getEnvironment(), this.initializer.initialize(this.context.getEnvironment(),
@ -93,7 +97,7 @@ public class LoggingApplicationListenerTests {
String output = this.outputCapture.toString().trim(); String output = this.outputCapture.toString().trim();
assertTrue("Wrong output:\n" + output, output.contains("Hello world")); assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
assertFalse("Wrong output:\n" + output, output.contains("???")); assertFalse("Wrong output:\n" + output, output.contains("???"));
assertTrue(new File("/tmp/spring.log").exists()); assertTrue(new File(tmpDir() + "/spring.log").exists());
} }
@Test @Test
@ -106,7 +110,8 @@ public class LoggingApplicationListenerTests {
String output = this.outputCapture.toString().trim(); String output = this.outputCapture.toString().trim();
assertTrue("Wrong output:\n" + output, output.contains("Hello world")); assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
assertFalse("Wrong output:\n" + output, output.contains("???")); assertFalse("Wrong output:\n" + output, output.contains("???"));
assertTrue("Wrong output:\n" + output, output.startsWith("/tmp/spring.log")); assertTrue("Wrong output:\n" + output,
output.startsWith(tmpDir() + "/spring.log"));
} }
@Test @Test

Loading…
Cancel
Save