summaryrefslogtreecommitdiff
path: root/cpp/src/tests/client_test.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-06-27 00:12:26 +0000
committerAlan Conway <aconway@apache.org>2007-06-27 00:12:26 +0000
commitd032f5584b0f1de890844a2796d6ba158b011fca (patch)
tree7ffc500423a1cee3c39d2a5e27d301057fbcd0e9 /cpp/src/tests/client_test.cpp
parent2e15ee024a7f47bda7bd6ea5991657a820bd0714 (diff)
downloadqpid-python-d032f5584b0f1de890844a2796d6ba158b011fca.tar.gz
Make check now starts a broker on a dynamically assigned port, so
multiple qpid builds on one host will not conflict. * src/tests/run_test, start_broker, kill_broker: Broker writes port to file, run_test sets QPID_PORT in environment of all tests. * src/tests/topic_publisher.cpp, topic_listener.cpp, client_test.cpp: All test clients use TestOptions to parse options from args and env. * src/qpid/Options.h: Renamed from CommonOptions.h Simplified use of Options class. * src/qpid/Url.h: Renamed defaultPort constant. * src/tests/logging.cpp: * src/tests/interop_runner.cpp: * src/tests/TestOptions.h: * src/qpidd.cpp: * src/qpid/log/Options.cpp: * src/qpid/log/Logger.cpp: * src/qpid/broker/Broker.cpp: Updated for changes to Options. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@550993 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/client_test.cpp')
-rw-r--r--cpp/src/tests/client_test.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/cpp/src/tests/client_test.cpp b/cpp/src/tests/client_test.cpp
index a05c01043f..3b8a3a2ee6 100644
--- a/cpp/src/tests/client_test.cpp
+++ b/cpp/src/tests/client_test.cpp
@@ -28,6 +28,7 @@
#include <iostream>
+#include "TestOptions.h"
#include "qpid/QpidError.h"
#include "qpid/client/ClientChannel.h"
#include "qpid/client/Connection.h"
@@ -59,38 +60,39 @@ public:
}
};
-int main(int argc, char**)
+int main(int argc, char** argv)
{
- verbose = argc > 1;
try {
+ qpid::TestOptions opts;
+ opts.parse(argc, argv);
+
//Use a custom exchange
Exchange exchange("MyExchange", Exchange::TOPIC_EXCHANGE);
//Use a named, temporary queue
Queue queue("MyQueue", true);
- Connection con(verbose);
- string host("localhost");
- con.open(host, 5672, "guest", "guest", "/test");
- if (verbose)
+ Connection con(opts.trace);
+ con.open(opts.host, opts.port, opts.username, opts.password, opts.virtualhost);
+ if (opts.trace)
std::cout << "Opened connection." << std::endl;
//Create and open a channel on the connection through which
//most functionality is exposed
Channel channel;
con.openChannel(channel);
- if (verbose) std::cout << "Opened channel." << std::endl;
+ if (opts.trace) std::cout << "Opened channel." << std::endl;
//'declare' the exchange and the queue, which will create them
//as they don't exist
channel.declareExchange(exchange);
- if (verbose) std::cout << "Declared exchange." << std::endl;
+ if (opts.trace) std::cout << "Declared exchange." << std::endl;
channel.declareQueue(queue);
- if (verbose) std::cout << "Declared queue." << std::endl;
+ if (opts.trace) std::cout << "Declared queue." << std::endl;
//now bind the queue to the exchange
channel.bind(exchange, queue, "MyTopic");
- if (verbose) std::cout << "Bound queue to exchange." << std::endl;
+ if (opts.trace) std::cout << "Bound queue to exchange." << std::endl;
//Set up a message listener to receive any messages that
//arrive in our queue on the broker. We only expect one, and
@@ -101,7 +103,7 @@ int main(int argc, char**)
SimpleListener listener(&monitor);
string tag("MyTag");
channel.consume(queue, tag, &listener);
- if (verbose) std::cout << "Registered consumer." << std::endl;
+ if (opts.trace) std::cout << "Registered consumer." << std::endl;
//we need to enable the message dispatching for this channel
//and we want that to occur on another thread so we call
@@ -114,7 +116,7 @@ int main(int argc, char**)
string data("MyMessage");
msg.setData(data);
channel.publish(msg, exchange, "MyTopic");
- if (verbose) std::cout << "Published message: " << data << std::endl;
+ if (opts.trace) std::cout << "Published message: " << data << std::endl;
{
Monitor::ScopedLock l(monitor);
@@ -125,9 +127,9 @@ int main(int argc, char**)
//close the channel & connection
channel.close();
- if (verbose) std::cout << "Closed channel." << std::endl;
+ if (opts.trace) std::cout << "Closed channel." << std::endl;
con.close();
- if (verbose) std::cout << "Closed connection." << std::endl;
+ if (opts.trace) std::cout << "Closed connection." << std::endl;
return 0;
} catch(const std::exception& e) {
std::cout << e.what() << std::endl;