summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/test_tools.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-09-25 14:16:51 +0000
committerAlan Conway <aconway@apache.org>2008-09-25 14:16:51 +0000
commit3751fdb4d6cdf3600aa97b7ec802c37c6c2a6f01 (patch)
tree7ade88dcd40745aca0bbba7025d785f793308812 /qpid/cpp/src/tests/test_tools.h
parentf8eca1f86220e065a5d56eff484ef5726a226f8f (diff)
downloadqpid-python-3751fdb4d6cdf3600aa97b7ec802c37c6c2a6f01.tar.gz
Added ScopedSuppressLogging, used to suppress expected error messages in tests.
For examples see src/tests/exception_test.cpp git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@698981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/test_tools.h')
-rw-r--r--qpid/cpp/src/tests/test_tools.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/qpid/cpp/src/tests/test_tools.h b/qpid/cpp/src/tests/test_tools.h
index 32127b0442..37a6594f8a 100644
--- a/qpid/cpp/src/tests/test_tools.h
+++ b/qpid/cpp/src/tests/test_tools.h
@@ -18,9 +18,9 @@
* limitations under the License.
*
*/
+#include "qpid/log/Logger.h"
#include <limits.h> // Include before boost/test headers.
-
#include <boost/test/test_tools.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/regex.hpp>
@@ -78,5 +78,17 @@ inline bool regexPredicate(const std::string& re, const std::string& text) {
/** Check if types of two objects (as given by typeinfo::name()) match. */
#define BOOST_CHECK_TYPEID_EQUAL(a,b) BOOST_CHECK_EQUAL(typeid(a).name(),typeid(b).name())
+/**
+ * Supress all logging in a scope, restore to previous configuration in destructor.
+ */
+struct ScopedSuppressLogging {
+ typedef qpid::log::Logger Logger;
+ ScopedSuppressLogging(Logger& l=Logger::instance()) : logger(l), opts(l.getOptions()) { l.clear(); }
+ ~ScopedSuppressLogging() { logger.configure(opts); }
+ Logger& logger;
+ qpid::log::Options opts;
+};
+
+
#endif /*!TEST_TOOLS_H*/