More defensive testing of tmpdir
This commit is contained in:
parent
0439b39381
commit
207d4853ed
|
|
@ -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 {
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue