From a59365db352b669b0163b0759597cf94120e91b8 Mon Sep 17 00:00:00 2001 From: Petr Adamec Date: Fri, 6 Apr 2018 08:45:29 +0200 Subject: [PATCH] Add test for JBEAP-14320 --- .../java/org/jboss/logmanager/FilterTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/java/org/jboss/logmanager/FilterTests.java b/src/test/java/org/jboss/logmanager/FilterTests.java index b51a1f97..4fe1b8b5 100644 --- a/src/test/java/org/jboss/logmanager/FilterTests.java +++ b/src/test/java/org/jboss/logmanager/FilterTests.java @@ -436,6 +436,15 @@ public void testRegexFilter3() { assertFalse("Handler was run", ran.get()); } + @Test + public void regexFilterExceptionNullMessageTest(){ + final ExtLogRecord logRecord = new ExtLogRecord(Level.ALL, null, null); + final Filter filter = new RegexFilter("test"); + boolean isLoggable = filter.isLoggable(logRecord); + assertFalse(isLoggable); + assertNull(logRecord.getFormattedMessage()); + } + @Test public void testSubstitueFilter0() { final Filter filter = new SubstituteFilter(Pattern.compile("test"), "lunch", true); @@ -490,6 +499,14 @@ public void testSubstituteFilter3() { assertEquals("Substitution was not correctly applied", "This is a lunches lunches", record.getFormattedMessage()); } + @Test + public void substituteFilterExceptionNullMessageTest(){ + final ExtLogRecord logRecord = new ExtLogRecord(Level.ALL, null, null); + final Filter filter = new SubstituteFilter(Pattern.compile("test"), "lunch", true); + filter.isLoggable(logRecord); + assertEquals("null", logRecord.getFormattedMessage()); + } + private static final class MessageCheckingHandler extends Handler {