summaryrefslogtreecommitdiff
path: root/cpp/tests/BasicPubSubTest.h
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-05-15 07:38:48 +0000
committerGordon Sim <gsim@apache.org>2007-05-15 07:38:48 +0000
commitb20c9a463aa86f91e5c3f5d86c75c988591f8d74 (patch)
tree3bfa8e4badada05d663033c2289ad3df89d0654c /cpp/tests/BasicPubSubTest.h
parentad0c6952f75c86ad587602cfb14dab46efedd4f6 (diff)
downloadqpid-python-b20c9a463aa86f91e5c3f5d86c75c988591f8d74.tar.gz
Separated out implementation from interop test headers.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@538079 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/tests/BasicPubSubTest.h')
-rw-r--r--cpp/tests/BasicPubSubTest.h99
1 files changed, 3 insertions, 96 deletions
diff --git a/cpp/tests/BasicPubSubTest.h b/cpp/tests/BasicPubSubTest.h
index c86d85e81a..e757bd8020 100644
--- a/cpp/tests/BasicPubSubTest.h
+++ b/cpp/tests/BasicPubSubTest.h
@@ -40,103 +40,10 @@ using namespace qpid::client;
class BasicPubSubTest : public SimpleTestCaseBase
{
-
- class Receiver : public Worker, public MessageListener
- {
- const Exchange& exchange;
- const std::string queue;
- const std::string key;
- std::string tag;
- public:
- Receiver(TestOptions& options, const Exchange& _exchange, const std::string& _queue, const std::string& _key, const int _messages)
- : Worker(options, _messages), exchange(_exchange), queue(_queue), key(_key){}
-
- void init()
- {
- Queue q(queue, true);
- channel.declareQueue(q);
- framing::FieldTable args;
- channel.bind(exchange, q, key, args);
- channel.consume(q, tag, this);
- channel.start();
- }
-
- void start(){
- }
-
- void received(Message&)
- {
- count++;
- }
- };
-
- class MultiReceiver : public Worker, public MessageListener
- {
- typedef boost::ptr_vector<Receiver> ReceiverList;
- ReceiverList receivers;
-
- public:
- MultiReceiver(TestOptions& options, const Exchange& exchange, const std::string& key, const int _messages, int receiverCount)
- : Worker(options, _messages)
- {
- for (int i = 0; i != receiverCount; i++) {
- std::string queue = (boost::format("%1%_%2%") % options.clientid % i).str();
- receivers.push_back(new Receiver(options, exchange, queue, key, _messages));
- }
- }
-
- void init()
- {
- for (ReceiverList::size_type i = 0; i != receivers.size(); i++) {
- receivers[i].init();
- }
- }
-
- void start()
- {
- for (ReceiverList::size_type i = 0; i != receivers.size(); i++) {
- receivers[i].start();
- }
- }
-
- void received(Message& msg)
- {
- for (ReceiverList::size_type i = 0; i != receivers.size(); i++) {
- receivers[i].received(msg);
- }
- }
-
- virtual int getCount()
- {
- count = 0;
- for (ReceiverList::size_type i = 0; i != receivers.size(); i++) {
- count += receivers[i].getCount();
- }
- return count;
- }
- virtual void stop()
- {
- for (ReceiverList::size_type i = 0; i != receivers.size(); i++) {
- receivers[i].stop();
- }
- }
- };
-
+ class Receiver;
+ class MultiReceiver;
public:
- void assign(const std::string& role, framing::FieldTable& params, TestOptions& options)
- {
- std::string key = params.getString("PUBSUB_KEY");
- int messages = params.getInt("PUBSUB_NUM_MESSAGES");
- int receivers = params.getInt("PUBSUB_NUM_RECEIVERS");
- if (role == "SENDER") {
- worker = std::auto_ptr<Worker>(new Sender(options, Exchange::STANDARD_TOPIC_EXCHANGE, key, messages));
- } else if(role == "RECEIVER"){
- worker = std::auto_ptr<Worker>(new MultiReceiver(options, Exchange::STANDARD_TOPIC_EXCHANGE, key, messages, receivers));
- } else {
- throw Exception("unrecognised role");
- }
- worker->init();
- }
+ void assign(const std::string& role, framing::FieldTable& params, TestOptions& options);
};
}