Author: tross Date: Tue Sep 22 20:11:30 2009 New Revision: 817813 URL: http://svn.apache.org/viewvc?rev=817813&view=rev Log: QMF updates: - Added "sendUserId" option (defaults to true) to QMF connection settings - Implemented the user-id function using "negotiatedSettings" from qpid::client::Connection - Fixed a sign-extension bug in Value - Added tests for all of the above
Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/agent_ruby.rb qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.h qpid/trunk/qpid/cpp/src/qmf/ResilientConnection.cpp qpid/trunk/qpid/cpp/src/qmf/ValueImpl.cpp Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/agent_ruby.rb URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/tests/agent_ruby.rb?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qmf/tests/agent_ruby.rb (original) +++ qpid/trunk/qpid/cpp/bindings/qmf/tests/agent_ruby.rb Tue Sep 22 20:11:30 2009 @@ -40,6 +40,9 @@ @parent_class.add_property(Qmf::SchemaProperty.new("int16val", Qmf::TYPE_INT16)) @parent_class.add_property(Qmf::SchemaProperty.new("int8val", Qmf::TYPE_INT8)) + @parent_class.add_property(Qmf::SchemaProperty.new("sstrval", Qmf::TYPE_SSTR)) + @parent_class.add_property(Qmf::SchemaProperty.new("lstrval", Qmf::TYPE_LSTR)) + @parent_class.add_statistic(Qmf::SchemaStatistic.new("queryCount", Qmf::TYPE_UINT32, :unit => "query", :desc => "Query count")) method = Qmf::SchemaMethod.new("echo", :desc => "Check responsiveness of the agent object") @@ -50,6 +53,14 @@ method.add_argument(Qmf::SchemaArgument.new("test", Qmf::TYPE_SSTR, :dir => Qmf::DIR_IN)) @parent_class.add_method(method) + method = Qmf::SchemaMethod.new("set_short_string", :desc => "Set the short string value in the object") + method.add_argument(Qmf::SchemaArgument.new("value", Qmf::TYPE_SSTR, :dir => Qmf::DIR_IN_OUT)) + @parent_class.add_method(method) + + method = Qmf::SchemaMethod.new("set_long_string", :desc => "Set the long string value in the object") + method.add_argument(Qmf::SchemaArgument.new("value", Qmf::TYPE_LSTR, :dir => Qmf::DIR_IN_OUT)) + @parent_class.add_method(method) + method = Qmf::SchemaMethod.new("create_child", :desc => "Create a new child object") method.add_argument(Qmf::SchemaArgument.new("child_name", Qmf::TYPE_LSTR, :dir => Qmf::DIR_IN)) method.add_argument(Qmf::SchemaArgument.new("child_ref", Qmf::TYPE_REF, :dir => Qmf::DIR_OUT)) @@ -84,12 +95,13 @@ def method_call(context, name, object_id, args, userId) # puts "Method: user=#{userId} context=#{context} method=#{name} object_num=#{object_id.object_num_low if object_id} args=#{args}" + retCode = 0 + retText = "OK" + if name == "echo" @agent.method_response(context, 0, "OK", args) elsif name == "set_numerics" - retCode = 0 - retText = "OK" if args['test'] == "big" @parent.uint64val = 0x9494949449494949 @@ -129,7 +141,11 @@ retText = "Invalid argument value for test" end - @agent.method_response(context, retCode, retText, args) + elsif name == "set_short_string" + @parent.sstrval = args['value'] + + elsif name == "set_long_string" + @parent.lstrval = args['value'] elsif name == "create_child" oid = @agent.alloc_object_id(2) @@ -137,15 +153,16 @@ @child = Qmf::AgentObject.new(@model.child_class) @child.name = args.by_key("child_name") @child.set_object_id(oid) - @agent.method_response(context, 0, "OK", args) elsif name == "probe_userid" args['userid'] = userId - @agent.method_response(context, 0, "OK", args) else - @agent.method_response(context, 1, "Unimplemented Method: #{name}", args) + retCode = 1 + retText = "Unimplemented Method: #{name}" end + + @agent.method_response(context, retCode, retText, args) end def main Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb (original) +++ qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb Tue Sep 22 20:11:30 2009 @@ -97,7 +97,7 @@ assert_equal(parent.int8val, 11) end - def _test_C_basic_types_numeric_negative + def test_C_basic_types_numeric_negative parents = @qmfc.get_objects(Qmf::Query.new(:class =>"parent")) assert_equal(parents.size, 1, "Number of parent objects") parent = parents[0] @@ -119,14 +119,68 @@ assert_equal(parent.int8val, -100) end - def _test_D_userid_for_method + def test_C_basic_types_string_short + parents = @qmfc.get_objects(Qmf::Query.new(:class =>"parent")) + assert_equal(parents.size, 1, "Number of parent objects") + parent = parents[0] + + strings = [] + strings << "" + strings << "A" + strings << "BC" + strings << "DEF" + strings << "GHIJKLMNOPQRSTUVWXYZ" + big = "a" + for i in 0...270 + big << "X" + end + strings << big + + strings.each do |str| + result = parent.set_short_string(str) + assert_equal(result.status, 0, "Method Response Status") + compare = str + compare = compare[0..254] if compare.size > 255 + assert_equal(result.args.value, compare, "Value returned by method") + parent.update + assert_equal(parent.sstrval, compare, "Value stored in the object") + end + end + + def test_C_basic_types_string_long + parents = @qmfc.get_objects(Qmf::Query.new(:class =>"parent")) + assert_equal(parents.size, 1, "Number of parent objects") + parent = parents[0] + + strings = [] + strings << "" + strings << "A" + strings << "BC" + strings << "DEF" + strings << "GHIJKLMNOPQRSTUVWXYZ" + big = "a" + for i in 0...270 + big << "X" + end + strings << big + + strings.each do |str| + result = parent.set_long_string(str) + assert_equal(result.status, 0, "Method Response Status") + assert_equal(result.args.value, str, "Value returned by method") + parent.update + assert_equal(parent.lstrval, str, "Value stored in the object") + end + end + + def test_D_userid_for_method parents = @qmfc.get_objects(Qmf::Query.new(:class => "parent")) assert_equal(parents.size, 1, "Number of parent objects") parent = parents[0] result = parent.probe_userid assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.args.userid, "guest") + assert_equal(result.args.userid, "anonymous") end end Modified: qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp (original) +++ qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp Tue Sep 22 20:11:30 2009 @@ -43,14 +43,15 @@ const string attrRetryDelayMin("retryDelayMin"); const string attrRetryDelayMax("retryDelayMax"); const string attrRetryDelayFactor("retryDelayFactor"); +const string attrSendUserId("sendUserId"); ConnectionSettingsImpl::ConnectionSettingsImpl() : - retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2) + retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2), sendUserId(true) { } ConnectionSettingsImpl::ConnectionSettingsImpl(const string& /*url*/) : - retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2) + retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2), sendUserId(true) { // TODO: Parse the URL } @@ -77,6 +78,7 @@ else if (key == attrRetryDelayMin) retryDelayMin = value.asUint(); else if (key == attrRetryDelayMax) retryDelayMax = value.asUint(); else if (key == attrRetryDelayFactor) retryDelayFactor = value.asUint(); + else if (key == attrSendUserId) sendUserId = value.asBool(); } Value ConnectionSettingsImpl::getAttr(const string& key) const Modified: qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.h URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.h?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.h (original) +++ qpid/trunk/qpid/cpp/src/qmf/ConnectionSettingsImpl.h Tue Sep 22 20:11:30 2009 @@ -34,6 +34,7 @@ int retryDelayMin; int retryDelayMax; int retryDelayFactor; + bool sendUserId; public: ConnectionSettingsImpl(); @@ -52,6 +53,7 @@ const qpid::client::ConnectionSettings& getClientSettings() const; void getRetrySettings(int* delayMin, int* delayMax, int* delayFactor) const; + bool getSendUserId() const { return sendUserId; } }; } Modified: qpid/trunk/qpid/cpp/src/qmf/ResilientConnection.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/ResilientConnection.cpp?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/qmf/ResilientConnection.cpp (original) +++ qpid/trunk/qpid/cpp/src/qmf/ResilientConnection.cpp Tue Sep 22 20:11:30 2009 @@ -65,13 +65,12 @@ client::Connection& connection; client::Session session; client::SubscriptionManager* subscriptions; + string userId; void* userContext; vector<string> dests; qpid::sys::Thread thread; - RCSession(ResilientConnectionImpl& ci, const string& n, client::Connection& c, void* uc) : - connImpl(ci), name(n), connection(c), session(connection.newSession(name)), - subscriptions(new client::SubscriptionManager(session)), userContext(uc), thread(*this) {} + RCSession(ResilientConnectionImpl& ci, const string& n, client::Connection& c, void* uc); ~RCSession(); void received(client::Message& msg); void run(); @@ -135,6 +134,14 @@ return item; } +RCSession::RCSession(ResilientConnectionImpl& ci, const string& n, client::Connection& c, void* uc) : + connImpl(ci), name(n), connection(c), session(connection.newSession(name)), + subscriptions(new client::SubscriptionManager(session)), userContext(uc), thread(*this) +{ + const qpid::client::ConnectionSettings& operSettings = connection.getNegotiatedSettings(); + userId = operSettings.username; +} + RCSession::~RCSession() { subscriptions->stop(); @@ -254,6 +261,8 @@ string data(message.body, message.length); msg.getDeliveryProperties().setRoutingKey(message.routingKey); msg.getMessageProperties().setReplyTo(qpid::framing::ReplyTo(message.replyExchange, message.replyKey)); + if (settings.impl->getSendUserId()) + msg.getMessageProperties().setUserId(sess->userId); msg.setData(data); try { Modified: qpid/trunk/qpid/cpp/src/qmf/ValueImpl.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/ValueImpl.cpp?rev=817813&r1=817812&r2=817813&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/qmf/ValueImpl.cpp (original) +++ qpid/trunk/qpid/cpp/src/qmf/ValueImpl.cpp Tue Sep 22 20:11:30 2009 @@ -42,8 +42,8 @@ case TYPE_BOOL : value.boolVal = (buf.getOctet() != 0); break; case TYPE_FLOAT : value.floatVal = buf.getFloat(); break; case TYPE_DOUBLE : value.doubleVal = buf.getDouble(); break; - case TYPE_INT8 : value.s32 = (int32_t) buf.getOctet(); break; - case TYPE_INT16 : value.s32 = (int32_t) buf.getShort(); break; + case TYPE_INT8 : value.s32 = (int32_t) ((int8_t) buf.getOctet()); break; + case TYPE_INT16 : value.s32 = (int32_t) ((int16_t) buf.getShort()); break; case TYPE_INT32 : value.s32 = (int32_t) buf.getLong(); break; case TYPE_INT64 : value.s64 = buf.getLongLong(); break; case TYPE_UUID : buf.getBin128(value.uuidVal); break; --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org