summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-03-03 17:06:44 +0000
committerGordon Sim <gsim@apache.org>2010-03-03 17:06:44 +0000
commit2a71aa199010c48608f6d63794f52ad2e7afede5 (patch)
treec75a9248e0ced59974bde18a73f5237f5efb8446 /cpp/src/tests
parent589def015a6567ecb7be9fe2af0ebec662cea56c (diff)
downloadqpid-python-2a71aa199010c48608f6d63794f52ad2e7afede5.tar.gz
QPID-2402 & QPID-2406: Documented the units for the ttl property of Message. Eliminated use of qpid::sys::Duration from API.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@918575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp24
-rw-r--r--cpp/src/tests/qpid_recv.cpp8
-rw-r--r--cpp/src/tests/qpid_stream.cpp27
3 files changed, 27 insertions, 32 deletions
diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp
index 9e6cd59feb..dea98216b4 100644
--- a/cpp/src/tests/MessagingSessionTests.cpp
+++ b/cpp/src/tests/MessagingSessionTests.cpp
@@ -130,7 +130,7 @@ struct MessagingFixture : public BrokerFixture
Message out(Uuid(true).str());
s.send(out);
Message in;
- BOOST_CHECK(r.fetch(in, 5*qpid::sys::TIME_SEC));
+ BOOST_CHECK(r.fetch(in, 5*DURATION_SEC));
BOOST_CHECK_EQUAL(out.getContent(), in.getContent());
r.close();
s.close();
@@ -196,7 +196,7 @@ struct MultiQueueFixture : MessagingFixture
}
};
-std::vector<std::string> fetch(Receiver& receiver, int count, qpid::sys::Duration timeout=qpid::sys::TIME_SEC*5)
+std::vector<std::string> fetch(Receiver& receiver, int count, Duration timeout=DURATION_SEC*5)
{
std::vector<std::string> data;
Message message;
@@ -215,7 +215,7 @@ void send(Sender& sender, uint count = 1, uint start = 1, const std::string& bas
}
void receive(Receiver& receiver, uint count = 1, uint start = 1,
- const std::string& base = "Message", qpid::sys::Duration timeout=qpid::sys::TIME_SEC*5)
+ const std::string& base = "Message", Duration timeout=DURATION_SEC*5)
{
for (uint i = start; i < start + count; ++i) {
BOOST_CHECK_EQUAL(receiver.fetch(timeout).getContent(), (boost::format("%1%_%2%") % base % i).str());
@@ -229,7 +229,7 @@ QPID_AUTO_TEST_CASE(testSimpleSendReceive)
Message out("test-message");
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
fix.session.acknowledge();
BOOST_CHECK_EQUAL(in.getContent(), out.getContent());
}
@@ -246,7 +246,7 @@ QPID_AUTO_TEST_CASE(testSendReceiveHeaders)
Receiver receiver = fix.session.createReceiver(fix.queue);
Message in;
for (uint i = 0; i < 10; ++i) {
- BOOST_CHECK(receiver.fetch(in, 5 * qpid::sys::TIME_SEC));
+ BOOST_CHECK(receiver.fetch(in, 5 * DURATION_SEC));
BOOST_CHECK_EQUAL(in.getContent(), out.getContent());
BOOST_CHECK_EQUAL(in.getHeaders()["a"].asUint32(), i);
fix.session.acknowledge();
@@ -323,7 +323,7 @@ QPID_AUTO_TEST_CASE(testNextReceiver)
for (uint i = 0; i < fix.queues.size(); i++) {
Message msg;
- BOOST_CHECK(fix.session.nextReceiver().fetch(msg, qpid::sys::TIME_SEC));
+ BOOST_CHECK(fix.session.nextReceiver().fetch(msg, DURATION_SEC));
BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("Message_%1%") % (i+1)).str());
}
}
@@ -339,7 +339,7 @@ QPID_AUTO_TEST_CASE(testMapMessage)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
MapView view(in);
BOOST_CHECK_EQUAL(view["abc"].asString(), "def");
BOOST_CHECK_EQUAL(view["pi"].asFloat(), 3.14f);
@@ -358,7 +358,7 @@ QPID_AUTO_TEST_CASE(testMapMessageWithInitial)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
MapView view(in);
BOOST_CHECK_EQUAL(view["abc"].asString(), "def");
BOOST_CHECK_EQUAL(view["pi"].asFloat(), 3.14f);
@@ -378,7 +378,7 @@ QPID_AUTO_TEST_CASE(testListMessage)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
ListView view(in);
BOOST_CHECK_EQUAL(view.size(), content.size());
BOOST_CHECK_EQUAL(view.front().asString(), "abc");
@@ -412,7 +412,7 @@ QPID_AUTO_TEST_CASE(testListMessageWithInitial)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
ListView view(in);
BOOST_CHECK_EQUAL(view.size(), content.size());
BOOST_CHECK_EQUAL(view.front().asString(), "abc");
@@ -441,10 +441,10 @@ QPID_AUTO_TEST_CASE(testReject)
Message m2("accept-me");
sender.send(m2);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ Message in = receiver.fetch(5 * DURATION_SEC);
BOOST_CHECK_EQUAL(in.getContent(), m1.getContent());
fix.session.reject(in);
- in = receiver.fetch(5 * qpid::sys::TIME_SEC);
+ in = receiver.fetch(5 * DURATION_SEC);
BOOST_CHECK_EQUAL(in.getContent(), m2.getContent());
fix.session.acknowledge();
}
diff --git a/cpp/src/tests/qpid_recv.cpp b/cpp/src/tests/qpid_recv.cpp
index 87a360ec0c..9e4e202053 100644
--- a/cpp/src/tests/qpid_recv.cpp
+++ b/cpp/src/tests/qpid_recv.cpp
@@ -27,16 +27,12 @@
#include <qpid/Options.h>
#include <qpid/log/Logger.h>
#include <qpid/log/Options.h>
-#include <qpid/sys/Time.h>
#include "TestOptions.h"
#include <iostream>
using namespace qpid::messaging;
-using qpid::sys::Duration;
-using qpid::sys::TIME_INFINITE;
-using qpid::sys::TIME_SEC;
using namespace std;
@@ -94,8 +90,8 @@ struct Options : public qpid::Options
Duration getTimeout()
{
- if (forever) return TIME_INFINITE;
- else return timeout*TIME_SEC;
+ if (forever) return INFINITE_DURATION;
+ else return timeout*DURATION_SEC;
}
bool parse(int argc, char** argv)
diff --git a/cpp/src/tests/qpid_stream.cpp b/cpp/src/tests/qpid_stream.cpp
index 3cc8e70809..ca21fa248b 100644
--- a/cpp/src/tests/qpid_stream.cpp
+++ b/cpp/src/tests/qpid_stream.cpp
@@ -32,7 +32,6 @@
#include <string>
using namespace qpid::messaging;
-using namespace qpid::sys;
namespace qpid {
namespace tests {
@@ -58,13 +57,13 @@ Args opts;
const std::string TIMESTAMP = "ts";
-uint64_t timestamp(const AbsTime& time)
+uint64_t timestamp(const qpid::sys::AbsTime& time)
{
- Duration t(time);
+ qpid::sys::Duration t(time);
return t;
}
-struct Client : Runnable
+struct Client : qpid::sys::Runnable
{
virtual ~Client() {}
virtual void doWork(Session&) = 0;
@@ -83,9 +82,9 @@ struct Client : Runnable
}
}
- Thread thread;
+ qpid::sys::Thread thread;
- void start() { thread = Thread(this); }
+ void start() { thread = qpid::sys::Thread(this); }
void join() { thread.join(); }
};
@@ -95,20 +94,20 @@ struct Publish : Client
{
Sender sender = session.createSender(opts.address);
Message msg;
- uint64_t interval = TIME_SEC / opts.rate;
+ uint64_t interval = qpid::sys::TIME_SEC / opts.rate;
uint64_t sent = 0, missedRate = 0;
- AbsTime start = now();
+ qpid::sys::AbsTime start = qpid::sys::now();
while (true) {
- AbsTime sentAt = now();
+ qpid::sys::AbsTime sentAt = qpid::sys::now();
msg.getHeaders()[TIMESTAMP] = timestamp(sentAt);
sender.send(msg);
++sent;
- AbsTime waitTill(start, sent*interval);
- Duration delay(sentAt, waitTill);
+ qpid::sys::AbsTime waitTill(start, sent*interval);
+ qpid::sys::Duration delay(sentAt, waitTill);
if (delay < 0) {
++missedRate;
} else {
- qpid::sys::usleep(delay / TIME_USEC);
+ qpid::sys::usleep(delay / qpid::sys::TIME_USEC);
}
}
}
@@ -128,9 +127,9 @@ struct Consume : Client
session.acknowledge();//TODO: add batching option
++received;
//calculate latency
- uint64_t receivedAt = timestamp(now());
+ uint64_t receivedAt = timestamp(qpid::sys::now());
uint64_t sentAt = msg.getHeaders()[TIMESTAMP].asUint64();
- double latency = ((double) (receivedAt - sentAt)) / TIME_MSEC;
+ double latency = ((double) (receivedAt - sentAt)) / qpid::sys::TIME_MSEC;
//update avg, min & max
minLatency = std::min(minLatency, latency);