summaryrefslogtreecommitdiff
path: root/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
commit928b806b8bc238de9222bd81e7fba950494588b7 (patch)
tree699a4f1c38c0f2df8a3e41cb839b84f4b7ef5bcc /cpp/src/tests/test_tools.h
parent8fca6bbadd52582a9d0e860a29adb0365c1fb71c (diff)
downloadqpid-python-928b806b8bc238de9222bd81e7fba950494588b7.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/qpid@698981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/test_tools.h')
-rw-r--r--cpp/src/tests/test_tools.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/cpp/src/tests/test_tools.h b/cpp/src/tests/test_tools.h
index 32127b0442..37a6594f8a 100644
--- a/cpp/src/tests/test_tools.h
+++ b/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*/