Add testPatternAndParameterizedMessageDateLookup(). Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c4954a87 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c4954a87 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c4954a87
Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: c4954a872376dec6dbeb66bb82f03dfe83f710d1 Parents: 7cbb136 Author: ggregory <ggreg...@us-l-gg02.rocketsoftware.com> Authored: Thu Aug 18 20:20:34 2016 -0700 Committer: ggregory <ggreg...@us-l-gg02.rocketsoftware.com> Committed: Thu Aug 18 20:20:34 2016 -0700 ---------------------------------------------------------------------- .../core/pattern/MessagePatternConverterTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c4954a87/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java index 4dea72d..57fe994 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java @@ -16,17 +16,18 @@ */ package org.apache.logging.log4j.core.pattern; +import static org.junit.Assert.assertEquals; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.DefaultConfiguration; import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.SimpleMessage; import org.junit.Test; -import static org.junit.Assert.*; - /** * */ @@ -61,6 +62,19 @@ public class MessagePatternConverterTest { } @Test + public void testPatternAndParameterizedMessageDateLookup() throws Exception { + final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, null); + Message msg = new ParameterizedMessage("${date:now:buhu}"); + LogEvent event = Log4jLogEvent.newBuilder() // + .setLoggerName("MyLogger") // + .setLevel(Level.DEBUG) // + .setMessage(msg).build(); + StringBuilder sb = new StringBuilder(); + converter.format(event, sb); + assertEquals("Unexpected result", "${date:now:buhu}", sb.toString()); + } + + @Test public void testPatternWithConfiguration() throws Exception { final Configuration config = new DefaultConfiguration(); final MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null);