-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON layout shouldn't fail to render nullable strings (#232)
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
loki-logback-appender/src/test/java/com/github/loki4j/logback/json/JsonEventWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.loki4j.logback.json; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class JsonEventWriterTest { | ||
|
||
@Test | ||
public void testWriteMultipleFields() { | ||
var writer = new JsonEventWriter(10); | ||
writer.writeBeginObject(); | ||
writer.writeStringField("str", "abc"); | ||
writer.writeFieldSeparator(); | ||
writer.writeNumberField("num", 123); | ||
writer.writeEndObject(); | ||
|
||
assertEquals("{\"str\":\"abc\",\"num\":123}", writer.toString()); | ||
} | ||
|
||
@Test | ||
public void testWriteNullString() { | ||
var writer = new JsonEventWriter(10); | ||
writer.writeBeginObject(); | ||
writer.writeStringField("str", null); | ||
writer.writeEndObject(); | ||
|
||
assertEquals("{\"str\":null}", writer.toString()); | ||
} | ||
} |