Skip to content

Commit

Permalink
Support Java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Creech committed Aug 10, 2022
1 parent c9f133c commit 61a6fc5
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.gson.JsonParser;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.logging.ErrorManager;
import java.util.logging.Filter;
import java.util.logging.Formatter;
Expand Down Expand Up @@ -399,15 +400,16 @@ public void testEnhancedLogEntry() {
handler.publish(newLogRecord(Level.FINEST, MESSAGE));
}

void validateJsonOutput(ByteArrayOutputStream bout) {
void validateJsonOutput(ByteArrayOutputStream bout) throws UnsupportedEncodingException {
final String expectedOutput =
"{\"severity\":\"INFO\",\"time\":\"1970-01-02T10:17:36.789Z\",\"logging.googleapis.com/labels\":{\"enhanced\":\"true\"},\"logging.googleapis.com/trace_sampled\":false,\"message\":\"message\"}";
assertEquals(
JsonParser.parseString(expectedOutput), JsonParser.parseString(bout.toString(UTF_8)));
JsonParser.parseString(expectedOutput),
JsonParser.parseString(bout.toString(UTF_8.name())));
}

@Test
public void testEnhancedLogEntryPrintToStdout() {
public void testEnhancedLogEntryPrintToStdout() throws UnsupportedEncodingException {
outputStreamPatcher.patch();

replay(options, logging);
Expand All @@ -424,7 +426,7 @@ public void testEnhancedLogEntryPrintToStdout() {
}

@Test
public void testEnhancedLogEntryPrintToStderr() {
public void testEnhancedLogEntryPrintToStderr() throws UnsupportedEncodingException {
outputStreamPatcher.patch();

replay(options, logging);
Expand Down

0 comments on commit 61a6fc5

Please sign in to comment.