Commit 207d4853 authored by Dave Syer's avatar Dave Syer

More defensive testing of tmpdir

parent 0439b393
...@@ -51,7 +51,11 @@ public class LogbackLoggingSystemTests { ...@@ -51,7 +51,11 @@ public class LogbackLoggingSystemTests {
@Before @Before
public void setup() { public void setup() {
this.logger = new SLF4JLogFactory().getInstance(getClass().getName()); this.logger = new SLF4JLogFactory().getInstance(getClass().getName());
new File("/tmp/spring.log").delete(); new File(tmpDir() + "/spring.log").delete();
}
private String tmpDir() {
return System.getProperty("java.io.tmpdir");
} }
@After @After
...@@ -68,8 +72,9 @@ public class LogbackLoggingSystemTests { ...@@ -68,8 +72,9 @@ public class LogbackLoggingSystemTests {
this.logger.info("Hello world"); this.logger.info("Hello world");
String output = this.output.toString().trim(); String output = this.output.toString().trim();
assertTrue("Wrong output:\n" + output, output.contains("Hello world")); assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
assertTrue("Wrong output:\n" + output, output.contains("/tmp/spring.log")); assertTrue("Wrong output (not " + tmpDir() + " :\n" + output,
assertFalse(new File("/tmp/spring.log").exists()); output.contains(tmpDir() + "/tmp.log"));
assertFalse(new File(tmpDir() + "/tmp.log").exists());
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment