blob: 5bcf2b76fdfdf96b338e1725f05227e4a1405d7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.log;
import org.junit.Test;
import org.junit.After;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
* @since 5.1
*/
@SuppressWarnings("removal")
public class FileLogTargetTest {
@Test(expected = RuntimeException.class)
public void requireThatExceptionIsThrowIfFileNotFound() throws IOException {
File file = new File("mydir1");
file.delete();
assertTrue(file.mkdir());
new FileLogTarget(file).open();
}
@After
public void cleanup() { new File("mydir1").delete(); }
@Test
public void requireThatFileCanOpened() throws IOException {
FileLogTarget logTarget = new FileLogTarget(File.createTempFile("logfile", ".log"));
assertNotNull(logTarget.open());
}
@Test
public void requireThatFileIsReopened() throws IOException {
FileLogTarget logTarget = new FileLogTarget(File.createTempFile("logfile", ".log"));
OutputStream out1 = logTarget.open();
assertNotNull(out1);
OutputStream out2 = logTarget.open();
assertNotNull(out2);
assertNotEquals(out1, out2);
}
}
|