diff --git a/src/test/cpp/helpers/messagebuffertest.cpp b/src/test/cpp/helpers/messagebuffertest.cpp index deba396be..f953ea308 100644 --- a/src/test/cpp/helpers/messagebuffertest.cpp +++ b/src/test/cpp/helpers/messagebuffertest.cpp @@ -21,6 +21,9 @@ #include "../logunit.h" #include #include +#include +#include +#include "util/compare.h" #if LOG4CXX_CFSTRING_API #include @@ -42,6 +45,7 @@ LOGUNIT_CLASS(MessageBufferTest) LOGUNIT_TEST(testInsertNull); LOGUNIT_TEST(testInsertInt); LOGUNIT_TEST(testInsertManipulator); + LOGUNIT_TEST(testBaseChange); #if LOG4CXX_WCHAR_T_API LOGUNIT_TEST(testInsertConstWStr); LOGUNIT_TEST(testInsertWString); @@ -136,6 +140,30 @@ LOGUNIT_CLASS(MessageBufferTest) LOGUNIT_ASSERT_EQUAL(true, buf.hasStream()); } + void testBaseChange() + { + LoggerPtr root; + LoggerPtr logger; + + root = Logger::getRootLogger(); + logger = Logger::getLogger(LOG4CXX_STR("java.org.apache.log4j.PatternLayoutTest")); + + PropertyConfigurator::configure(LOG4CXX_FILE("input/messagebuffer1.properties")); + + int num = 220; + LOG4CXX_INFO(logger, "number in hex: " << std::hex << num); + LOG4CXX_INFO(logger, "number in dec: " << num); + + LOGUNIT_ASSERT(Compare::compare(LOG4CXX_STR("output/messagebuffer"), LOG4CXX_FILE("witness/messagebuffer.1"))); + + auto rep = root->getLoggerRepository(); + + if (rep) + { + rep->resetConfiguration(); + } + } + #if LOG4CXX_WCHAR_T_API void testInsertConstWStr() { diff --git a/src/test/resources/input/messagebuffer1.properties b/src/test/resources/input/messagebuffer1.properties new file mode 100644 index 000000000..f80075bef --- /dev/null +++ b/src/test/resources/input/messagebuffer1.properties @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# See the License for the specific language governing permissions and +# limitations under the License. +# +log4j.rootCategory=DEBUG, testAppender +log4j.appender.testAppender=org.apache.log4j.FileAppender +log4j.appender.testAppender.file=output/messagebuffer +log4j.appender.testAppender.Append=false +log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout +log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m%n diff --git a/src/test/resources/witness/messagebuffer.1 b/src/test/resources/witness/messagebuffer.1 new file mode 100644 index 000000000..71145f642 --- /dev/null +++ b/src/test/resources/witness/messagebuffer.1 @@ -0,0 +1,2 @@ +INFO - number in hex: dc +INFO - number in dec: 220