Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r596012 - in /logging/log4cxx/trunk/src/test/cpp: propertyconfi: msg#00034

apache.logging.log4cxx.devel

Subject: svn commit: r596012 - in /logging/log4cxx/trunk/src/test/cpp: propertyconfiguratortest.cpp vectorappender.h

Author: carnold
Date: Sat Nov 17 14:12:15 2007
New Revision: 596012

URL: http://svn.apache.org/viewvc?rev=596012&view=rev
Log:
LOGCXX-207: Test cases for reported problem with appender-specific thresholds

Modified:
logging/log4cxx/trunk/src/test/cpp/propertyconfiguratortest.cpp
logging/log4cxx/trunk/src/test/cpp/vectorappender.h

Modified: logging/log4cxx/trunk/src/test/cpp/propertyconfiguratortest.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/propertyconfiguratortest.cpp?rev=596012&r1=596011&r2=596012&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/propertyconfiguratortest.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/propertyconfiguratortest.cpp Sat Nov 17
14:12:15 2007
@@ -1,69 +1,88 @@
-/*
- * 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.
- */
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <log4cxx/helpers/properties.h>
-#include <log4cxx/propertyconfigurator.h>
-#include <log4cxx/logmanager.h>
-
-using namespace log4cxx;
-using namespace log4cxx::helpers;
-
-
-class PropertyConfiguratorTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(PropertyConfiguratorTest);
- CPPUNIT_TEST(testInherited);
- CPPUNIT_TEST(testNull);
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void testInherited() {
- Properties props;
-
props.put(LOG4CXX_STR("log4j.rootLogger"),LOG4CXX_STR("DEBUG,VECTOR1"));
-
props.put(LOG4CXX_STR("log4j.logger.org.apache.log4j.PropertyConfiguratorTest"),
LOG4CXX_STR("inherited,VECTOR2"));
- props.put(LOG4CXX_STR("log4j.appender.VECTOR1"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
- props.put(LOG4CXX_STR("log4j.appender.VECTOR2"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
- PropertyConfigurator::configure(props);
- LoggerPtr logger =
Logger::getLogger("org.apache.log4j.PropertyConfiguratorTest");
- CPPUNIT_ASSERT_EQUAL((int) Level::DEBUG_INT,
- logger->getEffectiveLevel()->toInt());
- Logger::getRootLogger()->setLevel(Level::getError());
- CPPUNIT_ASSERT_EQUAL((int) Level::ERROR_INT,
- logger->getEffectiveLevel()->toInt());
- LogManager::resetConfiguration();
- }
-
- void testNull() {
- Properties props;
-
props.put(LOG4CXX_STR("log4j.rootLogger"),LOG4CXX_STR("DEBUG,VECTOR1"));
-
props.put(LOG4CXX_STR("log4j.logger.org.apache.log4j.PropertyConfiguratorTest"),
LOG4CXX_STR("NuLL,VECTOR2"));
- props.put(LOG4CXX_STR("log4j.appender.VECTOR1"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
- props.put(LOG4CXX_STR("log4j.appender.VECTOR2"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
- PropertyConfigurator::configure(props);
- LoggerPtr logger =
Logger::getLogger("org.apache.log4j.PropertyConfiguratorTest");
- CPPUNIT_ASSERT_EQUAL((int) Level::DEBUG_INT,
- logger->getEffectiveLevel()->toInt());
- Logger::getRootLogger()->setLevel(Level::getError());
- CPPUNIT_ASSERT_EQUAL((int) Level::ERROR_INT,
- logger->getEffectiveLevel()->toInt());
- LogManager::resetConfiguration();
- }
-};
-
-
-CPPUNIT_TEST_SUITE_REGISTRATION(PropertyConfiguratorTest);
+/*
+ * 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.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <log4cxx/helpers/properties.h>
+#include <log4cxx/propertyconfigurator.h>
+#include <log4cxx/logmanager.h>
+#include "vectorappender.h"
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+
+class PropertyConfiguratorTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(PropertyConfiguratorTest);
+ CPPUNIT_TEST(testInherited);
+ CPPUNIT_TEST(testNull);
+ CPPUNIT_TEST(testAppenderThreshold);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void testInherited() {
+ Properties props;
+
props.put(LOG4CXX_STR("log4j.rootLogger"),LOG4CXX_STR("DEBUG,VECTOR1"));
+
props.put(LOG4CXX_STR("log4j.logger.org.apache.log4j.PropertyConfiguratorTest"),
LOG4CXX_STR("inherited,VECTOR2"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR1"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR2"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
+ PropertyConfigurator::configure(props);
+ LoggerPtr logger =
Logger::getLogger("org.apache.log4j.PropertyConfiguratorTest");
+ CPPUNIT_ASSERT_EQUAL((int) Level::DEBUG_INT,
+ logger->getEffectiveLevel()->toInt());
+ Logger::getRootLogger()->setLevel(Level::getError());
+ CPPUNIT_ASSERT_EQUAL((int) Level::ERROR_INT,
+ logger->getEffectiveLevel()->toInt());
+ LogManager::resetConfiguration();
+ }
+
+ void testNull() {
+ Properties props;
+
props.put(LOG4CXX_STR("log4j.rootLogger"),LOG4CXX_STR("DEBUG,VECTOR1"));
+
props.put(LOG4CXX_STR("log4j.logger.org.apache.log4j.PropertyConfiguratorTest"),
LOG4CXX_STR("NuLL,VECTOR2"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR1"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR2"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
+ PropertyConfigurator::configure(props);
+ LoggerPtr logger =
Logger::getLogger("org.apache.log4j.PropertyConfiguratorTest");
+ CPPUNIT_ASSERT_EQUAL((int) Level::DEBUG_INT,
+ logger->getEffectiveLevel()->toInt());
+ Logger::getRootLogger()->setLevel(Level::getError());
+ CPPUNIT_ASSERT_EQUAL((int) Level::ERROR_INT,
+ logger->getEffectiveLevel()->toInt());
+ LogManager::resetConfiguration();
+ }
+
+ void testAppenderThreshold() {
+ Properties props;
+ props.put(LOG4CXX_STR("log4j.rootLogger"), LOG4CXX_STR("ALL,VECTOR1"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR1"),
LOG4CXX_STR("org.apache.log4j.VectorAppender"));
+ props.put(LOG4CXX_STR("log4j.appender.VECTOR1.threshold"),
LOG4CXX_STR("WARN"));
+ PropertyConfigurator::configure(props);
+ LoggerPtr root(Logger::getRootLogger());
+ VectorAppenderPtr appender(root->getAppender("VECTOR1"));
+ CPPUNIT_ASSERT_EQUAL((int) Level::WARN_INT,
appender->getThreshold()->toInt());
+ LOG4CXX_INFO(root, "Info message");
+ LOG4CXX_WARN(root, "Warn message");
+ LOG4CXX_WARN(root, "Error message");
+ CPPUNIT_ASSERT_EQUAL((size_t) 2, appender->vector.size());
+ LogManager::resetConfiguration();
+ }
+
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(PropertyConfiguratorTest);

Modified: logging/log4cxx/trunk/src/test/cpp/vectorappender.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/vectorappender.h?rev=596012&r1=596011&r2=596012&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/vectorappender.h (original)
+++ logging/log4cxx/trunk/src/test/cpp/vectorappender.h Sat Nov 17 14:12:15 2007
@@ -32,6 +32,10 @@
{
public:
DECLARE_LOG4CXX_OBJECT(VectorAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(VectorAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()

std::vector<spi::LoggingEventPtr> vector;






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
version-control...    qnx.openqnx.dev...    redhat.rhn.user...    ietf.openpgp/20...    mail.mutt.user/...    web.microformat...    java.sync4j.use...    education.ezpro...    user-groups.blu...    solaris.manager...    org.fitug.debat...    technology.erps...    politics.activi...    linux.redhat.fe...    bug-tracking.ma...    xfce.user/2004-...    hams/2004-11/ms...    kde.users.pim/2...    culture.cooking...    freebsd.devel.x...    gnu.m4.adhoc/20...    ngpt.user/2002-...    apple.fink.deve...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation