summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-04-21 14:48:58 +0000
committerAlan Conway <aconway@apache.org>2010-04-21 14:48:58 +0000
commit1a008057b08edf34f68b8b97ef886f2c1415aeba (patch)
tree7ae41cc93a3b68a81cf433a9c8dff872fd3d736b /cpp/src
parentb7c74d4a77f802b5ec5b6177009f0a2937bde201 (diff)
downloadqpid-python-1a008057b08edf34f68b8b97ef886f2c1415aeba.tar.gz
Consistent use of string constants for message property keys in sender/receiver tests.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@936337 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/tests/Statistics.cpp4
-rw-r--r--cpp/src/tests/qpid_receive.cpp3
-rw-r--r--cpp/src/tests/qpid_send.cpp8
-rw-r--r--cpp/src/tests/qpid_stream.cpp6
-rw-r--r--cpp/src/tests/receiver.cpp3
-rw-r--r--cpp/src/tests/replaying_sender.cpp4
-rw-r--r--cpp/src/tests/resuming_receiver.cpp3
-rw-r--r--cpp/src/tests/sender.cpp2
8 files changed, 21 insertions, 12 deletions
diff --git a/cpp/src/tests/Statistics.cpp b/cpp/src/tests/Statistics.cpp
index c002bc6a6a..2452dc8be9 100644
--- a/cpp/src/tests/Statistics.cpp
+++ b/cpp/src/tests/Statistics.cpp
@@ -56,9 +56,11 @@ ThroughputAndLatency::ThroughputAndLatency() :
samples(0)
{}
+const std::string TS = "ts";
+
void ThroughputAndLatency::message(const messaging::Message& m) {
Throughput::message(m);
- types::Variant::Map::const_iterator i = m.getProperties().find("ts");
+ types::Variant::Map::const_iterator i = m.getProperties().find(TS);
if (i != m.getProperties().end()) {
++samples;
int64_t start(i->second.asInt64());
diff --git a/cpp/src/tests/qpid_receive.cpp b/cpp/src/tests/qpid_receive.cpp
index 4c0d8c74c2..53d1d7d1fe 100644
--- a/cpp/src/tests/qpid_receive.cpp
+++ b/cpp/src/tests/qpid_receive.cpp
@@ -138,6 +138,7 @@ struct Options : public qpid::Options
};
const string EOS("eos");
+const string SN("sn");
class SequenceTracker
{
@@ -147,7 +148,7 @@ class SequenceTracker
bool isDuplicate(Message& message)
{
- uint sn = message.getProperties()["sn"];
+ uint sn = message.getProperties()[SN];
if (lastSn < sn) {
lastSn = sn;
return false;
diff --git a/cpp/src/tests/qpid_send.cpp b/cpp/src/tests/qpid_send.cpp
index ec6586323f..27f9b667c6 100644
--- a/cpp/src/tests/qpid_send.cpp
+++ b/cpp/src/tests/qpid_send.cpp
@@ -192,6 +192,8 @@ struct Options : public qpid::Options
};
const string EOS("eos");
+const string SN("sn");
+const string TS("ts");
}} // namespace qpid::tests
@@ -278,8 +280,8 @@ int main(int argc, char ** argv)
if (opts.rate) interval = qpid::sys::TIME_SEC/opts.rate;
while (contentGen->setContent(msg)) {
- msg.getProperties()["sn"] = ++sent;
- msg.getProperties()["ts"] = int64_t(
+ msg.getProperties()[SN] = ++sent;
+ msg.getProperties()[TS] = int64_t(
qpid::sys::Duration(qpid::sys::EPOCH, qpid::sys::now()));
sender.send(msg);
reporter.message(msg);
@@ -300,7 +302,7 @@ int main(int argc, char ** argv)
}
if (opts.reportTotal) reporter.report();
for (uint i = opts.sendEos; i > 0; --i) {
- msg.getProperties()["sn"] = ++sent;
+ msg.getProperties()[SN] = ++sent;
msg.setContent(EOS);//TODO: add in ability to send digest or similar
sender.send(msg);
}
diff --git a/cpp/src/tests/qpid_stream.cpp b/cpp/src/tests/qpid_stream.cpp
index 4305ee8c49..26df5332fe 100644
--- a/cpp/src/tests/qpid_stream.cpp
+++ b/cpp/src/tests/qpid_stream.cpp
@@ -73,7 +73,7 @@ struct Args : public qpid::Options
Args opts;
-const std::string TIMESTAMP = "ts";
+const std::string TS = "ts";
uint64_t timestamp(const qpid::sys::AbsTime& time)
{
@@ -119,7 +119,7 @@ struct Publish : Client
qpid::sys::AbsTime start = qpid::sys::now();
while (true) {
qpid::sys::AbsTime sentAt = qpid::sys::now();
- msg.getProperties()[TIMESTAMP] = timestamp(sentAt);
+ msg.getProperties()[TS] = timestamp(sentAt);
sender.send(msg);
++sent;
qpid::sys::AbsTime waitTill(start, sent*interval);
@@ -151,7 +151,7 @@ struct Consume : Client
}
//calculate latency
uint64_t receivedAt = timestamp(qpid::sys::now());
- uint64_t sentAt = msg.getProperties()[TIMESTAMP].asUint64();
+ uint64_t sentAt = msg.getProperties()[TS].asUint64();
double latency = ((double) (receivedAt - sentAt)) / qpid::sys::TIME_MSEC;
//update avg, min & max
diff --git a/cpp/src/tests/receiver.cpp b/cpp/src/tests/receiver.cpp
index e01954e31a..f1b462d6e4 100644
--- a/cpp/src/tests/receiver.cpp
+++ b/cpp/src/tests/receiver.cpp
@@ -61,6 +61,7 @@ struct Args : public qpid::TestOptions
};
const string EOS("eos");
+const string SN("sn");
class Receiver : public MessageListener, public FailoverManager::Command
{
@@ -99,7 +100,7 @@ void Receiver::received(Message& message)
bool Receiver::isDuplicate(Message& message)
{
- uint sn = message.getHeaders().getAsInt("sn");
+ uint sn = message.getHeaders().getAsInt(SN);
if (lastSn < sn) {
lastSn = sn;
return false;
diff --git a/cpp/src/tests/replaying_sender.cpp b/cpp/src/tests/replaying_sender.cpp
index 62912ea0fc..a5549bfdf2 100644
--- a/cpp/src/tests/replaying_sender.cpp
+++ b/cpp/src/tests/replaying_sender.cpp
@@ -71,6 +71,8 @@ Sender::Sender(const std::string& queue, uint count_, uint reportFreq )
message.getDeliveryProperties().setRoutingKey(queueName.c_str());
}
+const string SN("sn");
+
void Sender::execute(AsyncSession& session, bool isRetry)
{
if (verbosity > 0)
@@ -81,7 +83,7 @@ void Sender::execute(AsyncSession& session, bool isRetry)
stringstream message_data;
message_data << ++sent;
message.setData(message_data.str());
- message.getHeaders().setInt("sn", sent);
+ message.getHeaders().setInt(SN, sent);
if ( persistence )
message.getDeliveryProperties().setDeliveryMode(PERSISTENT);
diff --git a/cpp/src/tests/resuming_receiver.cpp b/cpp/src/tests/resuming_receiver.cpp
index abd62f003e..2e22a7c572 100644
--- a/cpp/src/tests/resuming_receiver.cpp
+++ b/cpp/src/tests/resuming_receiver.cpp
@@ -73,6 +73,7 @@ Listener::Listener ( int freq, int verbosity, char const * name )
queueName ( name )
{}
+const std::string SN("sn");
void Listener::received(Message & message)
{
@@ -108,7 +109,7 @@ void Listener::received(Message & message)
<< endl;
}
} else {
- uint sn = message.getHeaders().getAsInt("sn");
+ uint sn = message.getHeaders().getAsInt(SN);
if (lastSn < sn) {
if (sn - lastSn > 1) {
cerr << "Error: gap in sequence between " << lastSn << " and " << sn << endl;
diff --git a/cpp/src/tests/sender.cpp b/cpp/src/tests/sender.cpp
index 9634c1a55e..9850e851da 100644
--- a/cpp/src/tests/sender.cpp
+++ b/cpp/src/tests/sender.cpp
@@ -120,7 +120,7 @@ void Sender::execute(AsyncSession& session, bool isRetry)
string data;
while (getline(std::cin, data)) {
message.setData(data);
- message.getHeaders().setInt("sn", ++sent);
+ message.getHeaders().setInt("SN", ++sent);
string matchKey;
if (lvqMatchValues && getline(lvqMatchValues, matchKey)) {
message.getHeaders().setString(QueueOptions::strLVQMatchProperty, matchKey);