use of org.apache.logging.log4j.jackson.Log4jStackTraceElementDeserializer in project logging-log4j2 by apache.
the class StackTraceElementYamlMixInTest method testFromYamlWithLog4jModule.
@Test
public void testFromYamlWithLog4jModule() throws Exception {
final ObjectMapper mapper = new YAMLMapper();
final boolean encodeThreadContextAsList = false;
final SimpleModule module = new Log4jYamlModule(encodeThreadContextAsList, true, false);
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final StackTraceElement actual = mapper.readValue("---\nclass: package.SomeClass\nmethod: someMethod\nfile: SomeClass.java\nline: 123\n...", StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
use of org.apache.logging.log4j.jackson.Log4jStackTraceElementDeserializer in project logging-log4j2 by apache.
the class StackTraceElementJsonMixInTest method testFromJsonWithLog4jModule.
@Test
public void testFromJsonWithLog4jModule() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final boolean encodeThreadContextAsList = false;
final SimpleModule module = new Log4jJsonModule(encodeThreadContextAsList, true, false, false);
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final String s = this.aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}");
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
use of org.apache.logging.log4j.jackson.Log4jStackTraceElementDeserializer in project logging-log4j2 by apache.
the class StackTraceElementXmlMixInTest method testFromJsonWithLog4jModule.
@Test
public void testFromJsonWithLog4jModule() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final boolean encodeThreadContextAsList = false;
final Log4jXmlModule module = new Log4jXmlModule(true, false);
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final String s = this.aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}");
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
use of org.apache.logging.log4j.jackson.Log4jStackTraceElementDeserializer in project logging-log4j2 by apache.
the class StackTraceElementXmlMixInTest method testFromJsonWithSimpleModule.
@Test
public void testFromJsonWithSimpleModule() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final SimpleModule module = new SimpleModule();
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final String s = this.aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}");
final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
use of org.apache.logging.log4j.jackson.Log4jStackTraceElementDeserializer in project logging-log4j2 by apache.
the class StackTraceElementYamlMixInTest method testFromYamlWithSimpleModule.
@Test
public void testFromYamlWithSimpleModule() throws Exception {
final ObjectMapper mapper = new YAMLMapper();
final SimpleModule module = new SimpleModule();
module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer());
mapper.registerModule(module);
final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123);
final StackTraceElement actual = mapper.readValue("---\nclass: package.SomeClass\nmethod: someMethod\nfile: SomeClass.java\nline: 123\n...", StackTraceElement.class);
Assert.assertEquals(expected, actual);
}
Aggregations