diff options
author | Ola Aunrønning <ola.aunroe@gmail.com> | 2018-08-24 14:54:27 +0200 |
---|---|---|
committer | Ola Aunrønning <ola.aunroe@gmail.com> | 2018-09-10 13:07:15 +0200 |
commit | 44053e445e8f893514667325be40613830056e6e (patch) | |
tree | bd1f6be2b7ec2f419d2a9363de96fecb32988152 /container-core/src/test/java/com/yahoo/container/handler | |
parent | 79fbe75a324084d7e871e4aa7b82500e7ccd35b3 (diff) |
Add functionality for retrieving logs
Diffstat (limited to 'container-core/src/test/java/com/yahoo/container/handler')
-rw-r--r-- | container-core/src/test/java/com/yahoo/container/handler/LogReaderTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/handler/LogReaderTest.java b/container-core/src/test/java/com/yahoo/container/handler/LogReaderTest.java new file mode 100644 index 00000000000..ff6ea74a411 --- /dev/null +++ b/container-core/src/test/java/com/yahoo/container/handler/LogReaderTest.java @@ -0,0 +1,36 @@ +package com.yahoo.container.handler; + +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.writeToOutputStream(logDirectory, outputStream); + String expected = "{\"subfolder\":{\"log2.log\":\"VGhpcyBpcyBhbm90aGVyIGxvZyBmaWxl\"},\"log1.log\":\"VGhpcyBpcyBvbmUgbG9nIGZpbGU=\"}"; + String actual = new String(outputStream.toByteArray()); + assertEquals(expected, actual); + } + + @Test + public void testNothingISWrittenToOutputStreamWithEmptyLogFolder() throws Exception { + String logDirectory = "src/test/resources/emptylogfolder/"; + LogReader.writeToOutputStream(logDirectory, outputStream); + String expected = "{}"; + String actual = new String(outputStream.toByteArray()); + assertEquals(expected, actual); + } +}
\ No newline at end of file |