You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2007/08/14 16:29:16 UTC
svn commit: r565770 - in /incubator/qpid/trunk/qpid/cpp/src: ./ qpid/broker/
qpid/cluster/ qpid/framing/ tests/
Author: aconway
Date: Tue Aug 14 07:29:07 2007
New Revision: 565770
URL: http://svn.apache.org/viewvc?view=rev&rev=565770
Log:
Deleted following files that are obsolete for 0-10:
src/qpid/framing/AMQRequestBody.cpp
src/qpid/framing/AMQRequestBody.h
src/qpid/framing/AMQResponseBody.cpp
src/qpid/framing/AMQResponseBody.h
src/qpid/framing/Correlator.cpp
src/qpid/framing/Correlator.h
src/qpid/framing/MethodContext.cpp
src/qpid/framing/Requester.cpp
src/qpid/framing/Requester.h
src/qpid/framing/Responder.cpp
src/qpid/framing/Responder.h
Made changes to support their deletion.
Removed:
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQRequestBody.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQRequestBody.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQResponseBody.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQResponseBody.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Correlator.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Correlator.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Requester.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Requester.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Responder.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Responder.h
Modified:
incubator/qpid/trunk/qpid/cpp/src/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionAdapter.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Frame.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.h
incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Tue Aug 14 07:29:07 2007
@@ -135,15 +135,12 @@
libqpidcommon_la_SOURCES = \
$(platform_src) \
qpid/framing/AMQBody.cpp \
- qpid/framing/AMQRequestBody.cpp \
- qpid/framing/AMQResponseBody.cpp \
qpid/framing/AMQContentBody.cpp \
qpid/framing/AMQFrame.cpp \
qpid/framing/AMQHeaderBody.cpp \
qpid/framing/AMQHeartbeatBody.cpp \
qpid/framing/AMQMethodBody.cpp \
qpid/framing/FrameHandler.h \
- qpid/framing/MethodContext.cpp \
qpid/framing/BasicHeaderProperties.cpp \
qpid/framing/BodyHandler.cpp \
qpid/framing/ChannelAdapter.cpp \
@@ -154,11 +151,8 @@
qpid/framing/ProtocolInitiation.cpp \
qpid/framing/ProtocolVersion.cpp \
qpid/framing/ProtocolVersionException.cpp \
- qpid/framing/Requester.cpp \
- qpid/framing/Responder.cpp \
qpid/framing/SequenceNumber.cpp \
qpid/framing/SequenceNumberSet.cpp \
- qpid/framing/Correlator.cpp \
qpid/framing/Value.cpp \
qpid/framing/Proxy.cpp \
qpid/framing/Uuid.cpp \
@@ -366,13 +360,10 @@
qpid/framing/AMQHeaderBody.h \
qpid/framing/AMQHeartbeatBody.h \
qpid/framing/AMQMethodBody.h \
- qpid/framing/AMQRequestBody.h \
- qpid/framing/AMQResponseBody.h \
qpid/framing/BasicHeaderProperties.h \
qpid/framing/BodyHandler.h \
qpid/framing/Buffer.h \
qpid/framing/ChannelAdapter.h \
- qpid/framing/Correlator.h \
qpid/framing/FieldTable.h \
qpid/framing/FramingContent.h \
qpid/framing/HeaderProperties.h \
@@ -385,8 +376,6 @@
qpid/framing/ProtocolVersion.h \
qpid/framing/ProtocolVersionException.h \
qpid/framing/Proxy.h \
- qpid/framing/Requester.h \
- qpid/framing/Responder.h \
qpid/framing/SerializeHandler.h \
qpid/framing/SequenceNumber.h \
qpid/framing/SequenceNumberSet.h \
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionAdapter.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionAdapter.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionAdapter.cpp Tue Aug 14 07:29:07 2007
@@ -50,14 +50,10 @@
)
{
try{
- handler->client.setResponseTo(context.getRequestId());
method->invoke(*this, context);
- handler->client.setResponseTo(0);
}catch(ConnectionException& e){
- handler->client.setResponseTo(0);
handler->client.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId());
}catch(std::exception& e){
- handler->client.setResponseTo(0);
handler->client.close(541/*internal error*/, e.what(), method->amqpClassId(), method->amqpMethodId());
}
}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp Tue Aug 14 07:29:07 2007
@@ -162,10 +162,9 @@
MessageTransferBody::shared_ptr transfer(
boost::shared_polymorphic_downcast<MessageTransferBody>(
context.methodBody));
- RequestId requestId = context.getRequestId();
if (transfer->getBody().isInline()) {
- MessageMessage::shared_ptr message(new MessageMessage(&connection, requestId, transfer));
+ MessageMessage::shared_ptr message(new MessageMessage(&connection, 0, transfer));
channel.handleInlineTransfer(message);
} else {
throw ConnectionException(540, "References no longer supported");
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp Tue Aug 14 07:29:07 2007
@@ -171,16 +171,16 @@
msg->deliver(*this, tag, token, connection.getFrameMax());
}
-RequestId SemanticHandler::send(shared_ptr<AMQBody> body, Correlator::Action action)
+RequestId SemanticHandler::send(shared_ptr<AMQBody> body)
{
Mutex::ScopedLock l(outLock);
uint8_t type(body->type());
- if (type == REQUEST_BODY || type == RESPONSE_BODY || type == METHOD_BODY) {
+ if (type == METHOD_BODY) {
//temporary hack until channel management is moved to its own handler:
if (dynamic_pointer_cast<AMQMethodBody>(body)->amqpClassId() != ChannelOpenBody::CLASS_ID) {
++outgoing.hwm;
//std::cout << "[" << this << "] allocated: " << outgoing.hwm.getValue() << " to " << *body << std::endl;
}
}
- return ChannelAdapter::send(body, action);
+ return ChannelAdapter::send(body);
}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h Tue Aug 14 07:29:07 2007
@@ -59,7 +59,7 @@
void handleContent(boost::shared_ptr<qpid::framing::AMQContentBody>);
void handleHeartbeat(boost::shared_ptr<qpid::framing::AMQHeartbeatBody>);
- framing::RequestId send(shared_ptr<framing::AMQBody> body, framing::Correlator::Action action=framing::Correlator::Action());
+ framing::RequestId send(shared_ptr<framing::AMQBody> body);
//delivery adapter methods:
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/SessionManager.cpp Tue Aug 14 07:29:07 2007
@@ -67,7 +67,7 @@
virtual bool isOpen() const{ return true; }
virtual void handleMethodInContext(shared_ptr<AMQMethodBody>, const MethodContext&){}
// No-op send.
- virtual RequestId send(shared_ptr<AMQBody>, Correlator::Action) { return 0; }
+ virtual RequestId send(shared_ptr<AMQBody>) { return 0; }
//delivery adapter methods, also no-ops:
virtual DeliveryId deliver(Message::shared_ptr&, DeliveryToken::shared_ptr) { return 0; }
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp Tue Aug 14 07:29:07 2007
@@ -23,8 +23,7 @@
#include "AMQFrame.h"
#include "qpid/QpidError.h"
-#include "AMQRequestBody.h"
-#include "AMQResponseBody.h"
+#include "AMQMethodBody.h"
namespace qpid {
@@ -90,12 +89,6 @@
{
case METHOD_BODY:
body = AMQMethodBody::create(versionMap, version, buffer);
- break;
- case REQUEST_BODY:
- body = AMQRequestBody::create(versionMap, version, buffer);
- break;
- case RESPONSE_BODY:
- body = AMQResponseBody::create(versionMap, version, buffer);
break;
case HEADER_BODY:
body = AMQBody::shared_ptr(new AMQHeaderBody());
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp Tue Aug 14 07:29:07 2007
@@ -20,8 +20,6 @@
*/
#include "qpid/QpidError.h"
#include "BodyHandler.h"
-#include "AMQRequestBody.h"
-#include "AMQResponseBody.h"
#include "AMQMethodBody.h"
#include "AMQHeaderBody.h"
#include "AMQContentBody.h"
@@ -35,12 +33,6 @@
void BodyHandler::handleBody(shared_ptr<AMQBody> body) {
switch(body->type())
{
- case REQUEST_BODY:
- handleRequest(shared_polymorphic_cast<AMQRequestBody>(body));
- break;
- case RESPONSE_BODY:
- handleResponse(shared_polymorphic_cast<AMQResponseBody>(body));
- break;
case METHOD_BODY:
handleMethod(shared_polymorphic_cast<AMQMethodBody>(body));
break;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.h Tue Aug 14 07:29:07 2007
@@ -24,14 +24,9 @@
#include <boost/shared_ptr.hpp>
-#include "Requester.h"
-#include "Responder.h"
-
namespace qpid {
namespace framing {
-
-class AMQRequestBody;
-class AMQResponseBody;
+class AMQBody;
class AMQMethodBody;
class AMQHeaderBody;
class AMQContentBody;
@@ -47,8 +42,6 @@
virtual void handleBody(boost::shared_ptr<AMQBody> body);
protected:
- virtual void handleRequest(boost::shared_ptr<AMQRequestBody>) = 0;
- virtual void handleResponse(boost::shared_ptr<AMQResponseBody>) = 0;
virtual void handleMethod(boost::shared_ptr<AMQMethodBody>) = 0;
virtual void handleHeader(boost::shared_ptr<AMQHeaderBody>) = 0;
virtual void handleContent(boost::shared_ptr<AMQContentBody>) = 0;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.cpp Tue Aug 14 07:29:07 2007
@@ -44,53 +44,13 @@
handlers.out= make_shared_ptr(new OutputHandlerFrameHandler(out));
}
-RequestId ChannelAdapter::send(
- shared_ptr<AMQBody> body, Correlator::Action action)
+RequestId ChannelAdapter::send(shared_ptr<AMQBody> body)
{
RequestId requestId = 0;
assertChannelOpen();
- switch (body->type()) {
- case REQUEST_BODY: {
- AMQRequestBody::shared_ptr request =
- boost::shared_polymorphic_downcast<AMQRequestBody>(body);
- requester.sending(request->getData());
- requestId = request->getData().requestId;
- if (!action.empty())
- correlator.request(requestId, action);
- break;
- }
- case RESPONSE_BODY: {
- AMQResponseBody::shared_ptr response =
- boost::shared_polymorphic_downcast<AMQResponseBody>(body);
- responder.sending(response->getData());
- break;
- }
- // No action required for other body types.
- }
AMQFrame frame(getVersion(), getId(), body);
handlers.out->handle(frame);
return requestId;
-}
-
-void ChannelAdapter::handleRequest(AMQRequestBody::shared_ptr request) {
- assertMethodOk(*request);
- AMQRequestBody::Data& requestData = request->getData();
- responder.received(requestData);
- handleMethodInContext(request, MethodContext(this, request));
-}
-
-void ChannelAdapter::handleResponse(AMQResponseBody::shared_ptr response) {
- assertMethodOk(*response);
- AMQResponseBody::Data& responseData = response->getData();
-
- // FIXME aconway 2007-04-05: processed should be last
- // but causes problems with InProcessBroker tests because
- // we execute client code in handleMethod.
- // Need to introduce a queue & 2 threads for inprocess.
- requester.processed(responseData);
- // FIXME aconway 2007-04-04: exception handling.
- correlator.response(response);
- handleMethod(response);
}
void ChannelAdapter::handleMethod(AMQMethodBody::shared_ptr method) {
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ChannelAdapter.h Tue Aug 14 07:29:07 2007
@@ -27,9 +27,7 @@
#include "qpid/shared_ptr.h"
#include "BodyHandler.h"
-#include "Requester.h"
-#include "Responder.h"
-#include "Correlator.h"
+#include "ProtocolVersion.h"
#include "amqp_types.h"
#include "FrameHandler.h"
@@ -37,6 +35,7 @@
namespace framing {
class MethodContext;
+class OutputHandler;
/**
* Base class for client and broker channels.
@@ -71,19 +70,12 @@
/**
* Send a frame.
*@param body Body of the frame.
- *@param action optional action to execute when we receive a
- *response to this frame. Ignored if body is not a Request.
*@return If body is a request, the ID assigned else 0.
*/
- virtual RequestId send(shared_ptr<AMQBody> body,
- Correlator::Action action=Correlator::Action());
+ virtual RequestId send(shared_ptr<AMQBody> body);
virtual bool isOpen() const = 0;
- RequestId getFirstAckRequest() { return requester.getFirstAckRequest(); }
- RequestId getLastAckRequest() { return requester.getLastAckRequest(); }
- RequestId getNextSendRequestId() { return requester.getNextId(); }
-
protected:
void assertMethodOk(AMQMethodBody& method) const;
void assertChannelOpen() const;
@@ -98,14 +90,9 @@
friend class ChannelAdapterHandler;
void handleMethod(shared_ptr<AMQMethodBody>);
- void handleRequest(shared_ptr<AMQRequestBody>);
- void handleResponse(shared_ptr<AMQResponseBody>);
ChannelId id;
ProtocolVersion version;
- Requester requester;
- Responder responder;
- Correlator correlator;
FrameHandler::Chains handlers;
};
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Frame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Frame.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Frame.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Frame.cpp Tue Aug 14 07:29:07 2007
@@ -22,8 +22,6 @@
#include "Frame.h"
#include "qpid/QpidError.h"
-#include "AMQRequestBody.h"
-#include "AMQResponseBody.h"
namespace qpid {
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h Tue Aug 14 07:29:07 2007
@@ -26,6 +26,8 @@
namespace qpid {
namespace framing {
+class Buffer;
+
enum discriminator_types { INLINE = 0, REFERENCE = 1 };
/**
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.h?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodContext.h Tue Aug 14 07:29:07 2007
@@ -59,12 +59,6 @@
* It's also provides the request ID when constructing a response.
*/
BodyPtr methodBody;
-
- /**
- * Return methodBody's request ID.
- * It is an error to call this if methodBody is not a request.
- */
- RequestId getRequestId() const;
};
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp?view=diff&rev=565770&r1=565769&r2=565770
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/FramingTest.cpp Tue Aug 14 07:29:07 2007
@@ -27,16 +27,11 @@
#include <typeinfo>
#include "qpid/QpidError.h"
#include "qpid/framing/AMQP_HighestVersion.h"
-#include "qpid/framing/AMQRequestBody.h"
-#include "qpid/framing/AMQResponseBody.h"
-#include "qpid/framing/Requester.h"
-#include "qpid/framing/Responder.h"
#include "InProcessBroker.h"
#include "qpid/client/Connection.h"
#include "qpid/client/Connector.h"
#include "qpid/client/ClientExchange.h"
#include "qpid/client/ClientQueue.h"
-#include "qpid/framing/Correlator.h"
#include "qpid/framing/BasicGetOkBody.h"
#include <memory>
#include <boost/lexical_cast.hpp>
@@ -64,11 +59,6 @@
CPPUNIT_TEST(testBasicConsumeBody);
CPPUNIT_TEST(testConnectionRedirectBodyFrame);
CPPUNIT_TEST(testBasicConsumeOkBodyFrame);
- CPPUNIT_TEST(testRequestBodyFrame);
- CPPUNIT_TEST(testResponseBodyFrame);
- CPPUNIT_TEST(testRequester);
- CPPUNIT_TEST(testResponder);
- CPPUNIT_TEST(testCorrelator);
CPPUNIT_TEST(testInlineContent);
CPPUNIT_TEST(testContentReference);
CPPUNIT_TEST(testContentValidation);
@@ -168,32 +158,6 @@
}
}
- void testRequestBodyFrame() {
- std::string testing("testing");
- AMQBody::shared_ptr request(new ChannelOpenBody(version, testing));
- AMQFrame in(version, 999, request);
- in.encode(buffer);
- buffer.flip();
- AMQFrame out;
- out.decode(buffer);
- ChannelOpenBody* decoded =
- dynamic_cast<ChannelOpenBody*>(out.getBody().get());
- CPPUNIT_ASSERT(decoded);
- CPPUNIT_ASSERT_EQUAL(testing, decoded->getOutOfBand());
- }
-
- void testResponseBodyFrame() {
- AMQBody::shared_ptr response(new ChannelOpenOkBody(version));
- AMQFrame in(version, 999, response);
- in.encode(buffer);
- buffer.flip();
- AMQFrame out;
- out.decode(buffer);
- ChannelOpenOkBody* decoded =
- dynamic_cast<ChannelOpenOkBody*>(out.getBody().get());
- CPPUNIT_ASSERT(decoded);
- }
-
void testInlineContent() {
Content content(INLINE, "MyData");
CPPUNIT_ASSERT(content.isInline());
@@ -245,140 +209,6 @@
CPPUNIT_ASSERT_EQUAL(string("Invalid discriminator: 2"), e.msg);
}
- }
-
- void testRequester() {
- Requester r;
- AMQRequestBody::Data q;
- AMQResponseBody::Data p;
-
- r.sending(q);
- CPPUNIT_ASSERT_EQUAL(RequestId(1), q.requestId);
- CPPUNIT_ASSERT_EQUAL(ResponseId(0), q.responseMark);
-
- r.sending(q);
- CPPUNIT_ASSERT_EQUAL(RequestId(2), q.requestId);
- CPPUNIT_ASSERT_EQUAL(ResponseId(0), q.responseMark);
-
- // Now process a response
- p.responseId = 1;
- p.requestId = 2;
- r.processed(AMQResponseBody::Data(1, 2));
-
- r.sending(q);
- CPPUNIT_ASSERT_EQUAL(RequestId(3), q.requestId);
- CPPUNIT_ASSERT_EQUAL(ResponseId(1), q.responseMark);
-
- try {
- r.processed(p); // Already processed this response.
- CPPUNIT_FAIL("Expected exception");
- } catch (...) {}
-
- try {
- p.requestId = 50;
- r.processed(p); // No such request
- CPPUNIT_FAIL("Expected exception");
- } catch (...) {}
-
- r.sending(q); // reqId=4
- r.sending(q); // reqId=5
- r.sending(q); // reqId=6
- p.responseId++;
- p.requestId = 4;
- p.batchOffset = 2;
- r.processed(p);
- r.sending(q);
- CPPUNIT_ASSERT_EQUAL(RequestId(7), q.requestId);
- CPPUNIT_ASSERT_EQUAL(ResponseId(2), q.responseMark);
-
- p.responseId++;
- p.requestId = 1; // Out of order
- p.batchOffset = 0;
- r.processed(p);
- r.sending(q);
- CPPUNIT_ASSERT_EQUAL(RequestId(8), q.requestId);
- CPPUNIT_ASSERT_EQUAL(ResponseId(3), q.responseMark);
- }
-
- void testResponder() {
- Responder r;
- AMQRequestBody::Data q;
- AMQResponseBody::Data p;
-
- q.requestId = 1;
- q.responseMark = 0;
- r.received(q);
- p.requestId = q.requestId;
- r.sending(p);
- CPPUNIT_ASSERT_EQUAL(ResponseId(1), p.responseId);
- CPPUNIT_ASSERT_EQUAL(RequestId(1), p.requestId);
- CPPUNIT_ASSERT_EQUAL(0U, p.batchOffset);
- CPPUNIT_ASSERT_EQUAL(ResponseId(0), r.getResponseMark());
-
- q.requestId++;
- q.responseMark = 1;
- r.received(q);
- r.sending(p);
- CPPUNIT_ASSERT_EQUAL(ResponseId(2), p.responseId);
- CPPUNIT_ASSERT_EQUAL(0U, p.batchOffset);
- CPPUNIT_ASSERT_EQUAL(ResponseId(1), r.getResponseMark());
-
- try {
- // Response mark higher any request ID sent.
- q.responseMark = 3;
- r.received(q);
- } catch(...) {}
-
- try {
- // Response mark lower than previous response mark.
- q.responseMark = 0;
- r.received(q);
- } catch(...) {}
-
- // TODO aconway 2007-01-14: Test for batching when supported.
-
- }
-
-
- std::vector<Correlator::ResponsePtr> correlations;
-
- void correlatorCallback(Correlator::ResponsePtr r) {
- correlations.push_back(r);
- }
-
- struct DummyResponse : public AMQResponseBody {
- DummyResponse(ResponseId id=0, RequestId req=0, BatchOffset off=0)
- : AMQResponseBody(version, id, req, off) {}
- uint32_t size() const { return 0; }
- void print(std::ostream&) const {}
- MethodId amqpMethodId() const { return 0; }
- ClassId amqpClassId() const { return 0; }
- void encodeContent(Buffer& ) const {}
- void decodeContent(Buffer& ) {}
- };
-
- void testCorrelator() {
- CPPUNIT_ASSERT(correlations.empty());
- Correlator c;
- Correlator::Action action = boost::bind(&FramingTest::correlatorCallback, this, _1);
- c.request(5, action);
- Correlator::ResponsePtr r1(new DummyResponse(3, 5, 0));
- CPPUNIT_ASSERT(c.response(r1));
- CPPUNIT_ASSERT_EQUAL(size_t(1), correlations.size());
- CPPUNIT_ASSERT(correlations.front() == r1);
- correlations.clear();
-
- c.request(6, action);
- c.request(7, action);
- c.request(8, action);
- Correlator::ResponsePtr r2(new DummyResponse(4, 6, 3));
- CPPUNIT_ASSERT(c.response(r2));
- CPPUNIT_ASSERT_EQUAL(size_t(3), correlations.size());
- CPPUNIT_ASSERT(r2 == correlations[0]);
- CPPUNIT_ASSERT(r2 == correlations[1]);
- CPPUNIT_ASSERT(r2 == correlations[2]);
- Correlator::ResponsePtr r3(new DummyResponse(5, 99, 0));
- CPPUNIT_ASSERT(!c.response(r3));
}
// expect may contain null chars so use string(ptr,size) constructor