You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2020/11/18 22:19:25 UTC
[logging-log4cxx] branch master updated: Update mapfilter to return
NEUTRAL when additional filters should be considered. Update tests to check
for these values.
This is an automated email from the ASF dual-hosted git repository.
rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new 0b18b4d Update mapfilter to return NEUTRAL when additional filters should be considered. Update tests to check for these values.
new 4a872d5 Merge pull request #43 from pm-cfs/bugfix/mapfilter-chaining
0b18b4d is described below
commit 0b18b4d45d5f15475f3429e27ca4f1c3cd90152e
Author: Patrick Mills <pa...@cerberusftp.com>
AuthorDate: Mon Nov 16 17:45:17 2020 -0500
Update mapfilter to return NEUTRAL when additional filters should be considered.
Update tests to check for these values.
---
src/main/cpp/mapfilter.cpp | 4 ++--
src/test/cpp/filter/mapfiltertest.cpp | 27 ++++++++++++---------------
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/src/main/cpp/mapfilter.cpp b/src/main/cpp/mapfilter.cpp
index b164ae7..5ea3110 100644
--- a/src/main/cpp/mapfilter.cpp
+++ b/src/main/cpp/mapfilter.cpp
@@ -82,10 +82,10 @@ Filter::FilterDecision MapFilter::decide(
if (acceptOnMatch)
{
- return matched ? Filter::ACCEPT : Filter::DENY;
+ return matched ? Filter::ACCEPT : Filter::NEUTRAL;
}
else
{
- return matched ? Filter::DENY : Filter::ACCEPT;
+ return matched ? Filter::DENY : Filter::NEUTRAL;
}
}
diff --git a/src/test/cpp/filter/mapfiltertest.cpp b/src/test/cpp/filter/mapfiltertest.cpp
index bfb9e53..0b3d620 100644
--- a/src/test/cpp/filter/mapfiltertest.cpp
+++ b/src/test/cpp/filter/mapfiltertest.cpp
@@ -57,8 +57,8 @@ public:
}
/**
- * Check that MapFilter.decide() returns Filter.ACCEPT or Filter.DENY
- * based on Accept on Match setting when key/value does not match
+ * Check that MapFilter.decide() returns Filter.NEUTRAL
+ * when key/value does not match
*/
void test2()
{
@@ -74,10 +74,10 @@ public:
filter->activateOptions(p);
filter->setAcceptOnMatch(true);
- LOGUNIT_ASSERT_EQUAL(Filter::DENY, filter->decide(event));
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event));
filter->setAcceptOnMatch(false);
- LOGUNIT_ASSERT_EQUAL(Filter::ACCEPT, filter->decide(event));
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event));
}
/**
@@ -125,9 +125,9 @@ public:
filter->activateOptions(p);
filter->setMustMatchAll(true); // AND T/F
- LOGUNIT_ASSERT_EQUAL(Filter::DENY, filter->decide(event)); // does not match second
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event)); // does not match second
- filter->setMustMatchAll(false); // OR T/F
+ filter->setMustMatchAll(false); // OR T/F
LOGUNIT_ASSERT_EQUAL(Filter::ACCEPT, filter->decide(event)); // matches first
filter->setKeyValue(LOG4CXX_STR("my.name"), LOG4CXX_STR("Test"));
@@ -135,29 +135,26 @@ public:
filter->setMustMatchAll(true); // AND T/T
LOGUNIT_ASSERT_EQUAL(Filter::ACCEPT, filter->decide(event)); // matches all
- filter->setMustMatchAll(false); // OR T/T
+ filter->setMustMatchAll(false); // OR T/T
LOGUNIT_ASSERT_EQUAL(Filter::ACCEPT, filter->decide(event)); // matches first
filter->setKeyValue(LOG4CXX_STR("my.ip"), LOG4CXX_STR("localhost"));
filter->setMustMatchAll(true); // AND F/T
- LOGUNIT_ASSERT_EQUAL(Filter::DENY, filter->decide(event)); // does not match first
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event)); // does not match first
- filter->setMustMatchAll(false); // OR F/T
+ filter->setMustMatchAll(false); // OR F/T
LOGUNIT_ASSERT_EQUAL(Filter::ACCEPT, filter->decide(event)); // matches second
filter->setKeyValue(LOG4CXX_STR("my.name"), LOG4CXX_STR("Unkonwn"));
filter->setMustMatchAll(true); // AND F/F
- LOGUNIT_ASSERT_EQUAL(Filter::DENY, filter->decide(event)); // does not match first
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event)); // does not match first
- filter->setMustMatchAll(false); // OR F/F
- LOGUNIT_ASSERT_EQUAL(Filter::DENY, filter->decide(event)); // matches none
+ filter->setMustMatchAll(false); // OR F/F
+ LOGUNIT_ASSERT_EQUAL(Filter::NEUTRAL, filter->decide(event)); // matches none
}
};
-
LOGUNIT_TEST_SUITE_REGISTRATION(MapFilterTest);
-
-