You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2024/01/10 01:25:34 UTC
(logging-log4cxx) branch fix_smtp_messages updated (2abb5492 -> 3e401354)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch fix_smtp_messages
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
from 2abb5492 Improve smtp appender test
new 534fac0d Restore DefaultEvaluator testing
new 22ddb8bf Avoid negative logic
new 3e401354 Document smtp server-in-the-loop testing
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/main/cpp/smtpappender.cpp | 6 +++---
src/test/cpp/net/smtpappendertestcase.cpp | 10 +++++++---
src/test/resources/input/xml/smtpAppenderValid.xml | 4 ++--
3 files changed, 12 insertions(+), 8 deletions(-)
(logging-log4cxx) 03/03: Document smtp server-in-the-loop testing
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch fix_smtp_messages
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 3e4013544c774d357211cbfaeda90497ef6ae8bd
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Jan 10 12:25:07 2024 +1100
Document smtp server-in-the-loop testing
---
src/test/cpp/net/smtpappendertestcase.cpp | 7 ++++++-
src/test/resources/input/xml/smtpAppenderValid.xml | 4 ++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/test/cpp/net/smtpappendertestcase.cpp b/src/test/cpp/net/smtpappendertestcase.cpp
index 235250a3..cba483e0 100644
--- a/src/test/cpp/net/smtpappendertestcase.cpp
+++ b/src/test/cpp/net/smtpappendertestcase.cpp
@@ -104,8 +104,13 @@ class SMTPAppenderTestCase : public AppenderSkeletonTestCase
LOGUNIT_TEST(testDefaultThreshold);
LOGUNIT_TEST(testSetOptionThreshold);
LOGUNIT_TEST(testTrigger);
+#ifdef LOG4CXX_TEST_EMAIL_AND_SMTP_HOST_ARE_IN_ENVIRONMENT_VARIABLES
+ // This test requires the following environment variables:
+ // LOG4CXX_TEST_EMAIL_RECIPIENT - where the email is sent
+ // LOG4CXX_TEST_SMTP_HOST_NAME - the email server
LOGUNIT_TEST(testInvalid);
- //LOGUNIT_TEST(testValid);
+#endif
+ LOGUNIT_TEST(testValid);
LOGUNIT_TEST_SUITE_END();
diff --git a/src/test/resources/input/xml/smtpAppenderValid.xml b/src/test/resources/input/xml/smtpAppenderValid.xml
index 49f0a311..7df3d148 100644
--- a/src/test/resources/input/xml/smtpAppenderValid.xml
+++ b/src/test/resources/input/xml/smtpAppenderValid.xml
@@ -20,9 +20,9 @@
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="A1" class="org.apache.log4j.net.SMTPAppender">
<param name="from" value="log4cxx@apache.org" />
- <param name="to" value="your-local-internet-service-provider-account@your-local-internet-service-provider-address" />
+ <param name="to" value="${LOG4CXX_TEST_EMAIL_RECIPIENT}" />
<param name="subject" value="Test message" />
- <param name="SMTPHost" value="smtp.your-local-internet-service-provider-address"/>
+ <param name="SMTPHost" value="${LOG4CXX_TEST_SMTP_HOST_NAME}"/>
<param name="SMTPPort" value="587"/>
<triggeringPolicy class="org.apache.log4j.net.SMTPAppenderTest$MockTriggeringEventEvaluator"/>
(logging-log4cxx) 01/03: Restore DefaultEvaluator testing
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch fix_smtp_messages
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 534fac0d764b061f4b600701cc4318721c64d4bf
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Jan 10 11:54:46 2024 +1100
Restore DefaultEvaluator testing
---
src/test/cpp/net/smtpappendertestcase.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/test/cpp/net/smtpappendertestcase.cpp b/src/test/cpp/net/smtpappendertestcase.cpp
index 76761313..235250a3 100644
--- a/src/test/cpp/net/smtpappendertestcase.cpp
+++ b/src/test/cpp/net/smtpappendertestcase.cpp
@@ -146,14 +146,13 @@ class SMTPAppenderTestCase : public AppenderSkeletonTestCase
appender->setTo(LOG4CXX_STR("you@example.invalid"));
appender->setFrom(LOG4CXX_STR("me@example.invalid"));
appender->setLayout(std::make_shared<SimpleLayout>());
- auto trigger = LOG4CXX_NS::cast<spi::TriggeringEventEvaluator>(std::make_shared<MockTriggeringEventEvaluator>());
- appender->setEvaluator(trigger);
appender->setErrorHandler(eh);
Pool p;
appender->activateOptions(p);
auto root = Logger::getRootLogger();
root->addAppender(appender);
LOG4CXX_INFO(root, "Hello, World.");
+ LOG4CXX_ERROR(root, "Sending Message"); // The DefaultEvaluator should trigger e-mail generation
LOGUNIT_ASSERT(0 < eh->getErrorCount());
}
(logging-log4cxx) 02/03: Avoid negative logic
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch fix_smtp_messages
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 22ddb8bfac95da00ba749b7389ec514cab9f252c
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed Jan 10 12:19:23 2024 +1100
Avoid negative logic
---
src/main/cpp/smtpappender.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp
index 6b92d49e..a09d6250 100644
--- a/src/main/cpp/smtpappender.cpp
+++ b/src/main/cpp/smtpappender.cpp
@@ -279,15 +279,15 @@ class SMTPMessage
//
// replace any stray CR or LF with CRLF
// reset start of line
- if (c != ignoreChar || startOfLine < current)
+ if (c == ignoreChar && current == startOfLine)
+ ignoreChar = 0;
+ else
{
*current++ = 0x0D;
*current++ = 0x0A;
startOfLine = current;
ignoreChar = (c == 0x0A ? 0x0D : 0x0A);
}
- else
- ignoreChar = 0;
}
else
{