blob: ad779f6b7b438102b6b0806b71fef35e813bc5da (
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
|
package com.yahoo.container.handler;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import static org.junit.Assert.*;
public class LogReaderTest {
ByteArrayOutputStream outputStream;
@Before
public void setup() {
outputStream = new ByteArrayOutputStream();
}
@Test
public void testThatFilesAreWrittenCorrectlyToOutputStream() throws Exception{
String logDirectory = "src/test/resources/logfolder/";
LogReader logReader = new LogReader();
JSONObject json = logReader.readLogs(logDirectory, 21, Long.MAX_VALUE);
String expected = "{\"subfolder-log2.log\":\"VGhpcyBpcyBhbm90aGVyIGxvZyBmaWxl\",\"log1.log\":\"VGhpcyBpcyBvbmUgbG9nIGZpbGU=\"}";
String actual = json.toString();
assertEquals(expected, actual);
}
@Test
public void testThatLogsOutsideRangeAreExcluded() throws Exception {
String logDirectory = "src/test/resources/logfolder/";
LogReader logReader = new LogReader();
JSONObject json = logReader.readLogs(logDirectory, Long.MAX_VALUE, Long.MIN_VALUE);
String expected = "{}";
String actual = json.toString();
assertEquals(expected, actual);
}
}
|