diff options
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/BrokerChannelTest.cpp | 28 | ||||
-rw-r--r-- | cpp/src/tests/ExchangeTest.cpp | 2 | ||||
-rw-r--r-- | cpp/src/tests/MessageTest.cpp | 4 | ||||
-rw-r--r-- | cpp/src/tests/MessageUtils.h | 11 | ||||
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 26 | ||||
-rw-r--r-- | cpp/src/tests/TxAckTest.cpp | 5 | ||||
-rw-r--r-- | cpp/src/tests/TxPublishTest.cpp | 4 |
7 files changed, 41 insertions, 39 deletions
diff --git a/cpp/src/tests/BrokerChannelTest.cpp b/cpp/src/tests/BrokerChannelTest.cpp index f0ccf73189..8752b8afeb 100644 --- a/cpp/src/tests/BrokerChannelTest.cpp +++ b/cpp/src/tests/BrokerChannelTest.cpp @@ -59,16 +59,16 @@ struct MockHandler : ConnectionOutputHandler{ struct DeliveryRecorder : DeliveryAdapter { DeliveryId id; - typedef std::pair<Message::shared_ptr, DeliveryToken::shared_ptr> Delivery; + typedef std::pair<intrusive_ptr<Message>, DeliveryToken::shared_ptr> Delivery; std::vector<Delivery> delivered; - DeliveryId deliver(Message::shared_ptr& msg, DeliveryToken::shared_ptr token) + DeliveryId deliver(intrusive_ptr<Message>& msg, DeliveryToken::shared_ptr token) { delivered.push_back(Delivery(msg, token)); return ++id; } - void redeliver(Message::shared_ptr& msg, DeliveryToken::shared_ptr token, DeliveryId /*tag*/) + void redeliver(intrusive_ptr<Message>& msg, DeliveryToken::shared_ptr token, DeliveryId /*tag*/) { delivered.push_back(Delivery(msg, token)); } @@ -215,7 +215,7 @@ class BrokerChannelTest : public CppUnit::TestCase void testDeliveryNoAck(){ Channel channel(connection, recorder, 7); - Message::shared_ptr msg(createMessage("test", "my_routing_key", "my_message_id", 14)); + intrusive_ptr<Message> msg(createMessage("test", "my_routing_key", "my_message_id", 14)); Queue::shared_ptr queue(new Queue("my_queue")); string tag("test"); DeliveryToken::shared_ptr token(MessageDelivery::getBasicConsumeToken("my-token")); @@ -239,9 +239,9 @@ class BrokerChannelTest : public CppUnit::TestCase const string data1("abcd"); const string data2("efghijk"); const string data3("lmnopqrstuvwxyz"); - Message::shared_ptr msg1(createMessage("e", "A", "MsgA", data1.size())); - Message::shared_ptr msg2(createMessage("e", "B", "MsgB", data2.size())); - Message::shared_ptr msg3(createMessage("e", "C", "MsgC", data3.size())); + intrusive_ptr<Message> msg1(createMessage("e", "A", "MsgA", data1.size())); + intrusive_ptr<Message> msg2(createMessage("e", "B", "MsgB", data2.size())); + intrusive_ptr<Message> msg3(createMessage("e", "C", "MsgC", data3.size())); addContent(msg1, data1); addContent(msg2, data2); addContent(msg3, data3); @@ -261,7 +261,7 @@ class BrokerChannelTest : public CppUnit::TestCase queue->deliver(msg3); sleep(2); - Message::shared_ptr next = queue->dequeue().payload; + intrusive_ptr<Message> next = queue->dequeue().payload; CPPUNIT_ASSERT_EQUAL(msg1, next); CPPUNIT_ASSERT_EQUAL((uint32_t) data1.size(), next->encodedContentSize()); next = queue->dequeue().payload; @@ -289,7 +289,7 @@ class BrokerChannelTest : public CppUnit::TestCase MockMessageStore store; {//must ensure that store is last thing deleted const string data1("abcd"); - Message::shared_ptr msg1(createMessage("e", "A", "MsgA", data1.size())); + intrusive_ptr<Message> msg1(createMessage("e", "A", "MsgA", data1.size())); addContent(msg1, data1); Queue::shared_ptr queue1(new Queue("my_queue1", false, &store, 0)); @@ -300,7 +300,7 @@ class BrokerChannelTest : public CppUnit::TestCase queue3->deliver(msg1); sleep(2); - Message::shared_ptr next = queue1->dequeue().payload; + intrusive_ptr<Message> next = queue1->dequeue().payload; CPPUNIT_ASSERT_EQUAL(msg1, next); next = queue2->dequeue().payload; CPPUNIT_ASSERT_EQUAL(msg1, next); @@ -327,7 +327,7 @@ class BrokerChannelTest : public CppUnit::TestCase channel.flow(false); //'publish' a message - Message::shared_ptr msg(createMessage("test", "my_routing_key", "my_message_id", 14)); + intrusive_ptr<Message> msg(createMessage("test", "my_routing_key", "my_message_id", 14)); addContent(msg, "abcdefghijklmn"); queue->deliver(msg); @@ -342,9 +342,9 @@ class BrokerChannelTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(token, recorder.delivered.front().second); } - Message::shared_ptr createMessage(const string& exchange, const string& routingKey, const string& messageId, uint64_t contentSize) + intrusive_ptr<Message> createMessage(const string& exchange, const string& routingKey, const string& messageId, uint64_t contentSize) { - Message::shared_ptr msg(new Message()); + intrusive_ptr<Message> msg(new Message()); AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); AMQFrame header(0, AMQHeaderBody()); @@ -358,7 +358,7 @@ class BrokerChannelTest : public CppUnit::TestCase return msg; } - void addContent(Message::shared_ptr msg, const string& data) + void addContent(intrusive_ptr<Message> msg, const string& data) { AMQFrame content(0, AMQContentBody(data)); msg->getFrames().append(content); diff --git a/cpp/src/tests/ExchangeTest.cpp b/cpp/src/tests/ExchangeTest.cpp index 35fc5e0bdb..d1eca203c6 100644 --- a/cpp/src/tests/ExchangeTest.cpp +++ b/cpp/src/tests/ExchangeTest.cpp @@ -64,7 +64,7 @@ class ExchangeTest : public CppUnit::TestCase queue.reset(); queue2.reset(); - Message::shared_ptr msgPtr(MessageUtils::createMessage("exchange", "key", "id")); + intrusive_ptr<Message> msgPtr(MessageUtils::createMessage("exchange", "key", "id")); DeliverableMessage msg(msgPtr); topic.route(msg, "abc", 0); direct.route(msg, "abc", 0); diff --git a/cpp/src/tests/MessageTest.cpp b/cpp/src/tests/MessageTest.cpp index 3d3de5e9d0..f5239165b0 100644 --- a/cpp/src/tests/MessageTest.cpp +++ b/cpp/src/tests/MessageTest.cpp @@ -49,7 +49,7 @@ class MessageTest : public CppUnit::TestCase string data1("abcdefg"); string data2("hijklmn"); - Message::shared_ptr msg(new Message()); + intrusive_ptr<Message> msg(new Message()); AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); AMQFrame header(0, AMQHeaderBody()); @@ -77,7 +77,7 @@ class MessageTest : public CppUnit::TestCase msg->encode(wbuffer); Buffer rbuffer(buff, msg->encodedSize()); - msg.reset(new Message()); + msg = new Message(); msg->decodeHeader(rbuffer); msg->decodeContent(rbuffer); CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchangeName()); diff --git a/cpp/src/tests/MessageUtils.h b/cpp/src/tests/MessageUtils.h index 7fb1755c4b..cf0f130fa6 100644 --- a/cpp/src/tests/MessageUtils.h +++ b/cpp/src/tests/MessageUtils.h @@ -23,15 +23,16 @@ #include "qpid/broker/MessageDelivery.h" #include "qpid/framing/AMQFrame.h" -using namespace qpid::broker; -using namespace qpid::framing; +using namespace qpid; +using namespace broker; +using namespace framing; struct MessageUtils { - static Message::shared_ptr createMessage(const string& exchange, const string& routingKey, + static intrusive_ptr<Message> createMessage(const string& exchange, const string& routingKey, const string& messageId, uint64_t contentSize = 0) { - Message::shared_ptr msg(new Message()); + intrusive_ptr<Message> msg(new Message()); AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); AMQFrame header(0, AMQHeaderBody()); @@ -45,7 +46,7 @@ struct MessageUtils return msg; } - static void addContent(Message::shared_ptr msg, const string& data) + static void addContent(intrusive_ptr<Message> msg, const string& data) { AMQFrame content(0, AMQContentBody(data)); msg->getFrames().append(content); diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index 3235fe2418..2d84d23b6f 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -38,7 +38,7 @@ class TestConsumer : public virtual Consumer{ public: typedef shared_ptr<TestConsumer> shared_ptr; - Message::shared_ptr last; + intrusive_ptr<Message> last; bool received; TestConsumer(): received(false) {}; @@ -71,8 +71,8 @@ class QueueTest : public CppUnit::TestCase public: - Message::shared_ptr message(std::string exchange, std::string routingKey) { - Message::shared_ptr msg(new Message()); + intrusive_ptr<Message> message(std::string exchange, std::string routingKey) { + intrusive_ptr<Message> msg(new Message()); AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0)); AMQFrame header(0, AMQHeaderBody()); msg->getFrames().append(method); @@ -85,14 +85,14 @@ class QueueTest : public CppUnit::TestCase void testAsyncMessage(){ Queue::shared_ptr queue(new Queue("my_test_queue", true)); - Message::shared_ptr received; + intrusive_ptr<Message> received; TestConsumer::shared_ptr c1(new TestConsumer()); queue->consume(c1); //Test basic delivery: - Message::shared_ptr msg1 = message("e", "A"); + intrusive_ptr<Message> msg1 = message("e", "A"); msg1->enqueueAsync();//this is done on enqueue which is not called from process queue->process(msg1); sleep(2); @@ -109,7 +109,7 @@ class QueueTest : public CppUnit::TestCase void testAsyncMessageCount(){ Queue::shared_ptr queue(new Queue("my_test_queue", true)); - Message::shared_ptr msg1 = message("e", "A"); + intrusive_ptr<Message> msg1 = message("e", "A"); msg1->enqueueAsync();//this is done on enqueue which is not called from process queue->process(msg1); @@ -134,9 +134,9 @@ class QueueTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(uint32_t(2), queue->getConsumerCount()); //Test basic delivery: - Message::shared_ptr msg1 = message("e", "A"); - Message::shared_ptr msg2 = message("e", "B"); - Message::shared_ptr msg3 = message("e", "C"); + intrusive_ptr<Message> msg1 = message("e", "A"); + intrusive_ptr<Message> msg2 = message("e", "B"); + intrusive_ptr<Message> msg3 = message("e", "C"); queue->deliver(msg1); if (!c1->received) @@ -183,10 +183,10 @@ class QueueTest : public CppUnit::TestCase void testDequeue(){ Queue::shared_ptr queue(new Queue("my_queue", true)); - Message::shared_ptr msg1 = message("e", "A"); - Message::shared_ptr msg2 = message("e", "B"); - Message::shared_ptr msg3 = message("e", "C"); - Message::shared_ptr received; + intrusive_ptr<Message> msg1 = message("e", "A"); + intrusive_ptr<Message> msg2 = message("e", "B"); + intrusive_ptr<Message> msg3 = message("e", "C"); + intrusive_ptr<Message> received; queue->deliver(msg1); queue->deliver(msg2); diff --git a/cpp/src/tests/TxAckTest.cpp b/cpp/src/tests/TxAckTest.cpp index dd57736a0c..495b8b550e 100644 --- a/cpp/src/tests/TxAckTest.cpp +++ b/cpp/src/tests/TxAckTest.cpp @@ -29,6 +29,7 @@ using std::list; using std::vector; +using namespace qpid; using namespace qpid::broker; using namespace qpid::framing; @@ -58,7 +59,7 @@ class TxAckTest : public CppUnit::TestCase AccumulatedAck acked; TestMessageStore store; Queue::shared_ptr queue; - vector<Message::shared_ptr> messages; + vector<intrusive_ptr<Message> > messages; list<DeliveryRecord> deliveries; TxAck op; @@ -68,7 +69,7 @@ public: TxAckTest() : acked(0), queue(new Queue("my_queue", false, &store, 0)), op(acked, deliveries) { for(int i = 0; i < 10; i++){ - Message::shared_ptr msg(new Message()); + intrusive_ptr<Message> msg(new Message()); AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, "exchange", 0, 0)); AMQFrame header(0, AMQHeaderBody()); msg->getFrames().append(method); diff --git a/cpp/src/tests/TxPublishTest.cpp b/cpp/src/tests/TxPublishTest.cpp index 4ec526f207..b969598f1d 100644 --- a/cpp/src/tests/TxPublishTest.cpp +++ b/cpp/src/tests/TxPublishTest.cpp @@ -63,7 +63,7 @@ class TxPublishTest : public CppUnit::TestCase TestMessageStore store; Queue::shared_ptr queue1; Queue::shared_ptr queue2; - Message::shared_ptr msg; + intrusive_ptr<Message> msg; TxPublish op; public: @@ -99,7 +99,7 @@ public: op.prepare(0); op.commit(); CPPUNIT_ASSERT_EQUAL((uint32_t) 1, queue1->getMessageCount()); - Message::shared_ptr msg_dequeue = queue1->dequeue().payload; + intrusive_ptr<Message> msg_dequeue = queue1->dequeue().payload; CPPUNIT_ASSERT_EQUAL( true, ((PersistableMessage*) msg_dequeue.get())->isEnqueueComplete()); CPPUNIT_ASSERT_EQUAL(msg, msg_dequeue); |