carnold 2005/01/29 09:43:45
Modified: . build.xml
tests/src minimumtestcase.cpp patternlayouttest.cpp
tests/src/net socketservertestcase.cpp
tests/src/util filter.h linenumberfilter.cpp transformer.cpp
xmllineattributefilter.cpp xmltimestampfilter.cpp
tests/src/varia errorhandlertestcase.cpp
tests/src/xml domtestcase.cpp
Log:
LOGCXX-54: Replace boost-regex with sed
Revision Changes Path
1.25 +12 -0 logging-log4cxx/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/logging-log4cxx/build.xml,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- build.xml 28 Jan 2005 17:03:37 -0000 1.24
+++ build.xml 29 Jan 2005 17:43:44 -0000 1.25
@@ -104,6 +104,8 @@
<property name="cppunit.lib.dir" location="/usr/local/lib"/>
<property name="cppunit.bin.dir" location="/usr/local/lib"/>
<property name="cppunit.lib.name" value="cppunit"/>
+
+ <property name="expat.lib.name" value="expat"/>
</target>
<target name="init" depends="win-init, unix-init">
@@ -359,6 +361,8 @@
dir="${apriconv.lib.dir}" if="apriconv.lib.dir"/>
<libset libs="${apriconv.lib.name}"
unless="apriconv.lib.dir"/>
+ <libset libs="${expat.lib.name}" dir="${expat.lib.dir}"
if="expat.lib.dir"/>
+ <libset libs="${expat.lib.name}" unless="expat.lib.dir"
if="expat.lib.name"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="${cppunit.lib.name}" dir="${cppunit.lib.dir}"/>
<project outfile="cbx/shortsocketserver" type="cbuilderx"
if="gen-cbx"/>
@@ -398,6 +402,8 @@
<libset libs="${apriconv.lib.name}"
dir="${apriconv.lib.dir}" if="apriconv.lib.dir"/>
<libset libs="${apriconv.lib.name}" unless="apriconv.lib.dir"/>
+ <libset libs="${expat.lib.name}" dir="${expat.lib.dir}"
if="expat.lib.dir"/>
+ <libset libs="${expat.lib.name}" unless="expat.lib.dir"
if="expat.lib.name"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="${cppunit.lib.name}" dir="${cppunit.lib.dir}"/>
<syslibset libs="Ws2_32 ws2 advapi32" if="is-windows"/>
@@ -434,6 +440,8 @@
<libset libs="${apriconv.lib.name}"
dir="${apriconv.lib.dir}" if="apriconv.lib.dir"/>
<libset libs="${apriconv.lib.name}" unless="apriconv.lib.dir"/>
+ <libset libs="${expat.lib.name}" dir="${expat.lib.dir}"
if="expat.lib.dir"/>
+ <libset libs="${expat.lib.name}" unless="expat.lib.dir"
if="expat.lib.name"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="${cppunit.lib.name}" dir="${cppunit.lib.dir}"/>
<syslibset libs="Ws2_32 ws2 advapi32" if="is-windows"/>
@@ -470,6 +478,8 @@
<libset libs="${apriconv.lib.name}"
dir="${apriconv.lib.dir}" if="apriconv.lib.dir"/>
<libset libs="${apriconv.lib.name}" unless="apriconv.lib.dir"/>
+ <libset libs="${expat.lib.name}" dir="${expat.lib.dir}"
if="expat.lib.dir"/>
+ <libset libs="${expat.lib.name}" unless="expat.lib.dir"
if="expat.lib.name"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="${cppunit.lib.name}" dir="${cppunit.lib.dir}"/>
<syslibset libs="Ws2_32 ws2 advapi32" if="is-windows"/>
@@ -513,6 +523,8 @@
<libset libs="${apriconv.lib.name}" unless="apriconv.lib.dir"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="${cppunit.lib.name}" dir="${cppunit.lib.dir}"/>
+ <libset libs="${expat.lib.name}" dir="${expat.lib.dir}"
if="expat.lib.dir"/>
+ <libset libs="${expat.lib.name}" unless="expat.lib.dir"
if="expat.lib.name"/>
<includepath path="${include.dir}"/>
<includepath path="/usr/include/libxml2" if="is-unix"/>
1.15 +1 -1 logging-log4cxx/tests/src/minimumtestcase.cpp
Index: minimumtestcase.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/minimumtestcase.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- minimumtestcase.cpp 28 Jan 2005 17:03:37 -0000 1.14
+++ minimumtestcase.cpp 29 Jan 2005 17:43:44 -0000 1.15
@@ -44,7 +44,7 @@
#define TTCC_PAT \
ABSOLUTE_DATE_AND_TIME_PAT \
- " \\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message
\\d{1,2}"
+ " \\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message
[0-9]{1,2}"
#define TTCC2_PAT \
ABSOLUTE_DATE_AND_TIME_PAT \
1.14 +7 -7 logging-log4cxx/tests/src/patternlayouttest.cpp
Index: patternlayouttest.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/patternlayouttest.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- patternlayouttest.cpp 28 Jan 2005 17:03:37 -0000 1.13
+++ patternlayouttest.cpp 29 Jan 2005 17:43:44 -0000 1.14
@@ -44,18 +44,18 @@
#define REGEX_STR(x) x
-#define PAT0 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* -
Message \\d{1,2}")
+#define PAT0 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* -
Message [0-9]{1,2}")
#define PAT1 ISO8601_PAT REGEX_STR(" ") PAT0
#define PAT2 ABSOLUTE_DATE_AND_TIME_PAT REGEX_STR(" ") PAT0
#define PAT3 ABSOLUTE_TIME_PAT REGEX_STR(" ") PAT0
#define PAT4 RELATIVE_TIME_PAT REGEX_STR(" ") PAT0
-#define PAT5 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* :
Message \\d{1,2}")
-#define PAT6 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO |WARN |ERROR|FATAL)
.*patternlayouttest.cpp\\(\\d{1,4}\\): Message \\d{1,3}")
-#define PAT11a REGEX_STR("^(DEBUG|INFO |WARN |ERROR|FATAL) \\[0x[0-9A-F]*]\\
log4j.PatternLayoutTest: Message \\d{1,2}")
-#define PAT11b REGEX_STR("^(DEBUG|INFO |WARN |ERROR|FATAL) \\[0x[0-9A-F]*]\\
root: Message \\d{1,2}")
+#define PAT5 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* :
Message [0-9]{1,2}")
+#define PAT6 REGEX_STR("\\[0x[0-9A-F]*]\\ (DEBUG|INFO |WARN |ERROR|FATAL)
.*patternlayouttest.cpp\\([0-9]{1,4}\\): Message [0-9]{1,3}")
+#define PAT11a REGEX_STR("^(DEBUG|INFO |WARN |ERROR|FATAL) \\[0x[0-9A-F]*]\\
log4j.PatternLayoutTest: Message [0-9]{1,2}")
+#define PAT11b REGEX_STR("^(DEBUG|INFO |WARN |ERROR|FATAL) \\[0x[0-9A-F]*]\\
root: Message [0-9]{1,2}")
#define PAT12 REGEX_STR("^\\[0x[0-9A-F]*]\\ (DEBUG|INFO |WARN |ERROR|FATAL)
")\
- REGEX_STR(".*patternlayouttest.cpp\\(\\d{1,4}\\): ")\
- REGEX_STR("Message \\d{1,2}")
+ REGEX_STR(".*patternlayouttest.cpp\\([0-9]{1,4}\\): ")\
+ REGEX_STR("Message [0-9]{1,2}")
#define PAT_MDC_1 REGEX_STR("")
using namespace log4cxx;
1.17 +8 -8 logging-log4cxx/tests/src/net/socketservertestcase.cpp
Index: socketservertestcase.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/net/socketservertestcase.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- socketservertestcase.cpp 28 Jan 2005 17:03:37 -0000 1.16
+++ socketservertestcase.cpp 29 Jan 2005 17:43:44 -0000 1.17
@@ -60,37 +60,37 @@
// DEBUG T1 [thread] org.apache.log4j.net.SocketAppenderTestCase Message 1
#define PAT1 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T1
\\[0x[0-9A-F]*]\\ ") \
- REGEX_STR(".* Message \\d{1,2}")
+ REGEX_STR(".* Message [0-9]{1,2}")
// DEBUG T2 [thread] patternlayouttest.cpp(?) Message 1
#define PAT2 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T2
\\[0x[0-9A-F]*]\\ ") \
- REGEX_STR(".*socketservertestcase.cpp\\(\\d{1,4}\\) Message
\\d{1,2}")
+ REGEX_STR(".*socketservertestcase.cpp\\([0-9]{1,4}\\) Message
[0-9]{1,2}")
// DEBUG T3 [thread] patternlayouttest.cpp(?) Message 1
#define PAT3 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T3
\\[0x[0-9A-F]*]\\ ") \
- REGEX_STR(".*socketservertestcase.cpp\\(\\d{1,4}\\) Message
\\d{1,2}")
+ REGEX_STR(".*socketservertestcase.cpp\\([0-9]{1,4}\\) Message
[0-9]{1,2}")
// DEBUG some T4 MDC-TEST4 [thread] SocketAppenderTestCase - Message 1
// DEBUG some T4 MDC-TEST4 [thread] SocketAppenderTestCase - Message 1
#define PAT4 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some T4 MDC-TEST4
\\[0x[0-9A-F]*]\\") \
- REGEX_STR(" (root|SocketServerTestCase) - Message \\d{1,2}")
+ REGEX_STR(" (root|SocketServerTestCase) - Message [0-9]{1,2}")
#define PAT5 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some5 T5
MDC-TEST5 \\[0x[0-9A-F]*]\\") \
- REGEX_STR(" (root|SocketServerTestCase) - Message \\d{1,2}")
+ REGEX_STR(" (root|SocketServerTestCase) - Message [0-9]{1,2}")
#define PAT6 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some6 T6
client-test6 MDC-TEST6") \
- REGEX_STR(" \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase) - Message
\\d{1,2}")
+ REGEX_STR(" \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase) - Message
[0-9]{1,2}")
#define PAT7 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some7 T7
client-test7 MDC-TEST7") \
- REGEX_STR(" \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase) - Message
\\d{1,2}")
+ REGEX_STR(" \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase) - Message
[0-9]{1,2}")
// DEBUG some8 T8 shortSocketServer MDC-TEST7 [thread] SocketServerTestCase
- Message 1
#define PAT8 \
REGEX_STR("^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some8 T8
shortSocketServer") \
- REGEX_STR(" MDC-TEST8 \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase)
- Message \\d{1,2}")
+ REGEX_STR(" MDC-TEST8 \\[0x[0-9A-F]*]\\ (root|SocketServerTestCase)
- Message [0-9]{1,2}")
class ShortSocketServerLauncher
{
1.13 +6 -6 logging-log4cxx/tests/src/util/filter.h
Index: filter.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/util/filter.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- filter.h 28 Jan 2005 17:03:37 -0000 1.12
+++ filter.h 29 Jan 2005 17:43:45 -0000 1.13
@@ -23,11 +23,11 @@
#include <log4cxx/helpers/exception.h>
#define BASIC_PAT "\\[0x[0-9A-F]*] (FATAL|ERROR|WARN|INFO|DEBUG)"
-#define ISO8601_PAT "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}"
+#define ISO8601_PAT "^[0-9]{4}-[0-9]{2}-[0-9]{2}
[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}"
#define ABSOLUTE_DATE_AND_TIME_PAT \
- "^\\d{1,2} .{2,6}\\.? 200\\d \\d{2}:\\d{2}:\\d{2},\\d{3}"
-#define ABSOLUTE_TIME_PAT "^\\d{2}:\\d{2}:\\d{2},\\d{3}"
-#define RELATIVE_TIME_PAT "^\\d{1,10}"
+ "^[0-9]{1,2} .{2,6}\\.? 200[0-9] [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}"
+#define ABSOLUTE_TIME_PAT "^[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}"
+#define RELATIVE_TIME_PAT "^[0-9]{1,10}"
namespace log4cxx
{
@@ -41,8 +41,8 @@
Filter();
virtual ~Filter();
- typedef std::pair<std::string, std::string>
PatternReplacement;
- typedef std::vector <PatternReplacement> PatternList;
+ typedef std::pair<std::string, std::string>
PatternReplacement;
+ typedef std::vector <PatternReplacement> PatternList;
const PatternList& getPatterns() const{
return patterns;
}
1.8 +2 -2 logging-log4cxx/tests/src/util/linenumberfilter.cpp
Index: linenumberfilter.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/util/linenumberfilter.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- linenumberfilter.cpp 28 Jan 2005 17:03:37 -0000 1.7
+++ linenumberfilter.cpp 29 Jan 2005 17:43:45 -0000 1.8
@@ -19,8 +19,8 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-LineNumberFilter::LineNumberFilter()
+LineNumberFilter::LineNumberFilter()
{
patterns.push_back( PatternReplacement(" [^ ]*[\\\\]", " "));
- patterns.push_back( PatternReplacement("\\(\\d{1,4}\\)", "\\(X\\)"));
+ patterns.push_back( PatternReplacement("\\([0-9]{1,4}\\)", "\\(X\\)"));
}
1.8 +85 -30 logging-log4cxx/tests/src/util/transformer.cpp
Index: transformer.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/util/transformer.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- transformer.cpp 28 Jan 2005 17:03:37 -0000 1.7
+++ transformer.cpp 29 Jan 2005 17:43:45 -0000 1.8
@@ -19,6 +19,7 @@
#include <apr_thread_proc.h>
#include <apr_pools.h>
#include <apr_file_io.h>
+#include <assert.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -31,7 +32,7 @@
for(std::vector<Filter*>::const_iterator iter = filters.begin();
iter != filters.end();
iter++) {
-
+
const log4cxx::Filter::PatternList& thesePatterns =
(*iter)->getPatterns();
for (log4cxx::Filter::PatternList::const_iterator pattern =
thesePatterns.begin();
pattern != thesePatterns.end();
@@ -55,46 +56,100 @@
apr_pool_t* pool;
apr_status_t stat = apr_pool_create(&pool, NULL);
- apr_procattr_t* attr = NULL;
- stat = apr_procattr_create(&attr, pool);
-
+ //
+ // open the output file
+ //
apr_file_t* child_out;
apr_int32_t flags = APR_FOPEN_WRITE | APR_FOPEN_CREATE |
APR_FOPEN_TRUNCATE;
- stat = apr_file_open(&child_out, out.getOSName().c_str(),
+ stat = apr_file_open(&child_out, out.getOSName().c_str(),
flags, APR_OS_DEFAULT, pool);
+ assert(stat == 0);
- stat = apr_procattr_child_out_set(attr, child_out, NULL);
-
- const char** args = (const char**)
- apr_palloc(pool, sizeof(*args) * patterns.size()*2 + 3);
- args[0] = "-E";
- int i = 1;
- std::string tmp;
- for (log4cxx::Filter::PatternList::const_iterator iter =
patterns.begin();
+ //
+ // fairly naive file copy code
+ //
+ //
+ apr_file_t* in_file;
+ stat = apr_file_open(&in_file, in.getOSName().c_str(),
+ APR_FOPEN_READ, APR_OS_DEFAULT, pool);
+ assert(stat == 0);
+ apr_size_t bufsize = 32000;
+ void* buf = apr_palloc(pool, bufsize);
+ apr_size_t bytesRead = bufsize;
+
+ while(stat == 0 && bytesRead == bufsize) {
+ stat = apr_file_read(in_file, buf, &bytesRead);
+ if (stat == 0 && bytesRead > 0) {
+ stat = apr_file_write(child_out, buf, &bytesRead);
+ assert(stat == 0);
+ }
+ }
+ apr_file_close(child_out);
+ apr_file_close(in_file);
+
+
+ //
+ // if there are patterns, invoke sed to execute the replacements
+ //
+ //
+ if (patterns.size() > 0) {
+ apr_procattr_t* attr = NULL;
+ stat = apr_procattr_create(&attr, pool);
+ assert(stat == 0);
+
+
+ const char** args = (const char**)
+ apr_palloc(pool, (patterns.size()*2 + 4) * sizeof(*args));
+ int i = 0;
+ args[i++] = "-i";
+ args[i++] = "-r";
+ std::string tmp;
+ for (log4cxx::Filter::PatternList::const_iterator iter =
patterns.begin();
iter != patterns.end();
iter++) {
args[i++] = "-e";
- tmp = "s`";
+ tmp = "sQ";
tmp.append(iter->first);
- tmp.append(1, '`');
+ tmp.append(1, 'Q');
tmp.append(iter->second);
- tmp.append("`g");
- char* arg = (char*) apr_palloc(pool, tmp.length() + 1 *
sizeof(char));
+ tmp.append("Qg");
+ char* arg = (char*) apr_palloc(pool, (tmp.length() + 1) *
sizeof(char));
strcpy(arg, tmp.c_str());
args[i++] = arg;
+ }
+
+ args[i++] = out.getOSName().c_str();
+ args[i] = NULL;
+
+#if 0
+ // capture the error stream to diagnose problems
+ //
+ // open the error file
+ //
+ apr_file_t* child_err;
+ apr_int32_t flags = APR_FOPEN_WRITE | APR_FOPEN_CREATE |
APR_FOPEN_TRUNCATE;
+ stat = apr_file_open(&child_err, "sed.log",
+ flags, APR_OS_DEFAULT, pool);
+ assert(stat == 0);
+
+ stat = apr_procattr_child_err_set(attr, child_err, NULL);
+ assert(stat == 0);
+#endif
+
+
+
+
+
+ apr_proc_t pid;
+ stat = apr_proc_create(&pid,"sed", args, NULL, attr, pool);
+ assert(stat == 0);
+
+ int exitcode = -1;
+ apr_exit_why_e exitwhy;
+ stat = apr_proc_wait(&pid, &exitcode, &exitwhy, APR_WAIT);
+ apr_exit_why_e foo = exitwhy;
}
-
- args[i++] = in.getOSName().c_str();
- args[i] = NULL;
-
-
- apr_proc_t pid;
- stat = apr_proc_create(&pid,"sed", args, NULL, attr, pool);
-
- int exitcode = -1;
- apr_exit_why_e exitwhy;
- stat = apr_proc_wait(&pid, &exitcode, &exitwhy, APR_WAIT);
-
+
apr_pool_destroy(pool);
-}
\ No newline at end of file
+}
1.5 +2 -2 logging-log4cxx/tests/src/util/xmllineattributefilter.cpp
Index: xmllineattributefilter.cpp
===================================================================
RCS file:
/home/cvs/logging-log4cxx/tests/src/util/xmllineattributefilter.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- xmllineattributefilter.cpp 28 Jan 2005 17:03:37 -0000 1.4
+++ xmllineattributefilter.cpp 29 Jan 2005 17:43:45 -0000 1.5
@@ -20,6 +20,6 @@
using namespace log4cxx::helpers;
XMLLineAttributeFilter::XMLLineAttributeFilter() {
- patterns.push_back( PatternReplacement("file=\"[^ ]*[\\\\]",
"file=\""));
- patterns.push_back( PatternReplacement("line=\"\\d{1,3}\"",
"line=\"X\""));
+ patterns.push_back( PatternReplacement("file=\"[^ ]*[\\\\]",
"file=\""));
+ patterns.push_back( PatternReplacement("line=\"[0-9]{1,3}\"",
"line=\"X\""));
}
1.6 +2 -2 logging-log4cxx/tests/src/util/xmltimestampfilter.cpp
Index: xmltimestampfilter.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/util/xmltimestampfilter.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- xmltimestampfilter.cpp 28 Jan 2005 17:03:37 -0000 1.5
+++ xmltimestampfilter.cpp 29 Jan 2005 17:43:45 -0000 1.6
@@ -19,7 +19,7 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-XMLTimestampFilter::XMLTimestampFilter()
- : Filter("timestamp=\"\\d{10,13}\"", "timestamp=\"XXX\"") {}
+XMLTimestampFilter::XMLTimestampFilter()
+ : Filter("timestamp=\"[0-9]{10,13}\"", "timestamp=\"XXX\"") {}
1.7 +63 -63 logging-log4cxx/tests/src/varia/errorhandlertestcase.cpp
Index: errorhandlertestcase.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/varia/errorhandlertestcase.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- errorhandlertestcase.cpp 28 Jan 2005 17:03:38 -0000 1.6
+++ errorhandlertestcase.cpp 29 Jan 2005 17:43:45 -0000 1.7
@@ -1,12 +1,12 @@
/*
* Copyright 2003-2005 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,98 +36,98 @@
using namespace log4cxx::helpers;
using namespace log4cxx::xml;
-#define TEST1_A_PAT "FALLBACK - test - Message \\d"
-#define TEST1_B_PAT "FALLBACK - root - Message \\d"
+#define TEST1_A_PAT "FALLBACK - test - Message [0-9]"
+#define TEST1_B_PAT "FALLBACK - root - Message [0-9]"
#define TEST1_2_PAT \
- "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} " \
- "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"
+ "^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} " \
+ "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message [0-9]"
class ErrorHandlerTestCase : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ErrorHandlerTestCase);
- CPPUNIT_TEST(test1);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ErrorHandlerTestCase);
+ CPPUNIT_TEST(test1);
+ CPPUNIT_TEST_SUITE_END();
- LoggerPtr root;
- LoggerPtr logger;
+ LoggerPtr root;
+ LoggerPtr logger;
static const File TEMP;
static const File FILTERED;
public:
- void setUp()
- {
- root = Logger::getRootLogger();
- logger = Logger::getLogger(L"test");
- }
-
- void tearDown()
- {
- logger->getLoggerRepository()->resetConfiguration();
- }
-
- void test1()
- {
- DOMConfigurator::configure("input/xml/fallback1.xml");
- common();
-
- ControlFilter cf;
- cf << TEST1_A_PAT << TEST1_B_PAT << TEST1_2_PAT;
-
- ThreadFilter threadFilter;
- LineNumberFilter lineNumberFilter;
-
- std::vector<Filter *> filters;
- filters.push_back(&cf);
- filters.push_back(&threadFilter);
- filters.push_back(&lineNumberFilter);
+ void setUp()
+ {
+ root = Logger::getRootLogger();
+ logger = Logger::getLogger(L"test");
+ }
+
+ void tearDown()
+ {
+ logger->getLoggerRepository()->resetConfiguration();
+ }
+
+ void test1()
+ {
+ DOMConfigurator::configure("input/xml/fallback1.xml");
+ common();
+
+ ControlFilter cf;
+ cf << TEST1_A_PAT << TEST1_B_PAT << TEST1_2_PAT;
+
+ ThreadFilter threadFilter;
+ LineNumberFilter lineNumberFilter;
+
+ std::vector<Filter *> filters;
+ filters.push_back(&cf);
+ filters.push_back(&threadFilter);
+ filters.push_back(&lineNumberFilter);
common();
- try
- {
- Transformer::transform(TEMP, FILTERED, filters);
- }
- catch(UnexpectedFormatException& e)
- {
+ try
+ {
+ Transformer::transform(TEMP, FILTERED, filters);
+ }
+ catch(UnexpectedFormatException& e)
+ {
std::cout << "UnexpectedFormatException :" << e.what() <<
std::endl;
- throw;
- }
+ throw;
+ }
const File witness(L"witness/fallback");
- CPPUNIT_ASSERT(Compare::compare(FILTERED, witness));
- }
-
- void common()
- {
- int i = -1;
+ CPPUNIT_ASSERT(Compare::compare(FILTERED, witness));
+ }
+
+ void common()
+ {
+ int i = -1;
std::ostringstream os;
os << "Message " << ++ i;
- LOG4CXX_DEBUG(logger, os.str());
- LOG4CXX_DEBUG(root, os.str());
+ LOG4CXX_DEBUG(logger, os.str());
+ LOG4CXX_DEBUG(root, os.str());
os.str("");
os << "Message " << ++i;
- LOG4CXX_INFO(logger, os.str());
- LOG4CXX_INFO(root, os.str());
+ LOG4CXX_INFO(logger, os.str());
+ LOG4CXX_INFO(root, os.str());
os.str("");
os << "Message " << ++i;
- LOG4CXX_WARN(logger, os.str());
- LOG4CXX_WARN(root, os.str());
+ LOG4CXX_WARN(logger, os.str());
+ LOG4CXX_WARN(root, os.str());
os.str("");
os << "Message " << ++i;
- LOG4CXX_ERROR(logger, os.str());
- LOG4CXX_ERROR(root, os.str());
+ LOG4CXX_ERROR(logger, os.str());
+ LOG4CXX_ERROR(root, os.str());
os.str("");
os << "Message " << ++i;
- LOG4CXX_FATAL(logger, os.str());
- LOG4CXX_FATAL(root, os.str());
- }
+ LOG4CXX_FATAL(logger, os.str());
+ LOG4CXX_FATAL(root, os.str());
+ }
};
//TODO: Not sure this test ever worked. 0.9.7 didn't call common
1.8 +4 -4 logging-log4cxx/tests/src/xml/domtestcase.cpp
Index: domtestcase.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/tests/src/xml/domtestcase.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- domtestcase.cpp 28 Jan 2005 17:03:38 -0000 1.7
+++ domtestcase.cpp 29 Jan 2005 17:43:45 -0000 1.8
@@ -41,12 +41,12 @@
#define TEST1_1A_PAT \
- "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d"
+ "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message [0-9]"
-#define TEST1_1B_PAT "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d"
+#define TEST1_1B_PAT "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message [0-9]"
-#define TEST1_2_PAT "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} " \
- "\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"
+#define TEST1_2_PAT "^[0-9]{4}-[0-9]{2}-[0-9]{2}
[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} " \
+ "\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message [0-9]"
class DOMTestCase : public CppUnit::TestFixture
{