Author: gsim
Date: Tue Jun  9 12:41:53 2009
New Revision: 782978

URL: http://svn.apache.org/viewvc?rev=782978&view=rev
Log:
Enhanced test sender to allow the lvq match keys used to be specified in a file.


Modified:
    qpid/trunk/qpid/cpp/src/tests/sender.cpp

Modified: qpid/trunk/qpid/cpp/src/tests/sender.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/sender.cpp?rev=782978&r1=782977&r2=782978&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/sender.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/sender.cpp Tue Jun  9 12:41:53 2009
@@ -28,6 +28,7 @@
 #include <qpid/Exception.h>
 #include "TestOptions.h"
 
+#include <fstream>
 #include <iostream>
 
 using namespace qpid;
@@ -43,6 +44,7 @@
     uint sendEos;
     bool durable;
     string lvqMatchValue;
+    string lvqMatchFile;
 
     Args() : key("test-queue"), sendEos(0), durable(false)
     {
@@ -51,7 +53,8 @@
             ("routing-key", qpid::optValue(key, "KEY"), "Routing key to add to 
messages")
             ("send-eos", qpid::optValue(sendEos, "N"), "Send N EOS messages to 
mark end of input")
             ("durable", qpid::optValue(durable, "true|false"), "Mark messages 
as durable.")
-            ("lvq-match-value", qpid::optValue(lvqMatchValue, "KEY"), "The 
value to set for the LVQ match key property");
+            ("lvq-match-value", qpid::optValue(lvqMatchValue, "KEY"), "The 
value to set for the LVQ match key property")
+            ("lvq-match-file", qpid::optValue(lvqMatchFile, "FILE"), "A file 
containing values to set for the LVQ match key property");
     }
 };
 
@@ -60,7 +63,8 @@
 class Sender : public FailoverManager::Command
 {
   public:
-    Sender(const std::string& destination, const std::string& key, uint 
sendEos, bool durable, const std::string& lvqMatchValue);
+    Sender(const std::string& destination, const std::string& key, uint 
sendEos, bool durable, 
+           const std::string& lvqMatchValue, const std::string& lvqMatchFile);
     void execute(AsyncSession& session, bool isRetry);
   private:
     const std::string destination;
@@ -68,10 +72,12 @@
     Message message;  
     const uint sendEos;
     uint sent;
+    std::ifstream lvqMatchValues;
 };
 
-Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool 
durable, const std::string& lvqMatchValue) : 
-    destination(dest), sender(10), message("", key), sendEos(eos), sent(0) 
+Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool 
durable,
+               const std::string& lvqMatchValue, const std::string& 
lvqMatchFile) :
+    destination(dest), sender(10), message("", key), sendEos(eos), sent(0) , 
lvqMatchValues(lvqMatchFile.c_str())
 {
     if (durable){
         message.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
@@ -90,6 +96,10 @@
     while (getline(std::cin, data)) {
         message.setData(data);
         message.getHeaders().setInt("sn", ++sent);
+        string matchKey;
+        if (lvqMatchValues && getline(lvqMatchValues, matchKey)) {
+            message.getHeaders().setString(QueueOptions::strLVQMatchProperty, 
matchKey);
+        }
         sender.send(message, destination);
     }
     for (uint i = sendEos; i > 0; --i) {
@@ -104,7 +114,7 @@
     try {
         opts.parse(argc, argv);
         FailoverManager connection(opts.con);
-        Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, 
opts.lvqMatchValue);
+        Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, 
opts.lvqMatchValue, opts.lvqMatchFile);
         connection.execute(sender);
         connection.close();
         return 0;  



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to