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 2026/01/01 05:45:49 UTC
(logging-log4cxx) branch test_program_path_variable created (now 0a35cbc0)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch test_program_path_variable
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 0a35cbc0 Test program path variables in XML configuration files
This branch includes the following new commits:
new 0a35cbc0 Test program path variables in XML configuration files
The 1 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.
(logging-log4cxx) 01/01: Test program path variables in XML configuration files
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch test_program_path_variable
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 0a35cbc0ea5fac6e1dda2d6ff4f48f43d5129a2b
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Thu Jan 1 16:45:23 2026 +1100
Test program path variables in XML configuration files
---
src/test/cpp/xml/domtestcase.cpp | 43 +++++++++++----------------
src/test/resources/input/xml/DOMTestCase1.xml | 4 +--
src/test/resources/input/xml/DOMTestCase2.xml | 4 +--
3 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/src/test/cpp/xml/domtestcase.cpp b/src/test/cpp/xml/domtestcase.cpp
index b94ab641..e08d9421 100644
--- a/src/test/cpp/xml/domtestcase.cpp
+++ b/src/test/cpp/xml/domtestcase.cpp
@@ -32,6 +32,7 @@
#include <apr_file_io.h>
#include "../testchar.h"
#include "log4cxx/helpers/loglog.h"
+#include <log4cxx/helpers/filesystempath.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -62,20 +63,17 @@ LOGUNIT_CLASS(DOMTestCase)
LoggerPtr root;
LoggerPtr logger;
-
- static const File TEMP_A1;
- static const File TEMP_A2;
- static const File FILTERED_A1;
- static const File FILTERED_A2;
- static const File TEMP_A1_2;
- static const File TEMP_A2_2;
- static const File FILTERED_A1_2;
- static const File FILTERED_A2_2;
+ LogString output_dir;
public:
void setUp()
{
LogLog::setInternalDebugging(true);
+#if !LOG4CXX_HAS_FILESYSTEM_PATH
+ spi::Configurator::properties().setProperty(LOG4CXX_STR("PROGRAM_FILE_PATH.PARENT_PATH"), LOG4CXX_STR("output"));
+#endif
+ output_dir = spi::Configurator::properties().getProperty(LOG4CXX_STR("PROGRAM_FILE_PATH.PARENT_PATH"));
+
root = Logger::getRootLogger();
logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
}
@@ -113,6 +111,11 @@ public:
filters2.push_back(&threadFilter);
filters2.push_back(&iso8601Filter);
+ const File TEMP_A1{ output_dir + LOG4CXX_STR("/temp.A1") };
+ const File FILTERED_A1{ output_dir + LOG4CXX_STR("/filtered.A1") };
+ const File TEMP_A2{ output_dir + LOG4CXX_STR("/temp.A2") };
+ const File FILTERED_A2{ output_dir + LOG4CXX_STR("/filtered.A2") };
+
try
{
Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
@@ -150,6 +153,10 @@ public:
filters2.push_back(&threadFilter);
filters2.push_back(&iso8601Filter);
+ const File TEMP_A1_2{ output_dir + LOG4CXX_STR("/temp.A1.2") };
+ const File TEMP_A2_2{ output_dir + LOG4CXX_STR("/temp.A2.2") };
+ const File FILTERED_A1_2{ output_dir + LOG4CXX_STR("/filtered.A1.2") };
+ const File FILTERED_A2_2{ output_dir + LOG4CXX_STR("/filtered.A2.2") };
try
{
Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
@@ -162,11 +169,7 @@ public:
}
const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
- const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
- // TODO: A1 doesn't contain duplicate entries
- //
- // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
- LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
+ LOGUNIT_ASSERT(Compare::compare(FILTERED_A1_2, witness1));
}
@@ -196,7 +199,6 @@ public:
/**
* Creates a output file that ends with a superscript 3.
- * Output file is checked by build.xml after completion.
*/
void test3()
{
@@ -217,7 +219,6 @@ public:
/**
* Creates a output file that ends with a ideographic 4.
- * Output file is checked by build.xml after completion.
*/
void test4()
{
@@ -285,13 +286,3 @@ public:
LOGUNIT_TEST_SUITE_REGISTRATION(DOMTestCase);
-const File DOMTestCase::TEMP_A1(LOG4CXX_TEST_STR("output/temp.A1"));
-const File DOMTestCase::TEMP_A2(LOG4CXX_TEST_STR("output/temp.A2"));
-const File DOMTestCase::FILTERED_A1(LOG4CXX_TEST_STR("output/filtered.A1"));
-const File DOMTestCase::FILTERED_A2(LOG4CXX_TEST_STR("output/filtered.A2"));
-
-const File DOMTestCase::TEMP_A1_2(LOG4CXX_TEST_STR("output/temp.A1.2"));
-const File DOMTestCase::TEMP_A2_2(LOG4CXX_TEST_STR("output/temp.A2.2"));
-const File DOMTestCase::FILTERED_A1_2(LOG4CXX_TEST_STR("output/filtered.A1.2"));
-const File DOMTestCase::FILTERED_A2_2(LOG4CXX_TEST_STR("output/filtered.A2.2"));
-
diff --git a/src/test/resources/input/xml/DOMTestCase1.xml b/src/test/resources/input/xml/DOMTestCase1.xml
index 3fd822c1..be94342c 100644
--- a/src/test/resources/input/xml/DOMTestCase1.xml
+++ b/src/test/resources/input/xml/DOMTestCase1.xml
@@ -21,7 +21,7 @@
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="A1" class="org.apache.log4j.FileAppender">
- <param name="File" value="output/temp.A1" />
+ <param name="File" value="${PROGRAM_FILE_PATH.PARENT_PATH}/temp.A1" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
@@ -30,7 +30,7 @@
</appender>
<appender name="A2" class="org.apache.log4j.FileAppender">
- <param name="File" value="output/temp.A2" />
+ <param name="File" value="${PROGRAM_FILE_PATH.PARENT_PATH}/temp.A2" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value=" [%t] %p %c - %m%n" />
diff --git a/src/test/resources/input/xml/DOMTestCase2.xml b/src/test/resources/input/xml/DOMTestCase2.xml
index 2d48dee9..3cf48fd3 100644
--- a/src/test/resources/input/xml/DOMTestCase2.xml
+++ b/src/test/resources/input/xml/DOMTestCase2.xml
@@ -21,7 +21,7 @@
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="A1" class="org.apache.log4j.FileAppender">
- <param name="File" value="output\temp.A1.2" />
+ <param name="File" value="${PROGRAM_FILE_PATH.PARENT_PATH}\temp.A1.2" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
@@ -30,7 +30,7 @@
</appender>
<appender name="A2" class="org.apache.log4j.FileAppender">
- <param name="File" value="output\temp.A2.2" />
+ <param name="File" value="${PROGRAM_FILE_PATH.PARENT_PATH}\temp.A2.2" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} [%t] %-5p - %m%n"/>