You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/08/30 09:27:28 UTC

[11/24] logging-log4j2 git commit: Test [LOG4J2-1502] CsvParameterLayout is inserting NUL character if data starts with {, (, [ or ". More tests.

Test [LOG4J2-1502] CsvParameterLayout is inserting NUL character if data
starts with {, (, [ or ". More tests.

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

Branch: refs/heads/LOG4J2-1528
Commit: 05bbe44a991b4fbb76d138a902285c7951c33cea
Parents: 8d873b0
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 28 17:41:39 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 28 17:41:39 2016 -0700

----------------------------------------------------------------------
 .../CsvJsonParameterLayoutFileAppenderTest.java | 26 +++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/05bbe44a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/CsvJsonParameterLayoutFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/CsvJsonParameterLayoutFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/CsvJsonParameterLayoutFileAppenderTest.java
index 4722c3a..84578fc 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/CsvJsonParameterLayoutFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/CsvJsonParameterLayoutFileAppenderTest.java
@@ -42,14 +42,11 @@ public class CsvJsonParameterLayoutFileAppenderTest {
     @Rule
     public RuleChain rule = loggerContextRule.withCleanFilesRule(FILE_PATH);
 
-    @Test
-    @Ignore("https://issues.apache.org/jira/browse/LOG4J2-1502")
-    public void testNoNulCharacters() throws IOException {
+    public void testNoNulCharacters(final String message) throws IOException {
         @SuppressWarnings("resource")
         final LoggerContext loggerContext = loggerContextRule.getLoggerContext();
         final Logger logger = loggerContext.getLogger("com.example");
-        final String json = "{\"id\":10,\"name\":\"Alice\"}";
-        logger.error("log:", json);
+        logger.error("log:", message);
         loggerContext.stop();
         final File file = new File(FILE_PATH);
         final byte[] contents = Files.toByteArray(file);
@@ -66,6 +63,23 @@ public class CsvJsonParameterLayoutFileAppenderTest {
         Assert.assertEquals("File contains " + count0s + " 0x00 byte at indices " + sb, 0, count0s);
         final List<String> readLines = Files.readLines(file, Charset.defaultCharset());
         final String actual = readLines.get(0);
-        Assert.assertTrue(actual, actual.contains(json));
+        Assert.assertTrue(actual, actual.contains(message));
+    }
+
+    @Test
+    public void testNoNulCharactersABC() throws IOException {
+        testNoNulCharacters("ABC");;
+    }
+
+    @Test
+    @Ignore("https://issues.apache.org/jira/browse/LOG4J2-1502")
+    public void testNoNulCharactersJson() throws IOException {
+        testNoNulCharacters("{\"id\":10,\"name\":\"Alice\"}");;
+    }
+
+    @Test
+    @Ignore("https://issues.apache.org/jira/browse/LOG4J2-1502")
+    public void testNoNulCharactersXml() throws IOException {
+        testNoNulCharacters("<test attr1='val1' attr2=\"value2\">X</test>");
     }
 }