summaryrefslogtreecommitdiff
path: root/cpp/tests/client_test.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-02-15 08:26:00 +0000
committerGordon Sim <gsim@apache.org>2008-02-15 08:26:00 +0000
commit4351730550bc48c4237de4e616f8e420e084c081 (patch)
treef4d0101055d375a91e3838e0ee31651ff6e72122 /cpp/tests/client_test.cpp
parent4a5dd2bc8257c7a370088a179acc760b143c62a8 (diff)
downloadqpid-python-4351730550bc48c4237de4e616f8e420e084c081.tar.gz
* updated c++ build to work with recent gentools changes
* add null exchange.bound impl to SessionHandlerImpl (to reflect change to spec file) * pass AMQDataBlocks rather than AMQFrames to OutputHandler * allow client to pass messages frames to io layer in one go (via FrameList) if it will fit in a single buffer git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@627971 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/tests/client_test.cpp')
-rw-r--r--cpp/tests/client_test.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/cpp/tests/client_test.cpp b/cpp/tests/client_test.cpp
index a5cc64d1e4..55bf6234d1 100644
--- a/cpp/tests/client_test.cpp
+++ b/cpp/tests/client_test.cpp
@@ -35,6 +35,7 @@
#include <MessageListener.h>
#include <sys/Monitor.h>
#include <FieldTable.h>
+#include <cstdlib>
using namespace qpid::client;
using namespace qpid::sys;
@@ -52,12 +53,28 @@ public:
inline SimpleListener(Monitor* _monitor) : monitor(_monitor){}
inline virtual void received(Message& msg){
- std::cout << "Received message " << msg.getData() << std::endl;
+ std::cout << "Received message " << msg.getData().substr(0, 5) << "..." << std::endl;
monitor->notify();
}
};
-int main(int argc, char**)
+const std::string chars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
+std::string generateData(uint size)
+{
+ if (size < chars.length()) {
+ return chars.substr(0, size);
+ }
+ std::string data;
+ for (uint i = 0; i < (size / chars.length()); i++) {
+ data += chars;
+ }
+ data += chars.substr(0, size % chars.length());
+ return data;
+}
+
+
+int main(int argc, char** argv)
{
try{
//Use a custom exchange
@@ -109,10 +126,17 @@ int main(int argc, char**)
//Now we create and publish a message to our exchange with a
//routing key that will cause it to be routed to our queue
Message msg;
- string data("MyMessage");
- msg.setData(data);
+ uint size = 0;
+ if (argc > 1) {
+ size = atoi(argv[1]);
+ }
+ if (size) {
+ msg.setData(generateData(size));
+ } else {
+ msg.setData("MyMessage");
+ }
channel.publish(msg, exchange, "MyTopic");
- std::cout << "Published message: " << data << std::endl;
+ std::cout << "Published message: " << msg.getData().substr(0, 5) << "..." << std::endl;
{
Monitor::ScopedLock l(monitor);