|
3 | 3 | import httpserver.file.FileOperator; |
4 | 4 | import org.junit.Test; |
5 | 5 |
|
6 | | -import java.io.File; |
7 | 6 | import java.nio.file.Path; |
8 | 7 | import java.nio.file.Paths; |
9 | 8 | import java.nio.file.StandardOpenOption; |
|
14 | 13 | import static java.nio.file.Files.exists; |
15 | 14 | import static org.junit.Assert.*; |
16 | 15 |
|
17 | | -public class LoggerTest { |
| 16 | +public class FileLoggerTest { |
18 | 17 | @Test |
19 | 18 | public void createsLogFileOnConstructDoesntOverwrite() throws Exception { |
20 | 19 | Path logPath = Paths.get(tempDir().toString(), "logs"); |
21 | 20 |
|
22 | | - new Logger(logPath, new FileOperator()); |
| 21 | + new FileLogger(logPath, new FileOperator()); |
23 | 22 |
|
24 | 23 | assertTrue(exists(logPath)); |
25 | 24 |
|
26 | 25 | write(logPath, "fake log line\r\n".getBytes(), |
27 | 26 | StandardOpenOption.APPEND); |
28 | 27 |
|
29 | | - new Logger(logPath, new FileOperator()); |
| 28 | + new FileLogger(logPath, new FileOperator()); |
30 | 29 |
|
31 | 30 | assertEquals("fake log line\r\n", new String(readAllBytes(logPath))); |
32 | 31 | } |
33 | 32 |
|
34 | 33 | @Test |
35 | 34 | public void onLogCallsFileOperatorAppendWithPathAndPayload() throws Exception { |
36 | 35 | Path logPath = Paths.get(tempDir().toString(), "logs"); |
37 | | - Logger logger = new Logger(logPath, new FileOperator()); |
| 36 | + FileLogger fileLogger = new FileLogger(logPath, new FileOperator()); |
38 | 37 |
|
39 | | - logger.log("POST example"); |
40 | | - logger.log("HEAD example"); |
| 38 | + fileLogger.log("POST example"); |
| 39 | + fileLogger.log("HEAD example"); |
41 | 40 |
|
42 | 41 | assertEquals("POST example\r\nHEAD example\r\n", new String(readAllBytes(logPath))); |
43 | 42 | } |
|
0 commit comments