use of org.apache.logging.log4j.core.time.internal.DummyNanoClock in project logging-log4j2 by apache.
the class JsonLayoutTest method testLayoutRingBufferEventReusableMessageWithCurlyBraces.
// Test for LOG4J2-2312 LOG4J2-2341
@Test
public void testLayoutRingBufferEventReusableMessageWithCurlyBraces() throws Exception {
final boolean propertiesAsList = false;
final AbstractJacksonLayout layout = JsonLayout.newBuilder().setLocationInfo(false).setProperties(false).setPropertiesAsList(propertiesAsList).setComplete(false).setCompact(true).setEventEol(false).setCharset(StandardCharsets.UTF_8).setIncludeStacktrace(true).build();
Message message = ReusableMessageFactory.INSTANCE.newMessage("Testing {}", new TestObj());
try {
RingBufferLogEvent ringBufferEvent = new RingBufferLogEvent();
ringBufferEvent.setValues(null, "a.B", null, "f.q.c.n", Level.DEBUG, message, null, new SortedArrayStringMap(), ThreadContext.EMPTY_STACK, 1L, "threadName", 1, null, new SystemClock(), new DummyNanoClock());
final String str = layout.toSerializable(ringBufferEvent);
final String expectedMessage = "Testing " + TestObj.TO_STRING_VALUE;
assertThat(str, containsString("\"message\":\"" + expectedMessage + '"'));
final Log4jLogEvent actual = new Log4jJsonObjectMapper(propertiesAsList, true, false, false).readValue(str, Log4jLogEvent.class);
assertEquals(expectedMessage, actual.getMessage().getFormattedMessage());
} finally {
ReusableMessageFactory.release(message);
}
}
Aggregations