You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/04/15 20:27:19 UTC

logging-log4j2 git commit: ignore spurious output to the console and only fail if the text indicates that an object was allocated

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 65480fdde -> 412d7947d


ignore spurious output to the console and only fail if the text indicates that an object was allocated


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/412d7947
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/412d7947
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/412d7947

Branch: refs/heads/master
Commit: 412d7947daa15245cf6c6d01102943bdaacbb7dd
Parents: 65480fd
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 16 03:27:20 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Apr 16 03:27:20 2016 +0900

----------------------------------------------------------------------
 .../logging/log4j/core/GcFreeLoggingTest.java   | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/412d7947/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
index b5761f8..c66bae3 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
@@ -18,18 +18,20 @@ package org.apache.logging.log4j.core;
 
 import java.io.File;
 import java.net.URL;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
+import java.util.List;
 
-import com.google.monitoring.runtime.instrumentation.AllocationRecorder;
-import com.google.monitoring.runtime.instrumentation.Sampler;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
 import org.apache.logging.log4j.core.util.Constants;
-import org.junit.Ignore;
 import org.junit.Test;
 
+import com.google.monitoring.runtime.instrumentation.AllocationRecorder;
+import com.google.monitoring.runtime.instrumentation.Sampler;
+
 import static org.junit.Assert.*;
 
 /**
@@ -85,10 +87,14 @@ public class GcFreeLoggingTest {
         process.waitFor();
         process.exitValue();
 
-        final String output = new String(Files.readAllBytes(tempFile.toPath()));
-        final String NEWLINE = System.getProperty("line.separator");
-        assertEquals("FATAL o.a.l.l.c.GcFreeLoggingTest [main]  This message is logged to the console"
-                + NEWLINE, output);
+        final List<String> lines = Files.readAllLines(tempFile.toPath(), Charset.defaultCharset());
+        assertEquals("FATAL o.a.l.l.c.GcFreeLoggingTest [main]  This message is logged to the console",
+                lines.get(0));
+
+        for (int i = 1; i < lines.size(); i++) {
+            final String line = lines.get(i);
+            assertFalse(line, line.contains("allocated") || line.contains("array"));
+        }
     }
 
     /**