Author: gsim
Date: Tue May 15 00:38:48 2007
New Revision: 538079
URL: http://svn.apache.org/viewvc?view=rev&rev=538079
Log:
Separated out implementation from interop test headers.
Added:
incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp (with props)
incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp (with props)
incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp (with props)
Modified:
incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.h
incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.h
incubator/qpid/branches/M2/cpp/tests/Makefile.am
incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.h
Added: incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp?view=auto&rev=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp (added)
+++ incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp Tue May 15 00:38:48
2007
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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 "BasicP2PTest.h"
+
+using namespace qpid;
+using namespace qpid::client;
+
+class BasicP2PTest::Receiver : public Worker, public MessageListener
+{
+ const std::string queue;
+ std::string tag;
+public:
+ Receiver(TestOptions& options, const std::string& _queue, const int
_messages)
+ : Worker(options, _messages), queue(_queue){}
+ void init()
+ {
+ Queue q(queue, true);
+ channel.declareQueue(q);
+ framing::FieldTable args;
+ channel.bind(Exchange::STANDARD_DIRECT_EXCHANGE, q, queue, args);
+ channel.consume(q, tag, this);
+ channel.start();
+ }
+
+ void start()
+ {
+ }
+
+ void received(Message&)
+ {
+ count++;
+ }
+};
+
+void BasicP2PTest::assign(const std::string& role, framing::FieldTable&
params, TestOptions& options)
+{
+ std::string queue = params.getString("P2P_QUEUE_AND_KEY_NAME");
+ int messages = params.getInt("P2P_NUM_MESSAGES");
+ if (role == "SENDER") {
+ worker = std::auto_ptr<Worker>(new Sender(options,
Exchange::STANDARD_DIRECT_EXCHANGE, queue, messages));
+ } else if(role == "RECEIVER"){
+ worker = std::auto_ptr<Worker>(new Receiver(options, queue, messages));
+ } else {
+ throw Exception("unrecognised role");
+ }
+ worker->init();
+}
Propchange: incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.h?view=diff&rev=538079&r1=538078&r2=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.h (original)
+++ incubator/qpid/branches/M2/cpp/tests/BasicP2PTest.h Tue May 15 00:38:48 2007
@@ -34,51 +34,11 @@
namespace qpid {
-using namespace qpid::client;
-
class BasicP2PTest : public SimpleTestCaseBase
{
-
- class Receiver : public Worker, public MessageListener
- {
- const std::string queue;
- std::string tag;
- public:
- Receiver(TestOptions& options, const std::string& _queue, const int
_messages) : Worker(options, _messages), queue(_queue){}
-
- void init()
- {
- Queue q(queue, true);
- channel.declareQueue(q);
- framing::FieldTable args;
- channel.bind(Exchange::STANDARD_DIRECT_EXCHANGE, q, queue, args);
- channel.consume(q, tag, this);
- channel.start();
- }
-
- void start(){
- }
-
- void received(Message&)
- {
- count++;
- }
- };
-
+ class Receiver;
public:
- void assign(const std::string& role, framing::FieldTable& params,
TestOptions& options)
- {
- std::string queue = params.getString("P2P_QUEUE_AND_KEY_NAME");
- int messages = params.getInt("P2P_NUM_MESSAGES");
- if (role == "SENDER") {
- worker = std::auto_ptr<Worker>(new Sender(options,
Exchange::STANDARD_DIRECT_EXCHANGE, queue, messages));
- } else if(role == "RECEIVER"){
- worker = std::auto_ptr<Worker>(new Receiver(options, queue,
messages));
- } else {
- throw Exception("unrecognised role");
- }
- worker->init();
- }
+ void assign(const std::string& role, framing::FieldTable& params,
TestOptions& options);
};
}
Added: incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp?view=auto&rev=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp (added)
+++ incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp Tue May 15
00:38:48 2007
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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(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 BasicPubSubTest::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();
+ }
+ }
+};
+
+void BasicPubSubTest::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();
+}
+
Propchange: incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.h?view=diff&rev=538079&r1=538078&r2=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.h (original)
+++ incubator/qpid/branches/M2/cpp/tests/BasicPubSubTest.h Tue May 15 00:38:48
2007
@@ -40,103 +40,10 @@
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);
};
}
Modified: incubator/qpid/branches/M2/cpp/tests/Makefile.am
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/Makefile.am?view=diff&rev=538079&r1=538078&r2=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/Makefile.am (original)
+++ incubator/qpid/branches/M2/cpp/tests/Makefile.am Tue May 15 00:38:48 2007
@@ -23,8 +23,7 @@
client_test \
echo_service \
topic_listener \
- topic_publisher \
- interop_runner
+ topic_publisher
broker_tests = \
AccumulatedAckTest \
@@ -105,3 +104,11 @@
) \
> [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
+
+bin_PROGRAMS = interop_runner
+interop_runner_SOURCES = \
+ interop_runner.cpp \
+ SimpleTestCaseBase.cpp \
+ BasicP2PTest.cpp \
+ BasicPubSubTest.cpp
+interop_runner_LDADD = $(lib_client) $(lib_common) $(extra_libs)
Added: incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp?view=auto&rev=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp (added)
+++ incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp Tue May 15
00:38:48 2007
@@ -0,0 +1,87 @@
+/*
+ *
+ * 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 "SimpleTestCaseBase.h"
+
+using namespace qpid;
+
+void SimpleTestCaseBase::start()
+{
+ if (worker.get()) {
+ worker->start();
+ }
+}
+
+void SimpleTestCaseBase::stop()
+{
+ if (worker.get()) {
+ worker->stop();
+ }
+}
+
+void SimpleTestCaseBase::report(client::Message& report)
+{
+ if (worker.get()) {
+ report.getHeaders().setInt("MESSAGE_COUNT", worker->getCount());
+ //add number of messages sent or received
+ std::stringstream reportstr;
+ reportstr << worker->getCount();
+ report.setData(reportstr.str());
+ }
+}
+
+SimpleTestCaseBase::Sender::Sender(TestOptions& options,
+ const Exchange& _exchange,
+ const std::string& _key,
+ const int _messages)
+ : Worker(options, _messages), exchange(_exchange), key(_key) {}
+
+void SimpleTestCaseBase::Sender::init()
+{
+ channel.start();
+}
+
+void SimpleTestCaseBase::Sender::start(){
+ Message msg;
+ while (count < messages) {
+ channel.publish(msg, exchange, key);
+ count++;
+ }
+ stop();
+}
+
+SimpleTestCaseBase::Worker::Worker(TestOptions& options, const int _messages)
:
+ connection(options.trace), messages(_messages), count(0)
+{
+ connection.open(options.broker, options.port);
+ connection.openChannel(&channel);
+}
+
+void SimpleTestCaseBase::Worker::stop()
+{
+ channel.close();
+ connection.close();
+}
+
+int SimpleTestCaseBase::Worker::getCount()
+{
+ return count;
+}
+
Propchange: incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.h?view=diff&rev=538079&r1=538078&r2=538079
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.h (original)
+++ incubator/qpid/branches/M2/cpp/tests/SimpleTestCaseBase.h Tue May 15
00:38:48 2007
@@ -49,26 +49,11 @@
public:
- Worker(TestOptions& options, const int _messages) :
- connection(options.trace), messages(_messages), count(0)
- {
- connection.open(options.broker, options.port);
- connection.openChannel(&channel);
- }
-
+ Worker(TestOptions& options, const int messages);
virtual ~Worker(){}
- virtual void stop()
- {
- channel.close();
- connection.close();
- }
-
- virtual int getCount()
- {
- return count;
- }
-
+ virtual void stop();
+ virtual int getCount();
virtual void init() = 0;
virtual void start() = 0;
};
@@ -79,24 +64,11 @@
const std::string key;
public:
Sender(TestOptions& options,
- const Exchange& _exchange,
- const std::string& _key,
- const int _messages)
- : Worker(options, _messages), exchange(_exchange), key(_key) {}
-
- void init()
- {
- channel.start();
- }
-
- void start(){
- Message msg;
- while (count < messages) {
- channel.publish(msg, exchange, key);
- count++;
- }
- stop();
- }
+ const Exchange& exchange,
+ const std::string& key,
+ const int messages);
+ void init();
+ void start();
};
std::auto_ptr<Worker> worker;
@@ -106,30 +78,9 @@
virtual ~SimpleTestCaseBase() {}
- void start()
- {
- if (worker.get()) {
- worker->start();
- }
- }
-
- void stop()
- {
- if (worker.get()) {
- worker->stop();
- }
- }
-
- void report(client::Message& report)
- {
- if (worker.get()) {
- report.getHeaders().setInt("MESSAGE_COUNT", worker->getCount());
- //add number of messages sent or received
- std::stringstream reportstr;
- reportstr << worker->getCount();
- report.setData(reportstr.str());
- }
- }
+ void start();
+ void stop();
+ void report(client::Message& report);
};
}