From b5c270f10496f522ef6a03a8fa60f85d55c9187d Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 2 Feb 2007 22:03:10 +0000 Subject: * 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 --- cpp/tests/InMemoryContentTest.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'cpp/tests/InMemoryContentTest.cpp') diff --git a/cpp/tests/InMemoryContentTest.cpp b/cpp/tests/InMemoryContentTest.cpp index 1494518578..db54ea44a0 100644 --- a/cpp/tests/InMemoryContentTest.cpp +++ b/cpp/tests/InMemoryContentTest.cpp @@ -24,6 +24,7 @@ #include #include #include "AMQFrame.h" +#include "DummyChannel.h" using std::list; using std::string; @@ -31,13 +32,6 @@ using boost::dynamic_pointer_cast; using namespace qpid::broker; using namespace qpid::framing; -struct DummyHandler : OutputHandler{ - std::vector frames; - - virtual void send(AMQFrame* frame){ - frames.push_back(frame); - } -}; class InMemoryContentTest : public CppUnit::TestCase { @@ -64,12 +58,21 @@ public: void refragment(size_t inCount, string* in, size_t outCount, string* out, u_int32_t framesize = 5) { InMemoryContent content; - DummyHandler handler; - u_int16_t channel = 3; + DummyChannel channel(3); addframes(content, inCount, in); - content.send(highestProtocolVersion, &handler, channel, framesize); - check(handler, channel, outCount, out); + content.send(channel, framesize); + CPPUNIT_ASSERT_EQUAL(outCount, channel.out.frames.size()); + + for (unsigned int i = 0; i < outCount; i++) { + AMQContentBody::shared_ptr chunk( + dynamic_pointer_cast( + channel.out.frames[i]->getBody())); + CPPUNIT_ASSERT(chunk); + CPPUNIT_ASSERT_EQUAL(out[i], chunk->getData()); + CPPUNIT_ASSERT_EQUAL( + ChannelId(3), channel.out.frames[i]->getChannel()); + } } void addframes(InMemoryContent& content, size_t frameCount, string* frameData) @@ -80,17 +83,7 @@ public: } } - void check(DummyHandler& handler, u_int16_t channel, size_t expectedChunkCount, string* expectedChunks) - { - CPPUNIT_ASSERT_EQUAL(expectedChunkCount, handler.frames.size()); - for (unsigned int i = 0; i < expectedChunkCount; i++) { - AMQContentBody::shared_ptr chunk(dynamic_pointer_cast(handler.frames[i]->getBody())); - CPPUNIT_ASSERT(chunk); - CPPUNIT_ASSERT_EQUAL(expectedChunks[i], chunk->getData()); - CPPUNIT_ASSERT_EQUAL(channel, handler.frames[i]->getChannel()); - } - } }; // Make this test suite a plugin. -- cgit v1.2.1