Author: aconway
Date: Mon Jun 2 14:38:25 2008
New Revision: 662581
URL: http://svn.apache.org/viewvc?rev=662581&view=rev
Log:
Separate option parsing from qpid::client::ClientSettings.
Added:
incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h (with props)
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.h
incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.h
incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.h
incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.h
incubator/qpid/trunk/qpid/cpp/src/tests/TestCase.h
incubator/qpid/trunk/qpid/cpp/src/tests/TestOptions.h
incubator/qpid/trunk/qpid/cpp/src/tests/client_test.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Connection.cpp Mon Jun 2
14:38:25 2008
@@ -53,8 +53,7 @@
const std::string& vhost,
uint16_t maxFrameSize)
{
- // FIXME aconway 2008-06-02: refactor ConnectionSettings to separate out
command line parsing.
- ConnectionSettings settings("");
+ ConnectionSettings settings;
settings.host = host;
settings.port = port;
settings.username = uid;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.cpp
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.cpp Mon
Jun 2 14:38:25 2008
@@ -29,8 +29,7 @@
namespace qpid {
namespace client {
-ConnectionSettings::ConnectionSettings(const std::string& argv0) :
- Options("Connection Settings"),
+ConnectionSettings::ConnectionSettings() :
host("localhost"),
port(TcpAddress::DEFAULT_PORT),
clientid("cpp"),
@@ -42,34 +41,11 @@
maxChannels(32767),
maxFrameSize(65535),
bounds(2),
- tcpNoDelay(false),
- log(argv0)
-{
- addOptions()
- ("broker,b", optValue(host, "HOST"), "Broker host to connect to")
- ("port,p", optValue(port, "PORT"), "Broker port to connect to")
- ("virtualhost,v", optValue(virtualhost, "VHOST"), "virtual host")
- ("clientname,n", optValue(clientid, "ID"), "unique client identifier")
- ("username", optValue(username, "USER"), "user name for broker log
in.")
- ("password", optValue(password, "PASSWORD"), "password for broker log
in.")
- ("mechanism", optValue(mechanism, "MECH"), "SASL mechanism to use when
authenticating.")
- ("locale", optValue(locale, "LOCALE"), "locale to use.")
- ("max-channels", optValue(maxChannels, "N"), "the maximum number of
channels the client requires.")
- ("max-frame-size", optValue(maxFrameSize, "N"), "the maximum frame
size to request.")
- ("bounds-multiplier", optValue(bounds, "N"),
- "restricts the total size of outgoing frames queued up for writing
(as a multiple of the max frame size).");
- add(log);
-}
+ tcpNoDelay(false)
+{}
ConnectionSettings::~ConnectionSettings() {}
-void ConnectionSettings::parse(int argc, char** argv)
-{
- qpid::Options::parse(argc, argv);
- qpid::log::Logger::instance().configure(log);
-}
-
-
void ConnectionSettings::configurePosixTcpSocket(int fd) const
{
if (tcpNoDelay) {
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.h
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionSettings.h Mon Jun
2 14:38:25 2008
@@ -34,12 +34,11 @@
namespace client {
/**
- * Used to hold seetings for a connection (and parse these from
- * command line options etc if desired).
+ * Settings for a Connection.
*/
-struct ConnectionSettings : qpid::Options, qpid::sys::Socket::Configuration {
- // FIXME aconway 2008-06-02: separate option parsing from settings as
subclass.
- ConnectionSettings(const std::string& argv0=std::string());
+struct ConnectionSettings : public sys::Socket::Configuration {
+
+ ConnectionSettings();
virtual ~ConnectionSettings();
/**
@@ -47,12 +46,6 @@
*/
virtual void configurePosixTcpSocket(int fd) const;
- /**
- * Parse options from command line arguments (will throw exception
- * if arguments cannot be parsed).
- */
- void parse(int argc, char** argv);
-
/**
* The host (or ip address) to connect to (defaults to 'localhost').
*/
@@ -110,11 +103,6 @@
* If true, TCP_NODELAY will be set for the connection.
*/
bool tcpNoDelay;
-
- /**
- * Logging settings to use.
- */
- log::Options log;
};
}} // namespace qpid::client
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.cpp Mon Jun 2
14:38:25 2008
@@ -29,7 +29,7 @@
const std::string queue;
std::string tag;
public:
- Receiver(ConnectionSettings& options, const std::string& _queue, const int
_messages)
+ Receiver(ConnectionOptions& options, const std::string& _queue, const int
_messages)
: Worker(options, _messages), queue(_queue){}
void init()
{
@@ -51,7 +51,7 @@
}
};
-void BasicP2PTest::assign(const std::string& role, framing::FieldTable&
params, ConnectionSettings& options)
+void BasicP2PTest::assign(const std::string& role, framing::FieldTable&
params, ConnectionOptions& options)
{
std::string queue = params.getString("P2P_QUEUE_AND_KEY_NAME");
int messages = params.getInt("P2P_NUM_MESSAGES");
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BasicP2PTest.h Mon Jun 2 14:38:25
2008
@@ -38,7 +38,7 @@
{
class Receiver;
public:
- void assign(const std::string& role, framing::FieldTable& params,
ConnectionSettings& options);
+ void assign(const std::string& role, framing::FieldTable& params,
ConnectionOptions& options);
};
}
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.cpp Mon Jun 2
14:38:25 2008
@@ -30,7 +30,7 @@
const std::string key;
std::string tag;
public:
- Receiver(ConnectionSettings& options, const Exchange& _exchange, const
std::string& _queue, const std::string& _key, const int _messages)
+ 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()
@@ -58,7 +58,7 @@
ReceiverList receivers;
public:
- MultiReceiver(ConnectionSettings& options, const Exchange& exchange, const
std::string& key, const int _messages, int receiverCount)
+ 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++) {
@@ -104,7 +104,7 @@
}
};
-void BasicPubSubTest::assign(const std::string& role, framing::FieldTable&
params, ConnectionSettings& options)
+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");
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/BasicPubSubTest.h Mon Jun 2
14:38:25 2008
@@ -43,7 +43,7 @@
class Receiver;
class MultiReceiver;
public:
- void assign(const std::string& role, framing::FieldTable& params,
ConnectionSettings& options);
+ void assign(const std::string& role, framing::FieldTable& params,
ConnectionOptions& options);
};
}
Added: incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h?rev=662581&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h Mon Jun 2
14:38:25 2008
@@ -0,0 +1,53 @@
+#ifndef QPID_CLIENT_CONNECTIONOPTIONS_H
+#define QPID_CLIENT_CONNECTIONOPTIONS_H
+
+/*
+ *
+ * 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 "ConnectionOptions.h"
+#include "qpid/Options.h"
+
+/**
+ * Options parser for ConnectionOptions.
+ */
+struct ConnectionOptions : public qpid::Options,
+ public qpid::client::ConnectionSettings
+{
+ ConnectionOptions() : qpid::Options("Connection Settings")
+ {
+ using namespace qpid;
+ addOptions()
+ ("broker,b", optValue(host, "HOST"), "Broker host to connect to")
+ ("port,p", optValue(port, "PORT"), "Broker port to connect to")
+ ("virtualhost,v", optValue(virtualhost, "VHOST"), "virtual host")
+ ("clientname,n", optValue(clientid, "ID"), "unique client
identifier")
+ ("username", optValue(username, "USER"), "user name for broker log
in.")
+ ("password", optValue(password, "PASSWORD"), "password for broker
log in.")
+ ("mechanism", optValue(mechanism, "MECH"), "SASL mechanism to use
when authenticating.")
+ ("locale", optValue(locale, "LOCALE"), "locale to use.")
+ ("max-channels", optValue(maxChannels, "N"), "the maximum number
of channels the client requires.")
+ ("max-frame-size", optValue(maxFrameSize, "N"), "the maximum frame
size to request.")
+ ("bounds-multiplier", optValue(bounds, "N"),
+ "bound size of write queue (as a multiple of the max frame
size).");
+ }
+};
+
+#endif /*!QPID_CLIENT_CONNECTIONOPTIONS_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/tests/ConnectionOptions.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am Mon Jun 2 14:38:25 2008
@@ -63,7 +63,8 @@
TxAckTest.cpp \
TxBufferTest.cpp \
TxPublishTest.cpp \
- MessageBuilderTest.cpp
+ MessageBuilderTest.cpp \
+ ConnectionOptions.h
if HAVE_XML
unit_test_SOURCES+= XmlClientSessionTest.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.cpp Mon Jun 2
14:38:25 2008
@@ -47,7 +47,7 @@
}
}
-SimpleTestCaseBase::Sender::Sender(ConnectionSettings& options,
+SimpleTestCaseBase::Sender::Sender(ConnectionOptions& options,
const Exchange& _exchange,
const std::string& _key,
const int _messages)
@@ -67,7 +67,7 @@
stop();
}
-SimpleTestCaseBase::Worker::Worker(ConnectionSettings& options, const int
_messages) :
+SimpleTestCaseBase::Worker::Worker(ConnectionOptions& options, const int
_messages) :
messages(_messages), count(0)
{
connection.open(options.host, options.port);
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/SimpleTestCaseBase.h Mon Jun 2
14:38:25 2008
@@ -28,7 +28,7 @@
#include "qpid/client/Channel.h"
#include "qpid/client/Message.h"
#include "qpid/client/Connection.h"
-#include "qpid/client/ConnectionSettings.h"
+#include "ConnectionOptions.h"
#include "qpid/client/MessageListener.h"
#include "TestCase.h"
@@ -50,7 +50,7 @@
public:
- Worker(ConnectionSettings& options, const int messages);
+ Worker(ConnectionOptions& options, const int messages);
virtual ~Worker(){}
virtual void stop();
@@ -64,7 +64,7 @@
const Exchange& exchange;
const std::string key;
public:
- Sender(ConnectionSettings& options,
+ Sender(ConnectionOptions& options,
const Exchange& exchange,
const std::string& key,
const int messages);
@@ -75,7 +75,7 @@
std::auto_ptr<Worker> worker;
public:
- virtual void assign(const std::string& role, framing::FieldTable& params,
ConnectionSettings& options) = 0;
+ virtual void assign(const std::string& role, framing::FieldTable& params,
ConnectionOptions& options) = 0;
virtual ~SimpleTestCaseBase() {}
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TestCase.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TestCase.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TestCase.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TestCase.h Mon Jun 2 14:38:25 2008
@@ -21,7 +21,7 @@
*
*/
-#include "qpid/client/ConnectionSettings.h"
+#include "ConnectionOptions.h"
#include "qpid/client/Message.h"
@@ -39,7 +39,7 @@
* may be 'activated' at this stage others may require an explicit
* start request.
*/
- virtual void assign(const std::string& role, framing::FieldTable& params,
client::ConnectionSettings& options) = 0;
+ virtual void assign(const std::string& role, framing::FieldTable& params,
client::ConnectionOptions& options) = 0;
/**
* Each test will be started on its own thread, which should block
* until the test completes (this may or may not require an
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/TestOptions.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/TestOptions.h?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/TestOptions.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/TestOptions.h Mon Jun 2 14:38:25
2008
@@ -26,7 +26,7 @@
#include "qpid/Url.h"
#include "qpid/log/Logger.h"
#include "qpid/client/Connection.h"
-#include "qpid/client/ConnectionSettings.h"
+#include "ConnectionOptions.h"
#include <iostream>
#include <exception>
@@ -35,12 +35,14 @@
struct TestOptions : public qpid::Options
{
- TestOptions(const std::string& helpText_=std::string()) :
- Options("Test Options"), help(false), helpText(helpText_)
+ TestOptions(const std::string& helpText_=std::string(),
+ const std::string& argv0=std::string())
+ : Options("Test Options"), help(false), log(argv0), helpText(helpText_)
{
addOptions()
("help", optValue(help), "print this usage statement");
add(con);
+ add(log);
}
/** As well as parsing, throw help message if requested. */
@@ -52,7 +54,7 @@
msg << *this << std::endl << std::endl << e.what() << std::endl;
throw qpid::Options::Exception(msg.str());
}
- qpid::log::Logger::instance().configure(con.log);
+ qpid::log::Logger::instance().configure(log);
if (help) {
std::ostringstream msg;
msg << *this << std::endl << std::endl << helpText << std::endl;
@@ -67,7 +69,8 @@
bool help;
- client::ConnectionSettings con;
+ ConnectionOptions con;
+ qpid::log::Options log;
std::string helpText;
};
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/client_test.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/client_test.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/client_test.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/client_test.cpp Mon Jun 2 14:38:25
2008
@@ -30,7 +30,6 @@
#include "TestOptions.h"
#include "qpid/client/Connection.h"
-#include "qpid/client/ConnectionSettings.h"
#include "qpid/client/Message.h"
#include "qpid/client/Session.h"
#include "qpid/framing/FrameSet.h"
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp?rev=662581&r1=662580&r2=662581&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp Mon Jun 2
14:38:25 2008
@@ -24,7 +24,7 @@
#include "qpid/Exception.h"
#include "qpid/client/Channel.h"
#include "qpid/client/Connection.h"
-#include "qpid/client/ConnectionSettings.h"
+#include "qpid/client/ConnectionOptions.h"
#include "qpid/client/Exchange.h"
#include "qpid/client/MessageListener.h"
#include "qpid/client/Queue.h"
@@ -54,7 +54,7 @@
{
public:
DummyRun() {}
- void assign(const string&, FieldTable&, ConnectionSettings&) {}
+ void assign(const string&, FieldTable&, ConnectionOptions&) {}
void start() {}
void stop() {}
void report(qpid::client::Message&) {}
@@ -68,7 +68,7 @@
typedef boost::ptr_map<string, TestCase> TestMap;
Channel& channel;
- ConnectionSettings& options;
+ ConnectionOptions& options;
TestMap tests;
const string name;
const string topic;
@@ -86,13 +86,13 @@
void sendSimpleResponse(const string& type, Message& request);
void sendReport();
public:
- Listener(Channel& channel, ConnectionSettings& options);
+ Listener(Channel& channel, ConnectionOptions& options);
void received(Message& msg);
void bindAndConsume();
void registerTest(string name, TestCase* test);
};
-struct TestSettings : ConnectionSettings
+struct TestSettings : ConnectionOptions
{
bool help;
@@ -131,7 +131,7 @@
}
}
-Listener::Listener(Channel& _channel, ConnectionSettings& _options) :
channel(_channel), options(_options), name(options.clientid),
topic("iop.control." + name)
+Listener::Listener(Channel& _channel, ConnectionOptions& _options) :
channel(_channel), options(_options), name(options.clientid),
topic("iop.control." + name)
{}
void Listener::registerTest(string name, TestCase* test)