From f61e1ef7589da893b9b54448224dc0961515eb40 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 26 Oct 2007 19:48:31 +0000 Subject: Session resume support in client & broker: Client can resume a session after voluntary suspend() or network failure. Frames lost in network failure are automatically re-transmitted for transparent re-connection. client::Session improvements: - Locking to avoid races between network & user threads. - Replaced client::StateManager with sys::StateMonitor - avoid heap allocation. qpid::Exception clean up: - use QPID_MSG consistently to format exception messages. - throw typed exceptions (in reply_exceptions.h) for AMQP exceptions. - re-throw correct typed exception on client for exceptions from broker. - Removed QpidError.h rubygen/templates/constants.rb: - constants.h: Added FOO_CLASS_ID and FOO_BAR_METHOD_ID constants. - reply_constants.h: Added throwReplyException(code, text) log::Logger: - Fixed shutdown race in Statement::~Initializer() git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@588761 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/logging.cpp | 52 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'cpp/src/tests/logging.cpp') diff --git a/cpp/src/tests/logging.cpp b/cpp/src/tests/logging.cpp index f5402aaad7..1042e60077 100644 --- a/cpp/src/tests/logging.cpp +++ b/cpp/src/tests/logging.cpp @@ -71,22 +71,18 @@ BOOST_AUTO_TEST_CASE(testSelector_enable) { BOOST_CHECK(s.isEnabled(critical, "oops")); } -Logger& clearLogger() { - Logger::instance().clear(); - return Logger::instance(); -} - BOOST_AUTO_TEST_CASE(testStatementEnabled) { - // Verify that the logger enables and disables log statements. - Logger& l=clearLogger(); + // Verify that the singleton enables and disables static + // log statements. + Logger& l = Logger::instance(); l.select(Selector(debug)); - Statement s=QPID_LOG_STATEMENT_INIT(debug); + static Statement s=QPID_LOG_STATEMENT_INIT(debug); BOOST_CHECK(!s.enabled); - Statement::Initializer init(s); + static Statement::Initializer init(s); BOOST_CHECK(s.enabled); - Statement s2=QPID_LOG_STATEMENT_INIT(warning); - Statement::Initializer init2(s2); + static Statement s2=QPID_LOG_STATEMENT_INIT(warning); + static Statement::Initializer init2(s2); BOOST_CHECK(!s2.enabled); l.select(Selector(warning)); @@ -98,9 +94,10 @@ struct TestOutput : public Logger::Output { vector msg; vector stmt; - TestOutput() { - Logger::instance().output(qpid::make_auto_ptr(this)); + TestOutput(Logger& l) { + l.output(std::auto_ptr(this)); } + void log(const Statement& s, const string& m) { msg.push_back(m); stmt.push_back(s); @@ -111,10 +108,12 @@ struct TestOutput : public Logger::Output { using boost::assign::list_of; BOOST_AUTO_TEST_CASE(testLoggerOutput) { - Logger& l=clearLogger(); + Logger l; + l.clear(); l.select(Selector(debug)); Statement s=QPID_LOG_STATEMENT_INIT(debug); - TestOutput* out=new TestOutput(); + + TestOutput* out=new TestOutput(l); // Verify message is output. l.log(s, "foo"); @@ -122,7 +121,7 @@ BOOST_AUTO_TEST_CASE(testLoggerOutput) { BOOST_CHECK_EQUAL(expect, out->msg); // Verify multiple outputs - TestOutput* out2=new TestOutput(); + TestOutput* out2=new TestOutput(l); l.log(Statement(), "baz"); expect.push_back("baz\n"); BOOST_CHECK_EQUAL(expect, out->msg); @@ -131,9 +130,10 @@ BOOST_AUTO_TEST_CASE(testLoggerOutput) { } BOOST_AUTO_TEST_CASE(testMacro) { - Logger& l = clearLogger(); + Logger& l=Logger::instance(); + l.clear(); l.select(Selector(info)); - TestOutput* out=new TestOutput(); + TestOutput* out=new TestOutput(l); QPID_LOG(info, "foo"); vector expect=list_of("foo\n"); BOOST_CHECK_EQUAL(expect, out->msg); @@ -150,9 +150,9 @@ BOOST_AUTO_TEST_CASE(testMacro) { } BOOST_AUTO_TEST_CASE(testLoggerFormat) { - Logger& l=clearLogger(); + Logger& l = Logger::instance(); l.select(Selector(critical)); - TestOutput* out=new TestOutput(); + TestOutput* out=new TestOutput(l); // Time format is YYY-Month-dd hh:mm:ss l.format(Logger::TIME); @@ -183,7 +183,8 @@ BOOST_AUTO_TEST_CASE(testLoggerFormat) { } BOOST_AUTO_TEST_CASE(testOstreamOutput) { - Logger& l=clearLogger(); + Logger& l=Logger::instance(); + l.clear(); l.select(Selector(error)); ostringstream os; l.output(os); @@ -191,12 +192,12 @@ BOOST_AUTO_TEST_CASE(testOstreamOutput) { QPID_LOG(error, "bar"); QPID_LOG(error, "baz"); BOOST_CHECK_EQUAL("foo\nbar\nbaz\n", os.str()); - l.clear(); } #if 0 // This test requires manual intervention. Normally disabled. BOOST_AUTO_TEST_CASE(testSyslogOutput) { - Logger& l = clearLogger(); + Logger& l=Logger::instance(); + l.clear(); l.select(Selector(info)); l.syslog("qpid_test"); QPID_LOG(info, "Testing QPID"); @@ -312,7 +313,7 @@ BOOST_AUTO_TEST_CASE(testSelectorFromOptions) { } BOOST_AUTO_TEST_CASE(testOptionsFormat) { - Logger& l = clearLogger(); + Logger l; { Options opts; BOOST_CHECK_EQUAL(Logger::TIME|Logger::LEVEL, l.format(opts)); @@ -344,7 +345,8 @@ BOOST_AUTO_TEST_CASE(testOptionsFormat) { } BOOST_AUTO_TEST_CASE(testLoggerConfigure) { - Logger& l = clearLogger(); + Logger& l=Logger::instance(); + l.clear(); Options opts; char* argv[]={ 0, -- cgit v1.2.1