summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-11-09 23:30:59 +0000
committerAlan Conway <aconway@apache.org>2007-11-09 23:30:59 +0000
commite95499012b4663fdaa41a5b875be75492c1c8fb0 (patch)
treed0996eaa0bd4283431932fe085e6a8972d7598f1 /cpp/src
parentb78af32f2bb9c725bacec590dbdeecaec9b2906c (diff)
downloadqpid-python-e95499012b4663fdaa41a5b875be75492c1c8fb0.tar.gz
Get rid of BasicHeaderProperties, dead code from 0-8 protocol.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@593692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Makefile.am2
-rw-r--r--cpp/src/qpid/broker/Message.cpp7
-rw-r--r--cpp/src/qpid/broker/Message.h1
-rw-r--r--cpp/src/qpid/broker/MessageAdapter.cpp27
-rw-r--r--cpp/src/qpid/broker/MessageAdapter.h11
-rw-r--r--cpp/src/qpid/framing/AMQHeaderBody.cpp7
-rw-r--r--cpp/src/qpid/framing/AMQHeaderBody.h17
-rw-r--r--cpp/src/qpid/framing/BasicHeaderProperties.cpp136
-rw-r--r--cpp/src/qpid/framing/BasicHeaderProperties.h123
-rw-r--r--cpp/src/qpid/framing/FrameSet.cpp1
-rw-r--r--cpp/src/qpid/framing/amqp_framing.h1
-rw-r--r--cpp/src/tests/HeaderTest.cpp141
-rw-r--r--cpp/src/tests/MessageTest.cpp3
-rw-r--r--cpp/src/tests/TxAckTest.cpp2
-rw-r--r--cpp/src/tests/TxPublishTest.cpp2
-rw-r--r--cpp/src/tests/perftest.cpp4
16 files changed, 74 insertions, 411 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index 96f338e684..86986f654e 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -99,7 +99,6 @@ libqpidcommon_la_SOURCES = \
qpid/framing/AMQHeaderBody.cpp \
qpid/framing/AMQHeartbeatBody.cpp \
qpid/framing/Array.cpp \
- qpid/framing/BasicHeaderProperties.cpp \
qpid/framing/BodyHandler.cpp \
qpid/framing/ChannelAdapter.cpp \
qpid/framing/Buffer.cpp \
@@ -343,7 +342,6 @@ nobase_include_HEADERS = \
qpid/framing/AMQP_HighestVersion.h \
qpid/framing/AccumulatedAck.h \
qpid/framing/Array.h \
- qpid/framing/BasicHeaderProperties.h \
qpid/framing/Blob.h \
qpid/framing/BodyHandler.h \
qpid/framing/Buffer.h \
diff --git a/cpp/src/qpid/broker/Message.cpp b/cpp/src/qpid/broker/Message.cpp
index 4e075e73a3..0065ed397c 100644
--- a/cpp/src/qpid/broker/Message.cpp
+++ b/cpp/src/qpid/broker/Message.cpp
@@ -34,7 +34,6 @@ using namespace qpid::framing;
using std::string;
TransferAdapter Message::TRANSFER;
-PublishAdapter Message::PUBLISH;
Message::Message(const SequenceNumber& id) : frames(id), persistenceId(0), redelivered(false), loaded(false), publisher(0), adapter(0) {}
@@ -190,12 +189,12 @@ void Message::sendHeader(framing::FrameHandler& out, uint16_t /*maxFrameSize*/)
frames.map_if(f, TypeFilter(HEADER_BODY));
}
+// FIXME aconway 2007-11-09: Obsolete, remove. Was used to cover over
+// 0-8/0-9 message differences.
MessageAdapter& Message::getAdapter() const
{
if (!adapter) {
- if (frames.isA<BasicPublishBody>()) {
- adapter = &PUBLISH;
- } else if(frames.isA<MessageTransferBody>()) {
+ if(frames.isA<MessageTransferBody>()) {
adapter = &TRANSFER;
} else {
const AMQMethodBody* method = frames.getMethod();
diff --git a/cpp/src/qpid/broker/Message.h b/cpp/src/qpid/broker/Message.h
index f706a65e52..913cc759bc 100644
--- a/cpp/src/qpid/broker/Message.h
+++ b/cpp/src/qpid/broker/Message.h
@@ -130,7 +130,6 @@ public:
mutable MessageAdapter* adapter;
static TransferAdapter TRANSFER;
- static PublishAdapter PUBLISH;
MessageAdapter& getAdapter() const;
};
diff --git a/cpp/src/qpid/broker/MessageAdapter.cpp b/cpp/src/qpid/broker/MessageAdapter.cpp
index 764bf02cf4..2c29aa5444 100644
--- a/cpp/src/qpid/broker/MessageAdapter.cpp
+++ b/cpp/src/qpid/broker/MessageAdapter.cpp
@@ -28,33 +28,6 @@ namespace {
namespace qpid {
namespace broker{
- std::string PublishAdapter::getRoutingKey(const framing::FrameSet& f)
- {
- return f.as<framing::BasicPublishBody>()->getRoutingKey();
- }
-
- std::string PublishAdapter::getExchange(const framing::FrameSet& f)
- {
- return f.as<framing::BasicPublishBody>()->getExchange();
- }
-
- bool PublishAdapter::isImmediate(const framing::FrameSet& f)
- {
- return f.as<framing::BasicPublishBody>()->getImmediate();
- }
-
- const framing::FieldTable* PublishAdapter::getApplicationHeaders(const framing::FrameSet& f)
- {
- const framing::BasicHeaderProperties* p = f.getHeaders()->get<framing::BasicHeaderProperties>();
- return p ? &(p->getHeaders()) : 0;
- }
-
- bool PublishAdapter::isPersistent(const framing::FrameSet& f)
- {
- const framing::BasicHeaderProperties* p = f.getHeaders()->get<framing::BasicHeaderProperties>();
- return p && p->getDeliveryMode() == 2;
- }
-
std::string TransferAdapter::getRoutingKey(const framing::FrameSet& f)
{
const framing::DeliveryProperties* p = f.getHeaders()->get<framing::DeliveryProperties>();
diff --git a/cpp/src/qpid/broker/MessageAdapter.h b/cpp/src/qpid/broker/MessageAdapter.h
index e8337ec649..ef316edacb 100644
--- a/cpp/src/qpid/broker/MessageAdapter.h
+++ b/cpp/src/qpid/broker/MessageAdapter.h
@@ -24,7 +24,6 @@
#include <string>
#include "qpid/framing/BasicPublishBody.h"
-#include "qpid/framing/BasicHeaderProperties.h"
#include "qpid/framing/FieldTable.h"
#include "qpid/framing/FrameSet.h"
#include "qpid/framing/DeliveryProperties.h"
@@ -34,6 +33,7 @@
namespace qpid {
namespace broker {
+// FIXME aconway 2007-11-09: No longer needed, we only have one type of message.
struct MessageAdapter
{
virtual ~MessageAdapter() {}
@@ -45,15 +45,6 @@ struct MessageAdapter
virtual bool isPersistent(const framing::FrameSet& f) = 0;
};
-struct PublishAdapter : MessageAdapter
-{
- std::string getRoutingKey(const framing::FrameSet& f);
- std::string getExchange(const framing::FrameSet& f);
- bool isImmediate(const framing::FrameSet& f);
- const framing::FieldTable* getApplicationHeaders(const framing::FrameSet& f);
- bool isPersistent(const framing::FrameSet& f);
-};
-
struct TransferAdapter : MessageAdapter
{
std::string getRoutingKey(const framing::FrameSet& f);
diff --git a/cpp/src/qpid/framing/AMQHeaderBody.cpp b/cpp/src/qpid/framing/AMQHeaderBody.cpp
index 93568f5f46..8e02f6827f 100644
--- a/cpp/src/qpid/framing/AMQHeaderBody.cpp
+++ b/cpp/src/qpid/framing/AMQHeaderBody.cpp
@@ -44,9 +44,6 @@ void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, uint32_t size){
uint16_t type = buffer.getShort();
//The following switch could be generated as the number of options increases:
switch(type) {
- case BasicHeaderProperties::TYPE:
- decode(BasicHeaderProperties(), buffer, len - 2);
- break;
case MessageProperties::TYPE:
decode(MessageProperties(), buffer, len - 2);
break;
@@ -66,10 +63,6 @@ uint64_t qpid::framing::AMQHeaderBody::getContentLength() const
if (mProps) {
return mProps->getContentLength();
}
- const BasicHeaderProperties* bProps = get<BasicHeaderProperties>();
- if (bProps) {
- return bProps->getContentLength();
- }
return 0;
}
diff --git a/cpp/src/qpid/framing/AMQHeaderBody.h b/cpp/src/qpid/framing/AMQHeaderBody.h
index 9fd99bd2d9..460bd2d69e 100644
--- a/cpp/src/qpid/framing/AMQHeaderBody.h
+++ b/cpp/src/qpid/framing/AMQHeaderBody.h
@@ -21,7 +21,6 @@
#include "amqp_types.h"
#include "AMQBody.h"
#include "Buffer.h"
-#include "BasicHeaderProperties.h"
#include "qpid/framing/DeliveryProperties.h"
#include "qpid/framing/MessageProperties.h"
#include <iostream>
@@ -37,15 +36,10 @@ namespace framing {
class AMQHeaderBody : public AMQBody
{
- typedef std::vector< boost::variant<BasicHeaderProperties, DeliveryProperties, MessageProperties> > PropertyList;
+ typedef std::vector< boost::variant<DeliveryProperties, MessageProperties> > PropertyList;
PropertyList properties;
- void decode(BasicHeaderProperties s, Buffer& b, uint32_t size) {
- s.decode(b, size);
- properties.push_back(s);
- }
-
template <class T> void decode(T t, Buffer& b, uint32_t size) {
t.decodeStructBody(b, size);
properties.push_back(t);
@@ -60,11 +54,6 @@ class AMQHeaderBody : public AMQBody
t.encode(buffer);
}
- void operator()(const BasicHeaderProperties& s) const {
- buffer.putLong(s.size() + 2/*typecode*/);
- buffer.putShort(BasicHeaderProperties::TYPE);
- s.encode(buffer);
- }
};
class CalculateSize : public boost::static_visitor<> {
@@ -76,10 +65,6 @@ class AMQHeaderBody : public AMQBody
size += t.size();
}
- void operator()(const BasicHeaderProperties& s) {
- size += s.size() + 2/*typecode*/ + 4/*size field*/;
- }
-
uint32_t totalSize() {
return size;
}
diff --git a/cpp/src/qpid/framing/BasicHeaderProperties.cpp b/cpp/src/qpid/framing/BasicHeaderProperties.cpp
deleted file mode 100644
index 9d572787ae..0000000000
--- a/cpp/src/qpid/framing/BasicHeaderProperties.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "BasicHeaderProperties.h"
-
-//TODO: This could be easily generated from the spec
-
-qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(DeliveryMode(0)),
- priority(0),
- timestamp(0),
- contentLength(0){}
-qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){}
-
-uint32_t qpid::framing::BasicHeaderProperties::size() const{
- uint32_t bytes = 2;//flags
- if(contentType.length() > 0) bytes += contentType.length() + 1;
- if(contentEncoding.length() > 0) bytes += contentEncoding.length() + 1;
- if(headers.count() > 0) bytes += headers.size();
- if(deliveryMode != 0) bytes += 1;
- if(priority != 0) bytes += 1;
- if(correlationId.length() > 0) bytes += correlationId.length() + 1;
- if(replyTo.length() > 0) bytes += replyTo.length() + 1;
- if(expiration.length() > 0) bytes += expiration.length() + 1;
- if(messageId.length() > 0) bytes += messageId.length() + 1;
- if(timestamp != 0) bytes += 8;
- if(type.length() > 0) bytes += type.length() + 1;
- if(userId.length() > 0) bytes += userId.length() + 1;
- if(appId.length() > 0) bytes += appId.length() + 1;
- if(clusterId.length() > 0) bytes += clusterId.length() + 1;
- if(contentLength != 0) bytes += 8;
-
- return bytes;
-}
-
-void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{
- uint16_t flags = getFlags();
- buffer.putShort(flags);
-
- if(contentType.length() > 0) buffer.putShortString(contentType);
- if(contentEncoding.length() > 0) buffer.putShortString(contentEncoding);
- if(headers.count() > 0) buffer.put(headers);
- if(deliveryMode != 0) buffer.putOctet(deliveryMode);
- if(priority != 0) buffer.putOctet(priority);
- if(correlationId.length() > 0) buffer.putShortString(correlationId);
- if(replyTo.length() > 0) buffer.putShortString(replyTo);
- if(expiration.length() > 0) buffer.putShortString(expiration);
- if(messageId.length() > 0) buffer.putShortString(messageId);
- if(timestamp != 0) buffer.putLongLong(timestamp);;
- if(type.length() > 0) buffer.putShortString(type);
- if(userId.length() > 0) buffer.putShortString(userId);
- if(appId.length() > 0) buffer.putShortString(appId);
- if(clusterId.length() > 0) buffer.putShortString(clusterId);
- if(contentLength != 0) buffer.putLongLong(contentLength);
-}
-
-void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, uint32_t /*size*/){
- uint16_t flags = buffer.getShort();
- if(flags & (1 << 15)) buffer.getShortString(contentType);
- if(flags & (1 << 14)) buffer.getShortString(contentEncoding);
- if(flags & (1 << 13)) buffer.get(headers);
- if(flags & (1 << 12)) deliveryMode = DeliveryMode(buffer.getOctet());
- if(flags & (1 << 11)) priority = buffer.getOctet();
- if(flags & (1 << 10)) buffer.getShortString(correlationId);
- if(flags & (1 << 9)) buffer.getShortString(replyTo);
- if(flags & (1 << 8)) buffer.getShortString(expiration);
- if(flags & (1 << 7)) buffer.getShortString(messageId);
- if(flags & (1 << 6)) timestamp = buffer.getLongLong();
- if(flags & (1 << 5)) buffer.getShortString(type);
- if(flags & (1 << 4)) buffer.getShortString(userId);
- if(flags & (1 << 3)) buffer.getShortString(appId);
- if(flags & (1 << 2)) buffer.getShortString(clusterId);
- if(flags & (1 << 1)) contentLength = buffer.getLongLong();
-}
-
-uint16_t qpid::framing::BasicHeaderProperties::getFlags() const{
- uint16_t flags(0);
- if(contentType.length() > 0) flags |= (1 << 15);
- if(contentEncoding.length() > 0) flags |= (1 << 14);
- if(headers.count() > 0) flags |= (1 << 13);
- if(deliveryMode != 0) flags |= (1 << 12);
- if(priority != 0) flags |= (1 << 11);
- if(correlationId.length() > 0) flags |= (1 << 10);
- if(replyTo.length() > 0) flags |= (1 << 9);
- if(expiration.length() > 0) flags |= (1 << 8);
- if(messageId.length() > 0) flags |= (1 << 7);
- if(timestamp != 0) flags |= (1 << 6);
- if(type.length() > 0) flags |= (1 << 5);
- if(userId.length() > 0) flags |= (1 << 4);
- if(appId.length() > 0) flags |= (1 << 3);
- if(clusterId.length() > 0) flags |= (1 << 2);
- if(contentLength != 0) flags |= (1 << 1);
- return flags;
-}
-
-namespace qpid{
-namespace framing{
-
- std::ostream& operator<<(std::ostream& out, const BasicHeaderProperties& props)
- {
- if(props.contentType.length() > 0) out << "contentType=" << props.contentType << ";";
- if(props.contentEncoding.length() > 0) out << "contentEncoding=" << props.contentEncoding << ";";
- if(props.headers.count() > 0) out << "headers=" << props.headers << ";";
- if(props.deliveryMode != 0) out << "deliveryMode=" << props.deliveryMode << ";";
- if(props.priority != 0) out << "priority=" << props.priority << ";";
- if(props.correlationId.length() > 0) out << "correlationId=" << props.correlationId << ";";
- if(props.replyTo.length() > 0) out << "replyTo=" << props.replyTo << ";";
- if(props.expiration.length() > 0) out << "expiration=" << props.expiration << ";";
- if(props.messageId.length() > 0) out << "messageId=" << props.messageId << ";";
- if(props.timestamp != 0) out << "timestamp=" << props.timestamp << ";";
- if(props.type.length() > 0) out << "type=" << props.type << ";";
- if(props.userId.length() > 0) out << "userId=" << props.userId << ";";
- if(props.appId.length() > 0) out << "appId=" << props.appId << ";";
- if(props.clusterId.length() > 0) out << "clusterId=" << props.clusterId << ";";
- if(props.contentLength != 0) out << "contentLength=" << props.contentLength << ";";
-
- return out;
- }
-
-}}
diff --git a/cpp/src/qpid/framing/BasicHeaderProperties.h b/cpp/src/qpid/framing/BasicHeaderProperties.h
deleted file mode 100644
index d6c71437fb..0000000000
--- a/cpp/src/qpid/framing/BasicHeaderProperties.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "amqp_types.h"
-#include "Buffer.h"
-#include "FieldTable.h"
-#include "HeaderProperties.h"
-
-#ifndef _BasicHeaderProperties_
-#define _BasicHeaderProperties_
-
-namespace qpid {
-namespace framing {
-
-enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
-
-class BasicHeaderProperties : public HeaderProperties
-{
- string contentType;
- string contentEncoding;
- FieldTable headers;
- DeliveryMode deliveryMode;
- uint8_t priority;
- string correlationId;
- string replyTo;
- string expiration;
- string messageId;
- uint64_t timestamp;
- string type;
- string userId;
- string appId;
- string clusterId;
- uint64_t contentLength;
-
- uint16_t getFlags() const;
-
- public:
- static const uint16_t TYPE = BASIC;
-
- BasicHeaderProperties();
- virtual ~BasicHeaderProperties();
- virtual uint32_t size() const;
- virtual void encode(Buffer& buffer) const;
- virtual void decode(Buffer& buffer, uint32_t size = 0);
-
- virtual uint8_t classId() const { return BASIC; }
-
- string getContentType() const { return contentType; }
- string getContentEncoding() const { return contentEncoding; }
- FieldTable& getHeaders() { return headers; }
- const FieldTable& getHeaders() const { return headers; }
- DeliveryMode getDeliveryMode() const { return deliveryMode; }
- uint8_t getPriority() const { return priority; }
- string getCorrelationId() const {return correlationId; }
- string getReplyTo() const { return replyTo; }
- string getExpiration() const { return expiration; }
- string getMessageId() const {return messageId; }
- uint64_t getTimestamp() const { return timestamp; }
- string getType() const { return type; }
- string getUserId() const { return userId; }
- string getAppId() const { return appId; }
- string getClusterId() const { return clusterId; }
- uint64_t getContentLength() const { return contentLength; }
-
- void setContentType(const string& _type){ contentType = _type; }
- void setContentEncoding(const string& encoding){ contentEncoding = encoding; }
- void setHeaders(const FieldTable& _headers){ headers = _headers; }
- void setDeliveryMode(DeliveryMode mode){ deliveryMode = mode; }
- void setPriority(uint8_t _priority){ priority = _priority; }
- void setCorrelationId(const string& _correlationId){ correlationId = _correlationId; }
- void setReplyTo(const string& _replyTo){ replyTo = _replyTo;}
- void setExpiration(const string& _expiration){ expiration = _expiration; }
- void setMessageId(const string& _messageId){ messageId = _messageId; }
- void setTimestamp(uint64_t _timestamp){ timestamp = _timestamp; }
- void setType(const string& _type){ type = _type; }
- void setUserId(const string& _userId){ userId = _userId; }
- void setAppId(const string& _appId){appId = _appId; }
- void setClusterId(const string& _clusterId){ clusterId = _clusterId; }
- void setContentLength(uint64_t _contentLength){ contentLength = _contentLength; }
-
- friend std::ostream& operator<<(std::ostream&, const BasicHeaderProperties&);
-
- /** \internal
- * Template to copy between types like BasicHeaderProperties.
- */
- template <class T, class U>
- static void copy(T& to, const U& from) {
- to.setContentType(from.getContentType());
- to.setContentEncoding(from.getContentEncoding());
- to.setHeaders(from.getHeaders());
- to.setDeliveryMode(from.getDeliveryMode());
- to.setPriority(from.getPriority());
- to.setCorrelationId(from.getCorrelationId());
- to.setReplyTo(from.getReplyTo());
- to.setExpiration(from.getExpiration());
- to.setMessageId(from.getMessageId());
- to.setTimestamp(from.getTimestamp());
- to.setType(from.getType());
- to.setUserId(from.getUserId());
- to.setAppId(from.getAppId());
- to.setClusterId(from.getClusterId());
- to.setContentLength(from.getContentLength());
- }
-};
-}}
-#endif
diff --git a/cpp/src/qpid/framing/FrameSet.cpp b/cpp/src/qpid/framing/FrameSet.cpp
index 6db02419c2..b361076ee7 100644
--- a/cpp/src/qpid/framing/FrameSet.cpp
+++ b/cpp/src/qpid/framing/FrameSet.cpp
@@ -22,7 +22,6 @@
#include "FrameSet.h"
#include "qpid/framing/all_method_bodies.h"
#include "qpid/framing/frame_functors.h"
-#include "qpid/framing/BasicHeaderProperties.h"
#include "qpid/framing/MessageProperties.h"
#include "qpid/framing/TypeFilter.h"
diff --git a/cpp/src/qpid/framing/amqp_framing.h b/cpp/src/qpid/framing/amqp_framing.h
index 69b5942ba0..9ce148a37b 100644
--- a/cpp/src/qpid/framing/amqp_framing.h
+++ b/cpp/src/qpid/framing/amqp_framing.h
@@ -30,5 +30,4 @@
#include "OutputHandler.h"
#include "InitiationHandler.h"
#include "ProtocolInitiation.h"
-#include "BasicHeaderProperties.h"
#include "ProtocolVersion.h"
diff --git a/cpp/src/tests/HeaderTest.cpp b/cpp/src/tests/HeaderTest.cpp
index 1b21151b65..21374e30e1 100644
--- a/cpp/src/tests/HeaderTest.cpp
+++ b/cpp/src/tests/HeaderTest.cpp
@@ -24,21 +24,23 @@
#include "qpid_test_plugin.h"
using namespace qpid::framing;
+using namespace std;
class HeaderTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(HeaderTest);
CPPUNIT_TEST(testGenericProperties);
- CPPUNIT_TEST(testAllSpecificProperties);
- CPPUNIT_TEST(testSomeSpecificProperties);
+ CPPUNIT_TEST(testMessageProperties);
+ CPPUNIT_TEST(testDeliveryProperies);
CPPUNIT_TEST_SUITE_END();
-public:
+ public:
void testGenericProperties()
{
AMQHeaderBody body;
- body.get<BasicHeaderProperties>(true)->getHeaders().setString("A", "BCDE");
+ body.get<MessageProperties>(true)->getApplicationHeaders().setString(
+ "A", "BCDE");
char buff[100];
Buffer wbuffer(buff, 100);
body.encode(wbuffer);
@@ -46,44 +48,29 @@ public:
Buffer rbuffer(buff, 100);
AMQHeaderBody body2;
body2.decode(rbuffer, body.size());
- BasicHeaderProperties* props =
- body2.get<BasicHeaderProperties>(true);
- CPPUNIT_ASSERT(StringValue("BCDE") == *props->getHeaders().get("A"));
+ MessageProperties* props =
+ body2.get<MessageProperties>(true);
+ CPPUNIT_ASSERT_EQUAL(
+ string("BCDE"),
+ props->getApplicationHeaders().get("A")->get<string>());
}
- void testAllSpecificProperties(){
- string contentType("text/html");
- string contentEncoding("UTF8");
- DeliveryMode deliveryMode(PERSISTENT);
- uint8_t priority(3);
- string correlationId("abc");
- string replyTo("no-address");
- string expiration("why is this a string?");
- string messageId("xyz");
- uint64_t timestamp(0xabcd);
- string type("eh?");
- string userId("guest");
- string appId("just testing");
- string clusterId("no clustering required");
- uint64_t contentLength(54321);
-
+ void testMessageProperties() {
AMQFrame out(0, AMQHeaderBody());
- BasicHeaderProperties* properties =
- out.castBody<AMQHeaderBody>()->get<BasicHeaderProperties>(true);
- properties->setContentType(contentType);
- properties->getHeaders().setString("A", "BCDE");
- properties->setDeliveryMode(deliveryMode);
- properties->setPriority(priority);
- properties->setCorrelationId(correlationId);
- properties->setReplyTo(replyTo);
- properties->setExpiration(expiration);
- properties->setMessageId(messageId);
- properties->setTimestamp(timestamp);
- properties->setType(type);
- properties->setUserId(userId);
- properties->setAppId(appId);
- properties->setClusterId(clusterId);
- properties->setContentLength(contentLength);
+ MessageProperties* props1 =
+ out.castBody<AMQHeaderBody>()->get<MessageProperties>(true);
+
+ props1->setContentLength(42);
+ props1->setMessageId("messageId");
+ props1->setCorrelationId("correlationId");
+ props1->setReplyTo(ReplyTo("ex","key"));
+ props1->setContentType("contentType");
+ props1->setContentEncoding("contentEncoding");
+ props1->setType("type");
+ props1->setUserId("userId");
+ props1->setAppId("appId");
+ props1->setTransactionId("transactionId");
+ props1->setSecurityToken("securityToken");
char buff[10000];
Buffer wbuffer(buff, 10000);
@@ -92,55 +79,45 @@ public:
Buffer rbuffer(buff, 10000);
AMQFrame in;
in.decode(rbuffer);
- properties = in.castBody<AMQHeaderBody>()->get<BasicHeaderProperties>(true);
-
- CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType());
- CPPUNIT_ASSERT(StringValue("BCDE") == *properties->getHeaders().get("A"));
- CPPUNIT_ASSERT_EQUAL(deliveryMode, properties->getDeliveryMode());
- CPPUNIT_ASSERT_EQUAL(priority, properties->getPriority());
- CPPUNIT_ASSERT_EQUAL(correlationId, properties->getCorrelationId());
- CPPUNIT_ASSERT_EQUAL(replyTo, properties->getReplyTo());
- CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration());
- CPPUNIT_ASSERT_EQUAL(messageId, properties->getMessageId());
- CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp());
- CPPUNIT_ASSERT_EQUAL(type, properties->getType());
- CPPUNIT_ASSERT_EQUAL(userId, properties->getUserId());
- CPPUNIT_ASSERT_EQUAL(appId, properties->getAppId());
- CPPUNIT_ASSERT_EQUAL(clusterId, properties->getClusterId());
- CPPUNIT_ASSERT_EQUAL(contentLength, properties->getContentLength());
+ MessageProperties* props2 =
+ in.castBody<AMQHeaderBody>()->get<MessageProperties>(true);
+
+ CPPUNIT_ASSERT_EQUAL(props1->getContentLength(), props2->getContentLength());
+ CPPUNIT_ASSERT_EQUAL(props1->getMessageId(), props2->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(props1->getCorrelationId(), props2->getCorrelationId());
+ CPPUNIT_ASSERT_EQUAL(props1->getContentType(), props2->getContentType());
+ CPPUNIT_ASSERT_EQUAL(props1->getContentEncoding(), props2->getContentEncoding());
+ CPPUNIT_ASSERT_EQUAL(props1->getType(), props2->getType());
+ CPPUNIT_ASSERT_EQUAL(props1->getUserId(), props2->getUserId());
+ CPPUNIT_ASSERT_EQUAL(props1->getAppId(), props2->getAppId());
+ CPPUNIT_ASSERT_EQUAL(props1->getTransactionId(), props2->getTransactionId());
+ CPPUNIT_ASSERT_EQUAL(props1->getSecurityToken(), props2->getSecurityToken());
+
}
- void testSomeSpecificProperties(){
- string contentType("application/octet-stream");
- DeliveryMode deliveryMode(PERSISTENT);
- uint8_t priority(6);
- string expiration("Z");
- uint64_t timestamp(0xabe4a34a);
+ void testDeliveryProperies() {
+ AMQFrame out(0, AMQHeaderBody());
+ DeliveryProperties* props1 =
+ out.castBody<AMQHeaderBody>()->get<DeliveryProperties>(true);
- AMQHeaderBody body;
- BasicHeaderProperties* properties =
- body.get<BasicHeaderProperties>(true);
- properties->setContentType(contentType);
- properties->setDeliveryMode(deliveryMode);
- properties->setPriority(priority);
- properties->setExpiration(expiration);
- properties->setTimestamp(timestamp);
+ props1->setDiscardUnroutable(true);
+ props1->setExchange("foo");
- char buff[100];
- Buffer wbuffer(buff, 100);
- body.encode(wbuffer);
+ char buff[10000];
+ Buffer wbuffer(buff, 10000);
+ out.encode(wbuffer);
- Buffer rbuffer(buff, 100);
- AMQHeaderBody temp;
- temp.decode(rbuffer, body.size());
- properties = temp.get<BasicHeaderProperties>(true);
-
- CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType());
- CPPUNIT_ASSERT_EQUAL((int) deliveryMode, (int) properties->getDeliveryMode());
- CPPUNIT_ASSERT_EQUAL((int) priority, (int) properties->getPriority());
- CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration());
- CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp());
+ Buffer rbuffer(buff, 10000);
+ AMQFrame in;
+ in.decode(rbuffer);
+ DeliveryProperties* props2 =
+ in.castBody<AMQHeaderBody>()->get<DeliveryProperties>(true);
+
+ CPPUNIT_ASSERT(props2->getDiscardUnroutable());
+ CPPUNIT_ASSERT_EQUAL(string("foo"), props2->getExchange());
+ CPPUNIT_ASSERT(!props2->hasTimestamp());
}
+
};
// Make this test suite a plugin.
diff --git a/cpp/src/tests/MessageTest.cpp b/cpp/src/tests/MessageTest.cpp
index f56d5e829e..7e13595141 100644
--- a/cpp/src/tests/MessageTest.cpp
+++ b/cpp/src/tests/MessageTest.cpp
@@ -32,6 +32,9 @@ using namespace boost;
using namespace qpid::broker;
using namespace qpid::framing;
+
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class MessageTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(MessageTest);
diff --git a/cpp/src/tests/TxAckTest.cpp b/cpp/src/tests/TxAckTest.cpp
index dd57736a0c..de3355949d 100644
--- a/cpp/src/tests/TxAckTest.cpp
+++ b/cpp/src/tests/TxAckTest.cpp
@@ -32,6 +32,8 @@ using std::vector;
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class TxAckTest : public CppUnit::TestCase
{
diff --git a/cpp/src/tests/TxPublishTest.cpp b/cpp/src/tests/TxPublishTest.cpp
index 4ec526f207..73030516d9 100644
--- a/cpp/src/tests/TxPublishTest.cpp
+++ b/cpp/src/tests/TxPublishTest.cpp
@@ -34,6 +34,8 @@ using std::vector;
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class TxPublishTest : public CppUnit::TestCase
{
typedef std::pair<string, PersistableMessage*> msg_queue_pair;
diff --git a/cpp/src/tests/perftest.cpp b/cpp/src/tests/perftest.cpp
index 8d970a0a6f..e311f0fcd2 100644
--- a/cpp/src/tests/perftest.cpp
+++ b/cpp/src/tests/perftest.cpp
@@ -35,6 +35,8 @@ using namespace qpid;
using namespace client;
using namespace sys;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
struct Opts : public TestOptions {
bool listen;
@@ -165,7 +167,7 @@ void PublishThread::run() {
Message msg(string(msgSize, 'X'), "perftest");
char* msgBuf = const_cast<char*>(msg.getData().data());
if (opts.durable)
- msg.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
+ msg.getDeliveryProperties().setDeliveryMode(PERSISTENT);
// Time sending message.
AbsTime start=now();
if (!opts.summary) cout << "Publishing " << opts.count << " messages " << flush;