diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-04-23 21:06:35 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-04-23 21:06:35 +0000 |
commit | a7259adba14345898e78b483b7620340ffa5cfc5 (patch) | |
tree | e8d26c0981a666442ad4aa2fff5ddb87c5ce5866 /qpid/cpp/src/tests/BasicPubSubTest.cpp | |
parent | 8d32b03448e8e1ba6319fc0ac484d0ab54b29b38 (diff) | |
download | qpid-python-cmake.tar.gz |
Merge in trunk changes from r758432:768028cmake
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/cmake@768053 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/BasicPubSubTest.cpp')
-rw-r--r-- | qpid/cpp/src/tests/BasicPubSubTest.cpp | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/qpid/cpp/src/tests/BasicPubSubTest.cpp b/qpid/cpp/src/tests/BasicPubSubTest.cpp deleted file mode 100644 index 1e9ff364f1..0000000000 --- a/qpid/cpp/src/tests/BasicPubSubTest.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "BasicPubSubTest.h" - -using namespace qpid; - -class BasicPubSubTest::Receiver : public Worker, public MessageListener -{ - const Exchange& exchange; - const std::string queue; - const std::string key; - std::string tag; -public: - Receiver(ConnectionOptions& 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 BasicPubSubTest::MultiReceiver : public Worker, public MessageListener -{ - typedef boost::ptr_vector<Receiver> ReceiverList; - ReceiverList receivers; - -public: - MultiReceiver(ConnectionOptions& 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(); - } - } -}; - -void BasicPubSubTest::assign(const std::string& role, framing::FieldTable& params, ConnectionOptions& 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(); -} - |