Repository: logging-log4j2 Updated Branches: refs/heads/master ddf844af1 -> adad66f52
bugfix: use OS-independent line separators to run on Windows also Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/adad66f5 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/adad66f5 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/adad66f5 Branch: refs/heads/master Commit: adad66f52be226be2315681df333e80fa8842b2a Parents: ddf844a Author: rpopma <[email protected]> Authored: Thu Sep 24 15:18:03 2015 +0200 Committer: rpopma <[email protected]> Committed: Thu Sep 24 15:18:03 2015 +0200 ---------------------------------------------------------------------- .../logging/log4j/core/PatternSelectorTest.java | 6 +++-- .../log4j/core/layout/PatternLayoutTest.java | 23 +++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/adad66f5/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java index 06a5ef3..2bb9b7d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/PatternSelectorTest.java @@ -47,7 +47,9 @@ public class PatternSelectorTest { List<String> messages = app.getMessages(); assertNotNull("No Messages", messages); assertTrue("Incorrect number of messages. Expected 3, Actual " + messages.size(), messages.size() == 3); - assertEquals("[TRACE] TestPatternSelector ====== o.a.l.l.c.PatternSelectorTest.testPatternSelector:42 entry ======\n", messages.get(0)); - assertEquals("[INFO ] TestPatternSelector Hello World\n", messages.get(1)); + final String expect = String.format("[TRACE] TestPatternSelector ====== " + + "o.a.l.l.c.PatternSelectorTest.testPatternSelector:42 entry ======%n"); + assertEquals(expect, messages.get(0)); + assertEquals(String.format("[INFO ] TestPatternSelector Hello World%n"), messages.get(1)); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/adad66f5/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java index 296492b..0b372bb 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java @@ -16,28 +16,28 @@ */ package org.apache.logging.log4j.core.layout; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.MarkerManager; import org.apache.logging.log4j.ThreadContext; -import org.apache.logging.log4j.core.*; +import org.apache.logging.log4j.core.BasicConfigurationFactory; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.ConfigurationFactory; -import org.apache.logging.log4j.core.config.Property; import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.core.lookup.MainMapLookup; -import org.apache.logging.log4j.core.util.KeyValuePair; import org.apache.logging.log4j.message.SimpleMessage; import org.apache.logging.log4j.util.Strings; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; +import static org.junit.Assert.*; + /** * */ @@ -211,6 +211,7 @@ public class PatternLayoutTest { // System.out.println("event2=" + event2.getTimeMillis() / 1000); } + @SuppressWarnings("unused") private void testUnixTime(final String pattern) throws Exception { final PatternLayout layout = PatternLayout.newBuilder().withPattern(pattern + " %m") .withConfiguration(ctx.getConfiguration()).build(); @@ -278,17 +279,19 @@ public class PatternLayoutTest { .setIncludeLocation(true) .setMessage(new SimpleMessage("entry")).build(); final String result1 = new FauxLogger().formatEvent(event1, layout); - assertTrue("Unexpected result: " + result1, result1.endsWith("====== PatternLayoutTest.testPatternSelector:280 entry ======\n")); + final String expectSuffix1 = String.format("====== PatternLayoutTest.testPatternSelector:281 entry ======%n"); + assertTrue("Unexpected result: " + result1, result1.endsWith(expectSuffix1)); final LogEvent event2 = Log4jLogEvent.newBuilder() // .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") // .setLevel(Level.INFO) // .setMessage(new SimpleMessage("Hello, world 1!")).build(); final String result2 = new String(layout.toByteArray(event2)); - assertTrue("Unexpected result: " + result2, result2.endsWith("Hello, world 1!\n")); + final String expectSuffix2 = String.format("Hello, world 1!%n"); + assertTrue("Unexpected result: " + result2, result2.endsWith(expectSuffix2)); } public class FauxLogger { - public String formatEvent(LogEvent event, Layout layout) { + public String formatEvent(LogEvent event, Layout<?> layout) { return new String(layout.toByteArray(event)); } }
