Modified: qpid/trunk/qpid/cpp/src/tests/BrokerMgmtAgent.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/BrokerMgmtAgent.cpp?rev=1398530&r1=1398529&r2=1398530&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/BrokerMgmtAgent.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/BrokerMgmtAgent.cpp Mon Oct 15 21:35:38 2012
@@ -41,751 +41,700 @@ using namespace qpid::types;
 
 
 namespace qpid {
-    namespace tests {
+namespace tests {
 
-        namespace _qmf = qmf::org::apache::qpid::broker::mgmt::test;
-        namespace {
+namespace _qmf = qmf::org::apache::qpid::broker::mgmt::test;
+namespace {
 
-            typedef boost::shared_ptr<_qmf::TestObject> TestObjectPtr;
-            typedef std::vector<TestObjectPtr> TestObjectVector;
+typedef boost::shared_ptr<_qmf::TestObject> TestObjectPtr;
+typedef std::vector<TestObjectPtr> TestObjectVector;
 
-            // Instantiates a broker and its internal management agent.  
Provides
-            // factories for constructing Receivers for object indication 
messages.
-            //
-            class AgentFixture
-            {
-                MessagingFixture *mFix;
-
-            public:
-                AgentFixture( unsigned int pubInterval=10,
-                              bool qmfV2=false,
-                              qpid::broker::Broker::Options opts = 
qpid::broker::Broker::Options())
-                {
-                    opts.enableMgmt=true;
-                    opts.qmf2Support=qmfV2;
-                    opts.mgmtPubInterval=pubInterval;
-                    mFix = new MessagingFixture(opts, true);
-
-                    _qmf::TestObject::registerSelf(getBrokerAgent());
-                };
-                ~AgentFixture()
-                {
-                    delete mFix;
-                };
-                ::qpid::management::ManagementAgent *getBrokerAgent() { return 
mFix->broker->getManagementAgent(); }
-                Receiver createV1DataIndRcvr( const std::string package, const 
std::string klass )
-                {
-                    return mFix->session.createReceiver(std::string("kqueue; 
{create: always, delete: always, "
-                                                                    "node: 
{type: queue, "
-                                                                    
"x-bindings: [{exchange: qpid.management, "
-                                                                    "key: 
'console.obj.1.0.")
-                                                        + package + 
std::string(".") + klass
-                                                        + 
std::string("'}]}}"));
-                };
-                Receiver createV2DataIndRcvr( const std::string package, const 
std::string klass )
-                {
-                    std::string p(package);
-                    std::replace(p.begin(), p.end(), '.', '_');
-                    std::string k(klass);
-                    std::replace(k.begin(), k.end(), '.', '_');
-
-                    return mFix->session.createReceiver(std::string("kqueue; 
{create: always, delete: always, "
-                                                                    "node: 
{type: queue, "
-                                                                    
"x-bindings: [{exchange: qmf.default.topic, "
-                                                                    "key: 
'agent.ind.data.")
-                                                        + p + std::string(".") 
+ k
-                                                        + 
std::string("'}]}}"));
-                };
-            };
-
-
-            // A "management object" that supports the TestObject
-            //
-            class TestManageable : public qpid::management::Manageable
-            {
-                management::ManagementObject*  mgmtObj;
-                const std::string key;
-            public:
-                TestManageable(management::ManagementAgent *agent, std::string 
_key)
-                    : key(_key)
-                {
-                    _qmf::TestObject *tmp = new _qmf::TestObject(agent, this);
-
-                    // seed it with some default values...
-                    tmp->set_string1(key);
-                    tmp->set_bool1(true);
-                    qpid::types::Variant::Map vMap;
-                    vMap["one"] = qpid::types::Variant(1);
-                    vMap["two"] = qpid::types::Variant("two");
-                    vMap["three"] = qpid::types::Variant("whatever");
-                    tmp->set_map1(vMap);
-
-                    mgmtObj = tmp;
-                };
-                ~TestManageable() { mgmtObj = 0; /* deleted by agent on 
shutdown */ };
-                management::ManagementObject* GetManagementObject() const { 
return mgmtObj; };
-                static void validateTestObjectProperties(_qmf::TestObject& to)
-                {
-                    // verify the default values are as expected.  We don't 
check 'string1',
-                    // as it is the object key, and is unique for each object 
(no default value).
-                    BOOST_CHECK(to.get_bool1() == true);
-                    BOOST_CHECK(to.get_map1().size() == 3);
-                    qpid::types::Variant::Map mappy = to.get_map1();
-                    BOOST_CHECK(1 == (unsigned int)mappy["one"]);
-                    BOOST_CHECK(mappy["two"].asString() == std::string("two"));
-                    BOOST_CHECK(mappy["three"].asString() == 
std::string("whatever"));
-                };
-            };
-
-
-            // decode a V1 Content Indication message
-            //
-            void decodeV1ObjectUpdates(const Message& inMsg, TestObjectVector& 
objs, const size_t objLen)
-            {
-                const size_t MAX_BUFFER_SIZE=65536;
-                char tmp[MAX_BUFFER_SIZE];
-
-                objs.clear();
-
-                BOOST_CHECK(inMsg.getContent().size() <= MAX_BUFFER_SIZE);
-
-                ::memcpy(tmp, inMsg.getContent().data(), 
inMsg.getContent().size());
-                Buffer buf(tmp, inMsg.getContent().size());
-
-                while (buf.available() > 8) {     // 8 == qmf v1 header size
-                    BOOST_CHECK_EQUAL(buf.getOctet(), 'A');
-                    BOOST_CHECK_EQUAL(buf.getOctet(), 'M');
-                    BOOST_CHECK_EQUAL(buf.getOctet(), '2');
-                    BOOST_CHECK_EQUAL(buf.getOctet(), 'c'); // opcode == 
content indication
-                    // @@todo: kag: how do we skip 'i' entries???
-                    buf.getLong();  // ignore sequence
-
-                    std::string str1;                   // decode content body 
as string
-                    buf.getRawData(str1, objLen);
-
-                    TestObjectPtr fake(new _qmf::TestObject(0,0));
-                    fake->readProperties( str1 );
-                    objs.push_back(fake);
-                }
-            }
-
-
-            // decode a V2 Content Indication message
-            //
-            void decodeV2ObjectUpdates(const qpid::messaging::Message& inMsg, 
TestObjectVector& objs)
-            {
-                objs.clear();
-
-                BOOST_CHECK_EQUAL(inMsg.getContentType(), 
std::string("amqp/list"));
-
-                const ::qpid::types::Variant::Map& m = inMsg.getProperties();
-                Variant::Map::const_iterator iter = 
m.find(std::string("qmf.opcode"));
-                BOOST_CHECK(iter != m.end());
-                BOOST_CHECK_EQUAL(iter->second.asString(), 
std::string("_data_indication"));
-
-                Variant::List vList;
-                ::qpid::amqp_0_10::ListCodec::decode(inMsg.getContent(), 
vList);
-
-                for (Variant::List::iterator lIter = vList.begin(); lIter != 
vList.end(); lIter++) {
-                    TestObjectPtr fake(new _qmf::TestObject(0,0));
-                    fake->readTimestamps(lIter->asMap());
-                    fake->mapDecodeValues((lIter->asMap())["_values"].asMap());
-                    objs.push_back(fake);
-                }
-            }
-        }
+// Instantiates a broker and its internal management agent.  Provides
+// factories for constructing Receivers for object indication messages.
+//
+class AgentFixture
+{
+    MessagingFixture *mFix;
+
+  public:
+    AgentFixture( unsigned int pubInterval=10,
+                  bool qmfV2=false,
+                  qpid::broker::Broker::Options opts = 
qpid::broker::Broker::Options())
+    {
+        opts.enableMgmt=true;
+        opts.qmf2Support=qmfV2;
+        opts.mgmtPubInterval=pubInterval;
+        mFix = new MessagingFixture(opts, true);
+
+        _qmf::TestObject::registerSelf(getBrokerAgent());
+    };
+    ~AgentFixture()
+    {
+        delete mFix;
+    };
+    ::qpid::management::ManagementAgent *getBrokerAgent() { return 
mFix->broker->getManagementAgent(); }
+    Receiver createV1DataIndRcvr( const std::string package, const std::string 
klass )
+    {
+        return mFix->session.createReceiver(std::string("kqueue; {create: 
always, delete: always, "
+                                                        "node: {type: queue, "
+                                                        "x-bindings: 
[{exchange: qpid.management, "
+                                                        "key: 
'console.obj.1.0.")
+                                            + package + std::string(".") + 
klass
+                                            + std::string("'}]}}"));
+    };
+    Receiver createV2DataIndRcvr( const std::string package, const std::string 
klass )
+    {
+        std::string p(package);
+        std::replace(p.begin(), p.end(), '.', '_');
+        std::string k(klass);
+        std::replace(k.begin(), k.end(), '.', '_');
+
+        return mFix->session.createReceiver(std::string("kqueue; {create: 
always, delete: always, "
+                                                        "node: {type: queue, "
+                                                        "x-bindings: 
[{exchange: qmf.default.topic, "
+                                                        "key: 
'agent.ind.data.")
+                                            + p + std::string(".") + k
+                                            + std::string("'}]}}"));
+    };
+};
+
+
+// A "management object" that supports the TestObject
+//
+class TestManageable : public qpid::management::Manageable
+{
+    management::ManagementObject::shared_ptr mgmtObj;
+    const std::string key;
+  public:
+    TestManageable(management::ManagementAgent *agent, std::string _key)
+        : key(_key)
+    {
+        _qmf::TestObject::shared_ptr tmp(new _qmf::TestObject(agent, this));
+
+        // seed it with some default values...
+        tmp->set_string1(key);
+        tmp->set_bool1(true);
+        qpid::types::Variant::Map vMap;
+        vMap["one"] = qpid::types::Variant(1);
+        vMap["two"] = qpid::types::Variant("two");
+        vMap["three"] = qpid::types::Variant("whatever");
+        tmp->set_map1(vMap);
+
+        mgmtObj = tmp;
+    };
+    ~TestManageable() { mgmtObj.reset(); }
+    management::ManagementObject::shared_ptr GetManagementObject() const { 
return mgmtObj; };
+    static void validateTestObjectProperties(_qmf::TestObject& to)
+    {
+        // verify the default values are as expected.  We don't check 
'string1',
+        // as it is the object key, and is unique for each object (no default 
value).
+        BOOST_CHECK(to.get_bool1() == true);
+        BOOST_CHECK(to.get_map1().size() == 3);
+        qpid::types::Variant::Map mappy = to.get_map1();
+        BOOST_CHECK(1 == (unsigned int)mappy["one"]);
+        BOOST_CHECK(mappy["two"].asString() == std::string("two"));
+        BOOST_CHECK(mappy["three"].asString() == std::string("whatever"));
+    };
+};
+
+
+// decode a V1 Content Indication message
+//
+void decodeV1ObjectUpdates(const Message& inMsg, TestObjectVector& objs, const 
size_t objLen)
+{
+    const size_t MAX_BUFFER_SIZE=65536;
+    char tmp[MAX_BUFFER_SIZE];
+
+    objs.clear();
+
+    BOOST_CHECK(inMsg.getContent().size() <= MAX_BUFFER_SIZE);
+
+    ::memcpy(tmp, inMsg.getContent().data(), inMsg.getContent().size());
+    Buffer buf(tmp, inMsg.getContent().size());
+
+    while (buf.available() > 8) {     // 8 == qmf v1 header size
+        BOOST_CHECK_EQUAL(buf.getOctet(), 'A');
+        BOOST_CHECK_EQUAL(buf.getOctet(), 'M');
+        BOOST_CHECK_EQUAL(buf.getOctet(), '2');
+        BOOST_CHECK_EQUAL(buf.getOctet(), 'c'); // opcode == content indication
+        // @@todo: kag: how do we skip 'i' entries???
+        buf.getLong();  // ignore sequence
+
+        std::string str1;                   // decode content body as string
+        buf.getRawData(str1, objLen);
+
+        TestObjectPtr fake(new _qmf::TestObject(0,0));
+        fake->readProperties( str1 );
+        objs.push_back(fake);
+    }
+}
 
-        QPID_AUTO_TEST_SUITE(BrokerMgmtAgent)
 
-        // verify that an object that is added to the broker's management 
database is
-        // published correctly.  Furthermore, verify that it is published once 
after
-        // it has been deleted.
-        //
-        QPID_AUTO_TEST_CASE(v1ObjPublish)
-        {
-            AgentFixture* fix = new AgentFixture(3);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
+// decode a V2 Content Indication message
+//
+void decodeV2ObjectUpdates(const qpid::messaging::Message& inMsg, 
TestObjectVector& objs)
+{
+    objs.clear();
+
+    BOOST_CHECK_EQUAL(inMsg.getContentType(), std::string("amqp/list"));
+
+    const ::qpid::types::Variant::Map& m = inMsg.getProperties();
+    Variant::Map::const_iterator iter = m.find(std::string("qmf.opcode"));
+    BOOST_CHECK(iter != m.end());
+    BOOST_CHECK_EQUAL(iter->second.asString(), 
std::string("_data_indication"));
+
+    Variant::List vList;
+    ::qpid::amqp_0_10::ListCodec::decode(inMsg.getContent(), vList);
+
+    for (Variant::List::iterator lIter = vList.begin(); lIter != vList.end(); 
lIter++) {
+        TestObjectPtr fake(new _qmf::TestObject(0,0));
+        fake->readTimestamps(lIter->asMap());
+        fake->mapDecodeValues((lIter->asMap())["_values"].asMap());
+        objs.push_back(fake);
+    }
+}
+}
 
-            // create a manageable test object
-            TestManageable *tm = new TestManageable(agent, 
std::string("obj1"));
-            uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
+QPID_AUTO_TEST_SUITE(BrokerMgmtAgent)
 
-            Receiver r1 = 
fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+// verify that an object that is added to the broker's management database is
+// published correctly.  Furthermore, verify that it is published once after
+// it has been deleted.
+//
+QPID_AUTO_TEST_CASE(v1ObjPublish)
+{
+    AgentFixture* fix = new AgentFixture(3);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
 
-            agent->addObject(tm->GetManagementObject(), 1);
+    // create a manageable test object
+    TestManageable *tm = new TestManageable(agent, std::string("obj1"));
+    uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
 
-            // wait for the object to be published
-            Message m1;
-            BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
+    Receiver r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
 
-            TestObjectVector objs;
-            decodeV1ObjectUpdates(m1, objs, objLen);
-            BOOST_CHECK(objs.size() > 0);
+    agent->addObject(tm->GetManagementObject(), 1);
 
-            for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    // wait for the object to be published
+    Message m1;
+    BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
 
-                TestManageable::validateTestObjectProperties(**oIter);
+    TestObjectVector objs;
+    decodeV1ObjectUpdates(m1, objs, objLen);
+    BOOST_CHECK(objs.size() > 0);
 
-                qpid::types::Variant::Map mappy;
-                (*oIter)->writeTimestamps(mappy);
-                BOOST_CHECK(0 == mappy["_delete_ts"].asUint64());   // not 
deleted
-            }
+    for (TestObjectVector::iterator oIter = objs.begin(); oIter != objs.end(); 
oIter++) {
 
-            // destroy the object
+        TestManageable::validateTestObjectProperties(**oIter);
 
-            tm->GetManagementObject()->resourceDestroy();
+        qpid::types::Variant::Map mappy;
+        (*oIter)->writeTimestamps(mappy);
+        BOOST_CHECK(0 == mappy["_delete_ts"].asUint64());   // not deleted
+    }
 
-            // wait for the deleted object to be published
+    // destroy the object
 
-            bool isDeleted = false;
-            while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
+    tm->GetManagementObject()->resourceDestroy();
 
-                decodeV1ObjectUpdates(m1, objs, objLen);
-                BOOST_CHECK(objs.size() > 0);
+    // wait for the deleted object to be published
 
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    bool isDeleted = false;
+    while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
 
-                    TestManageable::validateTestObjectProperties(**oIter);
+        decodeV1ObjectUpdates(m1, objs, objLen);
+        BOOST_CHECK(objs.size() > 0);
 
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        isDeleted = true;
-                }
-            }
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
 
-            BOOST_CHECK(isDeleted);
+            TestManageable::validateTestObjectProperties(**oIter);
 
-            r1.close();
-            delete fix;
-            delete tm;
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                isDeleted = true;
         }
+    }
 
-        // Repeat the previous test, but with V2-based object support
-        //
-        QPID_AUTO_TEST_CASE(v2ObjPublish)
-        {
-            AgentFixture* fix = new AgentFixture(3, true);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
+    BOOST_CHECK(isDeleted);
 
-            TestManageable *tm = new TestManageable(agent, 
std::string("obj2"));
+    r1.close();
+    delete fix;
+    delete tm;
+}
 
-            Receiver r1 = 
fix->createV2DataIndRcvr(tm->GetManagementObject()->getPackageName(), "#");
+// Repeat the previous test, but with V2-based object support
+//
+QPID_AUTO_TEST_CASE(v2ObjPublish)
+{
+    AgentFixture* fix = new AgentFixture(3, true);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
 
-            agent->addObject(tm->GetManagementObject(), "testobj-1");
+    TestManageable *tm = new TestManageable(agent, std::string("obj2"));
 
-            // wait for the object to be published
-            Message m1;
-            BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
+    Receiver r1 = 
fix->createV2DataIndRcvr(tm->GetManagementObject()->getPackageName(), "#");
 
-            TestObjectVector objs;
-            decodeV2ObjectUpdates(m1, objs);
-            BOOST_CHECK(objs.size() > 0);
+    agent->addObject(tm->GetManagementObject(), "testobj-1");
 
-            for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    // wait for the object to be published
+    Message m1;
+    BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
 
-                TestManageable::validateTestObjectProperties(**oIter);
+    TestObjectVector objs;
+    decodeV2ObjectUpdates(m1, objs);
+    BOOST_CHECK(objs.size() > 0);
 
-                qpid::types::Variant::Map mappy;
-                (*oIter)->writeTimestamps(mappy);
-                BOOST_CHECK(0 == mappy["_delete_ts"].asUint64());
-            }
+    for (TestObjectVector::iterator oIter = objs.begin(); oIter != objs.end(); 
oIter++) {
 
-            // destroy the object
+        TestManageable::validateTestObjectProperties(**oIter);
 
-            tm->GetManagementObject()->resourceDestroy();
+        qpid::types::Variant::Map mappy;
+        (*oIter)->writeTimestamps(mappy);
+        BOOST_CHECK(0 == mappy["_delete_ts"].asUint64());
+    }
 
-            // wait for the deleted object to be published
+    // destroy the object
 
-            bool isDeleted = false;
-            while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
+    tm->GetManagementObject()->resourceDestroy();
 
-                decodeV2ObjectUpdates(m1, objs);
-                BOOST_CHECK(objs.size() > 0);
+    // wait for the deleted object to be published
 
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    bool isDeleted = false;
+    while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
 
-                    TestManageable::validateTestObjectProperties(**oIter);
+        decodeV2ObjectUpdates(m1, objs);
+        BOOST_CHECK(objs.size() > 0);
 
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        isDeleted = true;
-                }
-            }
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
 
-            BOOST_CHECK(isDeleted);
+            TestManageable::validateTestObjectProperties(**oIter);
 
-            r1.close();
-            delete fix;
-            delete tm;
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                isDeleted = true;
         }
+    }
 
+    BOOST_CHECK(isDeleted);
 
-        // verify that a deleted object is exported correctly using the
-        // exportDeletedObjects() method.  V1 testcase.
-        //
-        QPID_AUTO_TEST_CASE(v1ExportDelObj)
-        {
-            AgentFixture* fix = new AgentFixture(3);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            // create a manageable test object
-            TestManageable *tm = new TestManageable(agent, 
std::string("myObj"));
-            uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
-
-            Receiver r1 = 
fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+    r1.close();
+    delete fix;
+    delete tm;
+}
 
-            agent->addObject(tm->GetManagementObject(), 1);
 
-            // wait for the object to be published
-            Message m1;
-            BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
+// verify that a deleted object is exported correctly using the
+// exportDeletedObjects() method.  V1 testcase.
+//
+QPID_AUTO_TEST_CASE(v1ExportDelObj)
+{
+    AgentFixture* fix = new AgentFixture(3);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
 
-            TestObjectVector objs;
-            decodeV1ObjectUpdates(m1, objs, objLen);
-            BOOST_CHECK(objs.size() > 0);
+    // create a manageable test object
+    TestManageable *tm = new TestManageable(agent, std::string("myObj"));
+    uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
 
-            // destroy the object, then immediately export (before the next 
poll cycle)
+    Receiver r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
 
-            ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
-            tm->GetManagementObject()->resourceDestroy();
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 1);
+    agent->addObject(tm->GetManagementObject(), 1);
 
-            // wait for the deleted object to be published
+    // wait for the object to be published
+    Message m1;
+    BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
 
-            bool isDeleted = false;
-            while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
+    TestObjectVector objs;
+    decodeV1ObjectUpdates(m1, objs, objLen);
+    BOOST_CHECK(objs.size() > 0);
 
-                decodeV1ObjectUpdates(m1, objs, objLen);
-                BOOST_CHECK(objs.size() > 0);
+    // destroy the object, then immediately export (before the next poll cycle)
 
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
+    tm->GetManagementObject()->resourceDestroy();
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 1);
 
-                    TestManageable::validateTestObjectProperties(**oIter);
+    // wait for the deleted object to be published
 
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        isDeleted = true;
-                }
-            }
+    bool isDeleted = false;
+    while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
 
-            BOOST_CHECK(isDeleted);
+        decodeV1ObjectUpdates(m1, objs, objLen);
+        BOOST_CHECK(objs.size() > 0);
 
-            // verify there are no deleted objects to export now.
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
 
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 0);
+            TestManageable::validateTestObjectProperties(**oIter);
 
-            r1.close();
-            delete fix;
-            delete tm;
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                isDeleted = true;
         }
+    }
 
+    BOOST_CHECK(isDeleted);
 
-        // verify that a deleted object is imported correctly using the
-        // importDeletedObjects() method.  V1 testcase.
-        //
-        QPID_AUTO_TEST_CASE(v1ImportDelObj)
-        {
-            AgentFixture* fix = new AgentFixture(3);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
+    // verify there are no deleted objects to export now.
 
-            // create a manageable test object
-            TestManageable *tm = new TestManageable(agent, 
std::string("anObj"));
-            uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 0);
 
-            Receiver r1 = 
fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+    r1.close();
+    delete fix;
+    delete tm;
+}
 
-            agent->addObject(tm->GetManagementObject(), 1);
 
-            // wait for the object to be published
-            Message m1;
-            BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
+// verify that a deleted object is imported correctly using the
+// importDeletedObjects() method.  V1 testcase.
+//
+QPID_AUTO_TEST_CASE(v1ImportDelObj)
+{
+    AgentFixture* fix = new AgentFixture(3);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
 
-            TestObjectVector objs;
-            decodeV1ObjectUpdates(m1, objs, objLen);
-            BOOST_CHECK(objs.size() > 0);
+    // create a manageable test object
+    TestManageable *tm = new TestManageable(agent, std::string("anObj"));
+    uint32_t objLen = tm->GetManagementObject()->writePropertiesSize();
 
-            // destroy the object, then immediately export (before the next 
poll cycle)
+    Receiver r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
 
-            ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
-            tm->GetManagementObject()->resourceDestroy();
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 1);
+    agent->addObject(tm->GetManagementObject(), 1);
 
-            // destroy the broker, and reinistantiate a new one without 
populating it
-            // with a TestObject.
+    // wait for the object to be published
+    Message m1;
+    BOOST_CHECK(r1.fetch(m1, Duration::SECOND * 6));
 
-            r1.close();
-            delete fix;
-            delete tm;    // should no longer be necessary
+    TestObjectVector objs;
+    decodeV1ObjectUpdates(m1, objs, objLen);
+    BOOST_CHECK(objs.size() > 0);
 
-            fix = new AgentFixture(3);
-            r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
-            agent = fix->getBrokerAgent();
-            agent->importDeletedObjects( delObjs );
+    // destroy the object, then immediately export (before the next poll cycle)
 
-            // wait for the deleted object to be published
+    ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
+    tm->GetManagementObject()->resourceDestroy();
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 1);
 
-            bool isDeleted = false;
-            while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
+    // destroy the broker, and reinistantiate a new one without populating it
+    // with a TestObject.
 
-                decodeV1ObjectUpdates(m1, objs, objLen);
-                BOOST_CHECK(objs.size() > 0);
+    r1.close();
+    delete fix;
+    delete tm;    // should no longer be necessary
 
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    fix = new AgentFixture(3);
+    r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+    agent = fix->getBrokerAgent();
+    agent->importDeletedObjects( delObjs );
 
-                    TestManageable::validateTestObjectProperties(**oIter);
+    // wait for the deleted object to be published
 
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        isDeleted = true;
-                }
-            }
+    bool isDeleted = false;
+    while (!isDeleted && r1.fetch(m1, Duration::SECOND * 6)) {
 
-            BOOST_CHECK(isDeleted);
+        decodeV1ObjectUpdates(m1, objs, objLen);
+        BOOST_CHECK(objs.size() > 0);
 
-            // verify there are no deleted objects to export now.
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
 
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 0);
+            TestManageable::validateTestObjectProperties(**oIter);
 
-            r1.close();
-            delete fix;
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                isDeleted = true;
         }
+    }
 
+    BOOST_CHECK(isDeleted);
 
-        // verify that an object that is added and deleted prior to the
-        // first poll cycle is accounted for by the export
-        //
-        QPID_AUTO_TEST_CASE(v1ExportFastDelObj)
-        {
-            AgentFixture* fix = new AgentFixture(3);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            // create a manageable test object
-            TestManageable *tm = new TestManageable(agent, 
std::string("objectifyMe"));
-
-            // add, then immediately delete and export the object...
-
-            ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
-            agent->addObject(tm->GetManagementObject(), 999);
-            tm->GetManagementObject()->resourceDestroy();
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 1);
+    // verify there are no deleted objects to export now.
 
-            delete fix;
-            delete tm;
-        }
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 0);
 
+    r1.close();
+    delete fix;
+}
 
-        // Verify that we can export and import multiple deleted objects 
correctly.
-        //
-        QPID_AUTO_TEST_CASE(v1ImportMultiDelObj)
-        {
-            AgentFixture* fix = new AgentFixture(3);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            Receiver r1 = 
fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
-
-            // populate the agent with multiple test objects
-            const size_t objCount = 50;
-            std::vector<TestManageable *> tmv;
-            uint32_t objLen;
-
-            for (size_t i = 0; i < objCount; i++) {
-                std::stringstream key;
-                key << "testobj-" << std::setfill('x') << std::setw(4) << i;
-                // (no, seriously, I didn't just do that.)
-                // Note well: we have to keep the key string length EXACTLY 
THE SAME
-                // FOR ALL OBJECTS, so objLen will be the same.  Otherwise the
-                // decodeV1ObjectUpdates() will fail (v1 lacks explict encoded 
length).
-                TestManageable *tm = new TestManageable(agent, key.str());
-                objLen = tm->GetManagementObject()->writePropertiesSize();
-                agent->addObject(tm->GetManagementObject(), i + 1);
-                tmv.push_back(tm);
-            }
 
-            // wait for the objects to be published
-            Message m1;
-            uint32_t    msgCount = 0;
-            while(r1.fetch(m1, Duration::SECOND * 6)) {
-                TestObjectVector objs;
-                decodeV1ObjectUpdates(m1, objs, objLen);
-                msgCount += objs.size();
-            }
+// verify that an object that is added and deleted prior to the
+// first poll cycle is accounted for by the export
+//
+QPID_AUTO_TEST_CASE(v1ExportFastDelObj)
+{
+    AgentFixture* fix = new AgentFixture(3);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
+
+    // create a manageable test object
+    TestManageable *tm = new TestManageable(agent, std::string("objectifyMe"));
+
+    // add, then immediately delete and export the object...
+
+    ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
+    agent->addObject(tm->GetManagementObject(), 999);
+    tm->GetManagementObject()->resourceDestroy();
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 1);
 
-            BOOST_CHECK_EQUAL(msgCount, objCount);
+    delete fix;
+    delete tm;
+}
 
-            // destroy some of the objects, then immediately export (before 
the next poll cycle)
 
-            uint32_t delCount = 0;
-            for (size_t i = 0; i < objCount; i += 2) {
-                tmv[i]->GetManagementObject()->resourceDestroy();
-                delCount++;
-            }
+// Verify that we can export and import multiple deleted objects correctly.
+//
+QPID_AUTO_TEST_CASE(v1ImportMultiDelObj)
+{
+    AgentFixture* fix = new AgentFixture(3);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
+
+    Receiver r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
+
+    // populate the agent with multiple test objects
+    const size_t objCount = 50;
+    std::vector<TestManageable *> tmv;
+    uint32_t objLen;
+
+    for (size_t i = 0; i < objCount; i++) {
+        std::stringstream key;
+        key << "testobj-" << std::setfill('x') << std::setw(4) << i;
+        // (no, seriously, I didn't just do that.)
+        // Note well: we have to keep the key string length EXACTLY THE SAME
+        // FOR ALL OBJECTS, so objLen will be the same.  Otherwise the
+        // decodeV1ObjectUpdates() will fail (v1 lacks explict encoded length).
+        TestManageable *tm = new TestManageable(agent, key.str());
+        objLen = tm->GetManagementObject()->writePropertiesSize();
+        agent->addObject(tm->GetManagementObject(), i + 1);
+        tmv.push_back(tm);
+    }
 
-            ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK_EQUAL(delObjs.size(), delCount);
-
-            // destroy the broker, and reinistantiate a new one without 
populating it
-            // with TestObjects.
-
-            r1.close();
-            delete fix;
-            while (tmv.size()) {
-                delete tmv.back();
-                tmv.pop_back();
-            }
+    // wait for the objects to be published
+    Message m1;
+    uint32_t    msgCount = 0;
+    while(r1.fetch(m1, Duration::SECOND * 6)) {
+        TestObjectVector objs;
+        decodeV1ObjectUpdates(m1, objs, objLen);
+        msgCount += objs.size();
+    }
 
-            fix = new AgentFixture(3);
-            r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
-            agent = fix->getBrokerAgent();
-            agent->importDeletedObjects( delObjs );
-
-            // wait for the deleted object to be published, verify the count
-
-            uint32_t countDels = 0;
-            while (r1.fetch(m1, Duration::SECOND * 6)) {
-                TestObjectVector objs;
-                decodeV1ObjectUpdates(m1, objs, objLen);
-                BOOST_CHECK(objs.size() > 0);
+    BOOST_CHECK_EQUAL(msgCount, objCount);
 
-                
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+    // destroy some of the objects, then immediately export (before the next 
poll cycle)
 
-                    TestManageable::validateTestObjectProperties(**oIter);
+    uint32_t delCount = 0;
+    for (size_t i = 0; i < objCount; i += 2) {
+        tmv[i]->GetManagementObject()->resourceDestroy();
+        delCount++;
+    }
 
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        countDels++;
-                }
-            }
+    ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK_EQUAL(delObjs.size(), delCount);
+
+    // destroy the broker, and reinistantiate a new one without populating it
+    // with TestObjects.
+
+    r1.close();
+    delete fix;
+    while (tmv.size()) {
+        delete tmv.back();
+        tmv.pop_back();
+    }
 
-            // make sure we get the correct # of deleted objects
-            BOOST_CHECK_EQUAL(countDels, delCount);
+    fix = new AgentFixture(3);
+    r1 = fix->createV1DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+    agent = fix->getBrokerAgent();
+    agent->importDeletedObjects( delObjs );
+
+    // wait for the deleted object to be published, verify the count
+
+    uint32_t countDels = 0;
+    while (r1.fetch(m1, Duration::SECOND * 6)) {
+        TestObjectVector objs;
+        decodeV1ObjectUpdates(m1, objs, objLen);
+        BOOST_CHECK(objs.size() > 0);
 
-            // verify there are no deleted objects to export now.
+                
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
 
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 0);
+            TestManageable::validateTestObjectProperties(**oIter);
 
-            r1.close();
-            delete fix;
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                countDels++;
         }
+    }
 
-        // Verify that we can export and import multiple deleted objects 
correctly.
-        // QMF V2 variant
-        QPID_AUTO_TEST_CASE(v2ImportMultiDelObj)
-        {
-            AgentFixture* fix = new AgentFixture(3, true);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            Receiver r1 = 
fix->createV2DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
-
-            // populate the agent with multiple test objects
-            const size_t objCount = 50;
-            std::vector<TestManageable *> tmv;
-
-            for (size_t i = 0; i < objCount; i++) {
-                std::stringstream key;
-                key << "testobj-" << i;
-                TestManageable *tm = new TestManageable(agent, key.str());
-                if (tm->GetManagementObject()->writePropertiesSize()) {}
-                agent->addObject(tm->GetManagementObject(), key.str());
-                tmv.push_back(tm);
-            }
+    // make sure we get the correct # of deleted objects
+    BOOST_CHECK_EQUAL(countDels, delCount);
 
-            // wait for the objects to be published
-            Message m1;
-            uint32_t    msgCount = 0;
-            while(r1.fetch(m1, Duration::SECOND * 6)) {
-                TestObjectVector objs;
-                decodeV2ObjectUpdates(m1, objs);
-                msgCount += objs.size();
-            }
+    // verify there are no deleted objects to export now.
 
-            BOOST_CHECK_EQUAL(msgCount, objCount);
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 0);
 
-            // destroy some of the objects, then immediately export (before 
the next poll cycle)
+    r1.close();
+    delete fix;
+}
 
-            uint32_t delCount = 0;
-            for (size_t i = 0; i < objCount; i += 2) {
-                tmv[i]->GetManagementObject()->resourceDestroy();
-                delCount++;
-            }
+// Verify that we can export and import multiple deleted objects correctly.
+// QMF V2 variant
+QPID_AUTO_TEST_CASE(v2ImportMultiDelObj)
+{
+    AgentFixture* fix = new AgentFixture(3, true);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
+
+    Receiver r1 = fix->createV2DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
+
+    // populate the agent with multiple test objects
+    const size_t objCount = 50;
+    std::vector<TestManageable *> tmv;
+
+    for (size_t i = 0; i < objCount; i++) {
+        std::stringstream key;
+        key << "testobj-" << i;
+        TestManageable *tm = new TestManageable(agent, key.str());
+        if (tm->GetManagementObject()->writePropertiesSize()) {}
+        agent->addObject(tm->GetManagementObject(), key.str());
+        tmv.push_back(tm);
+    }
 
-            ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK_EQUAL(delObjs.size(), delCount);
-
-            // destroy the broker, and reinistantiate a new one without 
populating it
-            // with TestObjects.
-
-            r1.close();
-            delete fix;
-            while (tmv.size()) {
-                delete tmv.back();
-                tmv.pop_back();
-            }
+    // wait for the objects to be published
+    Message m1;
+    uint32_t    msgCount = 0;
+    while(r1.fetch(m1, Duration::SECOND * 6)) {
+        TestObjectVector objs;
+        decodeV2ObjectUpdates(m1, objs);
+        msgCount += objs.size();
+    }
 
-            fix = new AgentFixture(3, true);
-            r1 = fix->createV2DataIndRcvr("org.apache.qpid.broker.mgmt.test", 
"#");
-            agent = fix->getBrokerAgent();
-            agent->importDeletedObjects( delObjs );
-
-            // wait for the deleted object to be published, verify the count
-
-            uint32_t countDels = 0;
-            while (r1.fetch(m1, Duration::SECOND * 6)) {
-                TestObjectVector objs;
-                decodeV2ObjectUpdates(m1, objs);
-                BOOST_CHECK(objs.size() > 0);
-
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
-
-                    TestManageable::validateTestObjectProperties(**oIter);
-
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0)
-                        countDels++;
-                }
-            }
+    BOOST_CHECK_EQUAL(msgCount, objCount);
 
-            // make sure we get the correct # of deleted objects
-            BOOST_CHECK_EQUAL(countDels, delCount);
+    // destroy some of the objects, then immediately export (before the next 
poll cycle)
 
-            // verify there are no deleted objects to export now.
+    uint32_t delCount = 0;
+    for (size_t i = 0; i < objCount; i += 2) {
+        tmv[i]->GetManagementObject()->resourceDestroy();
+        delCount++;
+    }
 
-            agent->exportDeletedObjects( delObjs );
-            BOOST_CHECK(delObjs.size() == 0);
+    ::qpid::management::ManagementAgent::DeletedObjectList delObjs;
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK_EQUAL(delObjs.size(), delCount);
+
+    // destroy the broker, and reinistantiate a new one without populating it
+    // with TestObjects.
+
+    r1.close();
+    delete fix;
+    while (tmv.size()) {
+        delete tmv.back();
+        tmv.pop_back();
+    }
 
-            r1.close();
-            delete fix;
+    fix = new AgentFixture(3, true);
+    r1 = fix->createV2DataIndRcvr("org.apache.qpid.broker.mgmt.test", "#");
+    agent = fix->getBrokerAgent();
+    agent->importDeletedObjects( delObjs );
+
+    // wait for the deleted object to be published, verify the count
+
+    uint32_t countDels = 0;
+    while (r1.fetch(m1, Duration::SECOND * 6)) {
+        TestObjectVector objs;
+        decodeV2ObjectUpdates(m1, objs);
+        BOOST_CHECK(objs.size() > 0);
+
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+
+            TestManageable::validateTestObjectProperties(**oIter);
+
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0)
+                countDels++;
         }
+    }
 
-        // See QPID-2997
-        QPID_AUTO_TEST_CASE(v2RapidRestoreObj)
-        {
-            AgentFixture* fix = new AgentFixture(3, true);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            // two objects, same ObjID
-            TestManageable *tm1 = new TestManageable(agent, 
std::string("obj2"));
-            TestManageable *tm2 = new TestManageable(agent, 
std::string("obj2"));
-
-            Receiver r1 = 
fix->createV2DataIndRcvr(tm1->GetManagementObject()->getPackageName(), "#");
-
-            // add, then immediately delete and re-add a copy of the object
-            agent->addObject(tm1->GetManagementObject(), "testobj-1");
-            tm1->GetManagementObject()->resourceDestroy();
-            agent->addObject(tm2->GetManagementObject(), "testobj-1");
-
-            // expect: a delete notification, then an update notification
-            TestObjectVector objs;
-            bool isDeleted = false;
-            bool isAdvertised = false;
-            size_t count = 0;
-            Message m1;
-            while (r1.fetch(m1, Duration::SECOND * 6)) {
-
-                decodeV2ObjectUpdates(m1, objs);
-                BOOST_CHECK(objs.size() > 0);
-
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
-                    count++;
-                    TestManageable::validateTestObjectProperties(**oIter);
-
-                    qpid::types::Variant::Map mappy;
-                    (*oIter)->writeTimestamps(mappy);
-                    if (mappy["_delete_ts"].asUint64() != 0) {
-                        isDeleted = true;
-                        BOOST_CHECK(isAdvertised == false);  // delete must be 
first
-                    } else {
-                        isAdvertised = true;
-                        BOOST_CHECK(isDeleted == true);     // delete must be 
first
-                    }
-                }
-            }
+    // make sure we get the correct # of deleted objects
+    BOOST_CHECK_EQUAL(countDels, delCount);
 
-            BOOST_CHECK(isDeleted);
-            BOOST_CHECK(isAdvertised);
-            BOOST_CHECK(count == 2);
-
-            r1.close();
-            delete fix;
-            delete tm1;
-            delete tm2;
-        }
+    // verify there are no deleted objects to export now.
 
-        // See QPID-2997
-        QPID_AUTO_TEST_CASE(v2DuplicateErrorObj)
-        {
-            AgentFixture* fix = new AgentFixture(3, true);
-            management::ManagementAgent* agent;
-            agent = fix->getBrokerAgent();
-
-            // turn off the expected error log message
-            qpid::log::Options logOpts;
-            logOpts.selectors.clear();
-            logOpts.selectors.push_back("critical+");
-            qpid::log::Logger::instance().configure(logOpts);
-
-            // two objects, same ObjID
-            TestManageable *tm1 = new TestManageable(agent, 
std::string("obj2"));
-            TestManageable *tm2 = new TestManageable(agent, 
std::string("obj2"));
-            // Keep a pointer to the ManagementObject.  This test simulates a 
user-caused error
-            // case (duplicate objects) where the broker has no choice but to 
leak a management
-            // object (safest assumption).  To prevent valgrind from flagging 
this leak, we
-            // manually clean up the object at the end of the test.
-            management::ManagementObject *save = tm2->GetManagementObject();
-
-            Receiver r1 = 
fix->createV2DataIndRcvr(tm1->GetManagementObject()->getPackageName(), "#");
-
-            // add, then immediately delete and re-add a copy of the object
-            agent->addObject(tm1->GetManagementObject(), "testobj-1");
-            agent->addObject(tm2->GetManagementObject(), "testobj-1");
-
-            TestObjectVector objs;
-            size_t count = 0;
-            Message m1;
-            while (r1.fetch(m1, Duration::SECOND * 6)) {
-
-                decodeV2ObjectUpdates(m1, objs);
-                BOOST_CHECK(objs.size() > 0);
-
-                for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
-                    count++;
-                    TestManageable::validateTestObjectProperties(**oIter);
-                }
-            }
+    agent->exportDeletedObjects( delObjs );
+    BOOST_CHECK(delObjs.size() == 0);
 
-            BOOST_CHECK(count == 1);    // only one should be accepted.
+    r1.close();
+    delete fix;
+}
 
-            r1.close();
-            delete fix;
-            delete tm1;
-            delete tm2;
-            delete save;
+// See QPID-2997
+QPID_AUTO_TEST_CASE(v2RapidRestoreObj)
+{
+    AgentFixture* fix = new AgentFixture(3, true);
+    management::ManagementAgent* agent;
+    agent = fix->getBrokerAgent();
+
+    // two objects, same ObjID
+    TestManageable *tm1 = new TestManageable(agent, std::string("obj2"));
+    TestManageable *tm2 = new TestManageable(agent, std::string("obj2"));
+
+    Receiver r1 = 
fix->createV2DataIndRcvr(tm1->GetManagementObject()->getPackageName(), "#");
+
+    // add, then immediately delete and re-add a copy of the object
+    agent->addObject(tm1->GetManagementObject(), "testobj-1");
+    tm1->GetManagementObject()->resourceDestroy();
+    agent->addObject(tm2->GetManagementObject(), "testobj-1");
+
+    // expect: a delete notification, then an update notification
+    TestObjectVector objs;
+    bool isDeleted = false;
+    bool isAdvertised = false;
+    size_t count = 0;
+    Message m1;
+    while (r1.fetch(m1, Duration::SECOND * 6)) {
+
+        decodeV2ObjectUpdates(m1, objs);
+        BOOST_CHECK(objs.size() > 0);
+
+        for (TestObjectVector::iterator oIter = objs.begin(); oIter != 
objs.end(); oIter++) {
+            count++;
+            TestManageable::validateTestObjectProperties(**oIter);
+
+            qpid::types::Variant::Map mappy;
+            (*oIter)->writeTimestamps(mappy);
+            if (mappy["_delete_ts"].asUint64() != 0) {
+                isDeleted = true;
+                BOOST_CHECK(isAdvertised == false);  // delete must be first
+            } else {
+                isAdvertised = true;
+                BOOST_CHECK(isDeleted == true);     // delete must be first
+            }
         }
-
-        QPID_AUTO_TEST_SUITE_END()
     }
+
+    BOOST_CHECK(isDeleted);
+    BOOST_CHECK(isAdvertised);
+    BOOST_CHECK(count == 2);
+
+    r1.close();
+    delete fix;
+    delete tm1;
+    delete tm2;
+}
+
+QPID_AUTO_TEST_SUITE_END()
+}
 }
 
 

Modified: qpid/trunk/qpid/cpp/src/tests/testagent.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/testagent.cpp?rev=1398530&r1=1398529&r2=1398530&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/testagent.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/testagent.cpp Mon Oct 15 21:35:38 2012
@@ -59,7 +59,7 @@ class CoreClass : public Manageable
 {
     string           name;
     ManagementAgent* agent;
-    _qmf::Parent* mgmtObject;
+    _qmf::Parent::shared_ptr mgmtObject;
     std::vector<ChildClass*> children;
     Mutex vectorLock;
 
@@ -68,7 +68,7 @@ public:
     CoreClass(ManagementAgent* agent, string _name);
     ~CoreClass() { mgmtObject->resourceDestroy(); }
 
-    ManagementObject* GetManagementObject(void) const
+    ManagementObject::shared_ptr GetManagementObject(void) const
     { return mgmtObject; }
 
     void doLoop();
@@ -78,14 +78,14 @@ public:
 class ChildClass : public Manageable
 {
     string name;
-    _qmf::Child* mgmtObject;
+    _qmf::Child::shared_ptr mgmtObject;
 
 public:
 
     ChildClass(ManagementAgent* agent, CoreClass* parent, string name);
     ~ChildClass() { mgmtObject->resourceDestroy(); }
 
-    ManagementObject* GetManagementObject(void) const
+    ManagementObject::shared_ptr GetManagementObject(void) const
     { return mgmtObject; }
 
     void doWork()
@@ -97,9 +97,9 @@ public:
 CoreClass::CoreClass(ManagementAgent* _agent, string _name) : name(_name), 
agent(_agent)
 {
     static uint64_t persistId = 0x111222333444555LL;
-    mgmtObject = new _qmf::Parent(agent, this, name);
+    mgmtObject = _qmf::Parent::shared_ptr(new _qmf::Parent(agent, this, name));
 
-    agent->addObject(mgmtObject, persistId++);
+    agent->addObject(mgmtObject.get(), persistId++);
     mgmtObject->set_state("IDLE");
 }
 
@@ -146,9 +146,9 @@ Manageable::status_t CoreClass::Manageme
 
 ChildClass::ChildClass(ManagementAgent* agent, CoreClass* parent, string name)
 {
-    mgmtObject = new _qmf::Child(agent, this, parent, name);
+    mgmtObject = _qmf::Child::shared_ptr(new _qmf::Child(agent, this, parent, 
name));
 
-    agent->addObject(mgmtObject);
+    agent->addObject(mgmtObject.get());
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to