summaryrefslogtreecommitdiff
path: root/cpp/tests/MessageTest.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-02-02 22:03:10 +0000
committerAlan Conway <aconway@apache.org>2007-02-02 22:03:10 +0000
commitb5c270f10496f522ef6a03a8fa60f85d55c9187d (patch)
tree714e7abf7ba591d00232d821440e51461175cb9e /cpp/tests/MessageTest.cpp
parent750f272ac99e8c830807affb3ae68ab0beeca63f (diff)
downloadqpid-python-b5c270f10496f522ef6a03a8fa60f85d55c9187d.tar.gz
* cpp/lib/common/framing/MethodContext.h: Reduced MethodContext to
ChannelAdapter and Method Body. Request ID comes from body, ChannelAdapter is used to send frames, not OutputHandler. * cpp/lib/common/framing/ChannelAdapter.h,.cpp: Removed context member. Context is per-method not per-channel. * cpp/lib/broker/*: Replace direct use of OutputHandler and ChannelId with MethodContext (for responses) or ChannelAdapter (for requests.) Use context request-ID to construct responses, send all bodies via ChannelAdapter. * cpp/lib/broker/BrokerAdapter.cpp: Link broker::Channel to BrokerAdapter. * cpp/lib/broker/*: Remove unnecessary ProtocolVersion parameters. Fix bogus signatures: ProtocolVersion* -> const ProtocolVersion& * Cosmetic changes, many files: - fixed indentation, broke long lines. - removed unnecessary qpid:: prefixes. * broker/BrokerAdapter,BrokerChannel: Merged BrokerAdapter into broker::channel. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@502767 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/tests/MessageTest.cpp')
-rw-r--r--cpp/tests/MessageTest.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/cpp/tests/MessageTest.cpp b/cpp/tests/MessageTest.cpp
index 62249e1f5f..103a23f0df 100644
--- a/cpp/tests/MessageTest.cpp
+++ b/cpp/tests/MessageTest.cpp
@@ -23,19 +23,12 @@
#include <iostream>
#include <AMQP_HighestVersion.h>
#include "AMQFrame.h"
+#include "DummyChannel.h"
using namespace boost;
using namespace qpid::broker;
using namespace qpid::framing;
-struct DummyHandler : OutputHandler{
- std::vector<AMQFrame*> frames;
-
- virtual void send(AMQFrame* frame){
- frames.push_back(frame);
- }
-};
-
class MessageTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(MessageTest);
@@ -52,7 +45,9 @@ class MessageTest : public CppUnit::TestCase
string data1("abcdefg");
string data2("hijklmn");
- Message::shared_ptr msg = Message::shared_ptr(new BasicMessage(0, exchange, routingKey, false, false));
+ BasicMessage::shared_ptr msg(
+ new BasicMessage(0, exchange, routingKey, false, false,
+ DummyChannel::basicGetBody()));
AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC));
header->setContentSize(14);
AMQContentBody::shared_ptr part1(new AMQContentBody(data1));
@@ -69,7 +64,8 @@ class MessageTest : public CppUnit::TestCase
msg->encode(buffer);
buffer.flip();
- msg = Message::shared_ptr(new BasicMessage(buffer));
+ msg.reset(new BasicMessage());
+ msg->decode(buffer);
CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchange());
CPPUNIT_ASSERT_EQUAL(routingKey, msg->getRoutingKey());
CPPUNIT_ASSERT_EQUAL(messageId, msg->getHeaderProperties()->getMessageId());
@@ -77,10 +73,11 @@ class MessageTest : public CppUnit::TestCase
CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getHeaderProperties()->getHeaders().getString("abc"));
CPPUNIT_ASSERT_EQUAL((u_int64_t) 14, msg->contentSize());
- DummyHandler handler;
- msg->deliver(&handler, 0, "ignore", 0, 100, &(qpid::framing::highestProtocolVersion));
- CPPUNIT_ASSERT_EQUAL((size_t) 3, handler.frames.size());
- AMQContentBody::shared_ptr contentBody(dynamic_pointer_cast<AMQContentBody, AMQBody>(handler.frames[2]->getBody()));
+ DummyChannel channel(1);
+ // FIXME aconway 2007-02-02: deliver should take const ProtocolVersion&
+ msg->deliver(channel, "ignore", 0, 100);
+ CPPUNIT_ASSERT_EQUAL((size_t) 3, channel.out.frames.size());
+ AMQContentBody::shared_ptr contentBody(dynamic_pointer_cast<AMQContentBody, AMQBody>(channel.out.frames[2]->getBody()));
CPPUNIT_ASSERT(contentBody);
CPPUNIT_ASSERT_EQUAL(data1 + data2, contentBody->getData());
}