diff options
author | Ted Ross <tross@apache.org> | 2009-10-02 17:45:58 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2009-10-02 17:45:58 +0000 |
commit | 0f7c02dae11afed532bf60302cf2185f422fd23c (patch) | |
tree | 9b176b6ebbe29419aa4bfe5d24102d5091dc2a72 /qpid/cpp | |
parent | 4b60b602712e767a4438b2c6552cb50fa9aa97cb (diff) | |
download | qpid-python-0f7c02dae11afed532bf60302cf2185f422fd23c.tar.gz |
QMF Fixes:
- In ruby: waitForStable => wait_for_stable
- Setting an unknown attribute on connection settings now throws an exception
- Added connected? accessor to Connection
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821109 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r-- | qpid/cpp/bindings/qmf/ruby/qmf.rb | 17 | ||||
-rwxr-xr-x | qpid/cpp/bindings/qmf/tests/ruby_console.rb | 2 | ||||
-rwxr-xr-x | qpid/cpp/bindings/qmf/tests/ruby_console_test.rb | 10 | ||||
-rw-r--r-- | qpid/cpp/bindings/qmf/tests/test_base.rb | 2 | ||||
-rw-r--r-- | qpid/cpp/include/qmf/engine/ConnectionSettings.h | 4 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp | 7 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h | 2 |
7 files changed, 32 insertions, 12 deletions
diff --git a/qpid/cpp/bindings/qmf/ruby/qmf.rb b/qpid/cpp/bindings/qmf/ruby/qmf.rb index 548b50874c..f79fb5ed88 100644 --- a/qpid/cpp/bindings/qmf/ruby/qmf.rb +++ b/qpid/cpp/bindings/qmf/ruby/qmf.rb @@ -60,7 +60,8 @@ module Qmf raise ArgumentError, "Value for attribute '#{key}' has unsupported type: #{val.class}" end - @impl.setAttr(key, v) + good = @impl.setAttr(key, v) + raise "Invalid attribute '#{key}'" unless good end def method_missing(name_in, *args) @@ -96,12 +97,17 @@ module Qmf @new_conn_handlers = [] @conn_handlers_to_delete = [] @conn_handlers = [] + @connected = nil @thread = Thread.new do run end end + def connected? + @connected + end + def kick @sockEngine.write(".") @sockEngine.flush @@ -123,7 +129,6 @@ module Qmf def run() eventImpl = Qmfengine::ResilientConnectionEvent.new - connected = nil new_handlers = nil del_handlers = nil bt_count = 0 @@ -140,7 +145,7 @@ module Qmf new_handlers.each do |nh| @conn_handlers << nh - nh.conn_event_connected() if connected + nh.conn_event_connected() if @connected end new_handlers = nil @@ -154,10 +159,10 @@ module Qmf begin case eventImpl.kind when Qmfengine::ResilientConnectionEvent::CONNECTED - connected = :true + @connected = :true @conn_handlers.each { |h| h.conn_event_connected() } when Qmfengine::ResilientConnectionEvent::DISCONNECTED - connected = nil + @connected = nil @conn_handlers.each { |h| h.conn_event_disconnected(eventImpl.errorText) } when Qmfengine::ResilientConnectionEvent::SESSION_CLOSED eventImpl.sessionContext.handler.sess_event_session_closed(eventImpl.sessionContext, eventImpl.errorText) @@ -1049,7 +1054,7 @@ module Qmf @operational = :false end - def waitForStable(timeout = nil) + def wait_for_stable(timeout = nil) synchronize do return if @stable if timeout diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console.rb b/qpid/cpp/bindings/qmf/tests/ruby_console.rb index b53cf57b1f..f4420c9fc6 100755 --- a/qpid/cpp/bindings/qmf/tests/ruby_console.rb +++ b/qpid/cpp/bindings/qmf/tests/ruby_console.rb @@ -110,7 +110,7 @@ class App < Qmf::ConsoleHandler @qmfc = Qmf::Console.new(self) @broker = @qmfc.add_connection(@connection) - @broker.waitForStable + @broker.wait_for_stable ##dump_schema diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb index 9a33b5cdc6..b72c8e3806 100755 --- a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb +++ b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb @@ -24,6 +24,8 @@ require 'test_base' class ConsoleTest < ConsoleTestBase def test_A_agent_presence + assert(@connection.connected?, "Connection not connected") + agents = [] count = 0 while agents.size == 0 @@ -37,6 +39,14 @@ class ConsoleTest < ConsoleTestBase assert_equal(agentList.size, 2, "Number of agents reported by Console") end + def test_A_connection_settings + begin + @settings.bogusAttribute = 25 + fail("Connection settings accepted bogus attribute") + rescue + end + end + def test_B_basic_method_invocation parent = @qmfc.object(:class => "parent") assert(parent, "Number of 'parent' objects") diff --git a/qpid/cpp/bindings/qmf/tests/test_base.rb b/qpid/cpp/bindings/qmf/tests/test_base.rb index 947753b02a..cb7fd9d4f9 100644 --- a/qpid/cpp/bindings/qmf/tests/test_base.rb +++ b/qpid/cpp/bindings/qmf/tests/test_base.rb @@ -31,7 +31,7 @@ class ConsoleTestBase < Qmf::ConsoleHandler @qmfc = Qmf::Console.new @broker = @qmfc.add_connection(@connection) - @broker.waitForStable + @broker.wait_for_stable tests = [] methods.each do |m| diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h index 33f7c85a94..36312400b1 100644 --- a/qpid/cpp/include/qmf/engine/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/engine/ConnectionSettings.h @@ -79,8 +79,10 @@ namespace engine { * * @param value Reference to a value to be stored as the attribute. The type of the value * is specific to the key. + * + * @return True if success, False if invalid attribute */ - QMFE_EXTERN void setAttr(const char* key, const Value& value); + QMFE_EXTERN bool setAttr(const char* key, const Value& value); /** * Get the value of an attribute. diff --git a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp index 8c918eec20..2cd6af10f8 100644 --- a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp +++ b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp @@ -56,7 +56,7 @@ ConnectionSettingsImpl::ConnectionSettingsImpl(const string& /*url*/) : // TODO: Parse the URL } -void ConnectionSettingsImpl::setAttr(const string& key, const Value& value) +bool ConnectionSettingsImpl::setAttr(const string& key, const Value& value) { if (key == attrProtocol) clientSettings.protocol = value.asString(); else if (key == attrHost) clientSettings.host = value.asString(); @@ -79,6 +79,9 @@ void ConnectionSettingsImpl::setAttr(const string& key, const Value& value) else if (key == attrRetryDelayMax) retryDelayMax = value.asUint(); else if (key == attrRetryDelayFactor) retryDelayFactor = value.asUint(); else if (key == attrSendUserId) sendUserId = value.asBool(); + else + return false; + return true; } Value ConnectionSettingsImpl::getAttr(const string& key) const @@ -257,7 +260,7 @@ ConnectionSettings::ConnectionSettings(const ConnectionSettings& from) { impl = ConnectionSettings::ConnectionSettings() { impl = new ConnectionSettingsImpl(); } ConnectionSettings::ConnectionSettings(const char* url) { impl = new ConnectionSettingsImpl(url); } ConnectionSettings::~ConnectionSettings() { delete impl; } -void ConnectionSettings::setAttr(const char* key, const Value& value) { impl->setAttr(key, value); } +bool ConnectionSettings::setAttr(const char* key, const Value& value) { return impl->setAttr(key, value); } Value ConnectionSettings::getAttr(const char* key) const { return impl->getAttr(key); } const char* ConnectionSettings::getAttrString() const { return impl->getAttrString().c_str(); } void ConnectionSettings::transportTcp(uint16_t port) { impl->transportTcp(port); } diff --git a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h index c47c8bee2e..98bf87868b 100644 --- a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h +++ b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h @@ -41,7 +41,7 @@ namespace engine { ConnectionSettingsImpl(); ConnectionSettingsImpl(const std::string& url); ~ConnectionSettingsImpl() {} - void setAttr(const std::string& key, const Value& value); + bool setAttr(const std::string& key, const Value& value); Value getAttr(const std::string& key) const; const std::string& getAttrString() const; void transportTcp(uint16_t port); |