blob: 3b1be62dfb1ffb506560e8cfb5f49f0b5591d8aa (
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
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
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);
}
}
|