summaryrefslogtreecommitdiff
path: root/qpid/cpp/bindings/qmf/tests
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-01-05 19:45:28 +0000
committerTed Ross <tross@apache.org>2010-01-05 19:45:28 +0000
commit25d63a161d11d504e51ead2f76e761f561503b69 (patch)
tree8f018d410a0d9ba554afc61f0f603407ffd1ecb6 /qpid/cpp/bindings/qmf/tests
parentf41fee09de1f40adc1323e7d811a5a76bc0b6edc (diff)
downloadqpid-python-25d63a161d11d504e51ead2f76e761f561503b69.tar.gz
Added handling of MAP values for the wrapped QMF interfaces.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@896191 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/bindings/qmf/tests')
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/agent_ruby.rb27
-rw-r--r--qpid/cpp/bindings/qmf/tests/python_agent.py46
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/ruby_console_test.rb38
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/run_interop_tests12
4 files changed, 121 insertions, 2 deletions
diff --git a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
index adf91a8b66..0be779994a 100755
--- a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
+++ b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
@@ -43,6 +43,8 @@ class Model
@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_property(Qmf::SchemaProperty.new("mapval", Qmf::TYPE_MAP))
+
@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")
@@ -53,6 +55,11 @@ class Model
method.add_argument(Qmf::SchemaArgument.new("test", Qmf::TYPE_SSTR, :dir => Qmf::DIR_IN))
@parent_class.add_method(method)
+ method = Qmf::SchemaMethod.new("set_map", :desc => "Set the map value in the object")
+ method.add_argument(Qmf::SchemaArgument.new("value", Qmf::TYPE_MAP, :dir => Qmf::DIR_IN))
+ method.add_argument(Qmf::SchemaArgument.new("output", Qmf::TYPE_MAP, :dir => Qmf::DIR_OUT))
+ @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)
@@ -101,19 +108,37 @@ class App < Qmf::AgentHandler
if name == "echo"
@agent.method_response(context, 0, "OK", args)
+ elsif name == "set_map"
+
+ map = args['value']
+
+ map['added'] = 'Added Text'
+ args['output'] = map
+
elsif name == "set_numerics"
if args['test'] == "big"
@parent.uint64val = 0x9494949449494949
@parent.uint32val = 0xa5a55a5a
@parent.uint16val = 0xb66b
- @parent.uint8val = 0xc7
+ @parent.uint8val = 0xc7
@parent.int64val = 1000000000000000000
@parent.int32val = 1000000000
@parent.int16val = 10000
@parent.int8val = 100
+ @parent.mapval = {'u64' => @parent.uint64val,
+ 'u32' => @parent.uint32val,
+ 'u16' => @parent.uint16val,
+ 'u8' => @parent.uint8val,
+ 'i64' => @parent.int64val,
+ 'i32' => @parent.int32val,
+ 'i16' => @parent.int16val,
+ 'i8' => @parent.int8val,
+ 'sstr' => "Short String",
+ 'map' => {'first' => 'FIRST', 'second' => 'SECOND'}}
+
elsif args['test'] == "small"
@parent.uint64val = 4
@parent.uint32val = 5
diff --git a/qpid/cpp/bindings/qmf/tests/python_agent.py b/qpid/cpp/bindings/qmf/tests/python_agent.py
index 0f5ffe5b8a..c42273d7b2 100644
--- a/qpid/cpp/bindings/qmf/tests/python_agent.py
+++ b/qpid/cpp/bindings/qmf/tests/python_agent.py
@@ -41,6 +41,12 @@ class Model:
self.parent_class.add_property(qmf.SchemaProperty("int16val", qmf.TYPE_INT16))
self.parent_class.add_property(qmf.SchemaProperty("int8val", qmf.TYPE_INT8))
+ self.parent_class.add_property(qmf.SchemaProperty("sstrval", qmf.TYPE_SSTR))
+ self.parent_class.add_property(qmf.SchemaProperty("lstrval", qmf.TYPE_LSTR))
+
+ self.parent_class.add_property(qmf.SchemaProperty("mapval", qmf.TYPE_MAP))
+
+
self.parent_class.add_statistic(qmf.SchemaStatistic("queryCount", qmf.TYPE_UINT32, {"unit":"query", "desc":"Query count"}))
_method = qmf.SchemaMethod("echo", {"desc":"Check responsiveness of the agent object"})
@@ -51,6 +57,19 @@ class Model:
_method.add_argument(qmf.SchemaArgument("test", qmf.TYPE_SSTR, {"dir":qmf.DIR_IN}))
self.parent_class.add_method(_method)
+ _method = qmf.SchemaMethod("set_map", {"desc":"Set the map value in the object"})
+ _method.add_argument(qmf.SchemaArgument("value", qmf.TYPE_MAP, {"dir":qmf.DIR_IN}))
+ _method.add_argument(qmf.SchemaArgument("output", qmf.TYPE_MAP, {"dir":qmf.DIR_OUT}))
+ self.parent_class.add_method(_method)
+
+ _method = qmf.SchemaMethod("set_short_string", {"desc":"Set the short string value in the object"})
+ _method.add_argument(qmf.SchemaArgument("value", qmf.TYPE_SSTR, {"dir":qmf.DIR_IN_OUT}))
+ self.parent_class.add_method(_method)
+
+ _method = qmf.SchemaMethod("set_long_string", {"desc":"Set the long string value in the object"})
+ _method.add_argument(qmf.SchemaArgument("value", qmf.TYPE_LSTR, {"dir":qmf.DIR_IN_OUT}))
+ self.parent_class.add_method(_method)
+
_method = qmf.SchemaMethod("create_child", {"desc":"Create a new child object"})
_method.add_argument(qmf.SchemaArgument("child_name", qmf.TYPE_LSTR, {"dir":qmf.DIR_IN}))
_method.add_argument(qmf.SchemaArgument("child_ref", qmf.TYPE_REF, {"dir":qmf.DIR_OUT}))
@@ -97,6 +116,12 @@ class App(qmf.AgentHandler):
if name == "echo":
self._agent.method_response(context, 0, "OK", args)
+ elif name == "set_map":
+ map = args['value']
+ map['added'] = "Added Text"
+ args['output'] = map
+ self._agent.method_response(context, 0, "OK", args)
+
elif name == "set_numerics":
_retCode = 0
_retText = "OK"
@@ -115,6 +140,17 @@ class App(qmf.AgentHandler):
self._parent["int16val"] = 10000
self._parent.set_attr("int8val", 100)
+ self._parent.set_attr("mapval", {'u64' : self._parent['uint64val'],
+ 'u32' : self._parent['uint32val'],
+ 'u16' : self._parent['uint16val'],
+ 'u8' : self._parent['uint8val'],
+ 'i64' : self._parent['int64val'],
+ 'i32' : self._parent['int32val'],
+ 'i16' : self._parent['int16val'],
+ 'i8' : self._parent['int8val'],
+ 'sstr' : "Short String",
+ 'map' : {'first' : 'FIRST', 'second' : 'SECOND'}})
+
## Test the __getattr__ implementation:
## @todo: remove once python_client implements this
## form of property access
@@ -150,6 +186,14 @@ class App(qmf.AgentHandler):
self._agent.method_response(context, _retCode, _retText, args)
+ elif name == "set_short_string":
+ self._parent.set_attr('sstrval', args['value'])
+ self._agent.method_response(context, 0, "OK", args)
+
+ elif name == "set_long_string":
+ self._parent.set_attr('lstrval', args['value'])
+ self._agent.method_response(context, 0, "OK", args)
+
elif name == "create_child":
#
# Instantiate an object based on the Child Schema Class
@@ -199,7 +243,7 @@ class App(qmf.AgentHandler):
## @todo how do we force a test failure?
# verify the properties() and statistics() object methods:
- assert len(self._parent.properties()) == 10
+ assert len(self._parent.properties()) == 13
assert len(self._parent.statistics()) == 1
self._parent.set_attr("name", "Parent One")
diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
index c5c7b141dd..3a771aaafd 100755
--- a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
+++ b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
@@ -177,6 +177,44 @@ class ConsoleTest < ConsoleTestBase
end
end
+ def test_C_basic_types_map
+ parent = @qmfc.object(:class =>"parent")
+ assert(parent, "Number of parent objects")
+
+ result = parent.set_numerics("big")
+ assert_equal(result.status, 0, "Method Response Status")
+ assert_equal(result.text, "OK", "Method Response Text")
+
+ parent.update
+
+ map = parent.mapval
+
+ assert_equal(map['u64'], 0x9494949449494949)
+ assert_equal(map['u32'], 0xA5A55A5A)
+ assert_equal(map['u16'], 0xB66B)
+ assert_equal(map['u8'], 0xC7)
+
+ assert_equal(map['i64'], 1000000000000000000)
+ assert_equal(map['i32'], 1000000000)
+ assert_equal(map['i16'], 10000)
+ assert_equal(map['i8'], 100)
+
+ assert_equal(map['sstr'], "Short String")
+
+ submap = map['map']
+ assert_equal(submap['first'], "FIRST")
+ assert_equal(submap['second'], "SECOND")
+
+ result = parent.set_map({'first' => 'FIRST', 'sub' => {'subfirst' => 25}})
+ assert_equal(result.status, 0, "Method Response Status")
+ assert_equal(result.text, "OK", "Method Response Text")
+
+ rmap = result.args.output
+ assert_equal(rmap['first'], "FIRST")
+ assert_equal(rmap['sub']['subfirst'], 25)
+ assert_equal(rmap['added'], 'Added Text')
+ end
+
def test_D_userid_for_method
parent = @qmfc.object(:class => "parent")
assert(parent, "Number of parent objects")
diff --git a/qpid/cpp/bindings/qmf/tests/run_interop_tests b/qpid/cpp/bindings/qmf/tests/run_interop_tests
index b5545d736d..1669fe0189 100755
--- a/qpid/cpp/bindings/qmf/tests/run_interop_tests
+++ b/qpid/cpp/bindings/qmf/tests/run_interop_tests
@@ -101,6 +101,18 @@ if test -d ${PYTHON_DIR} ; then
echo "FAIL qmf interop tests (Ruby Console/Ruby Agent)";
TESTS_FAILED=1
fi
+
+ if test -d ${PYTHON_LIB_DIR} ; then
+ echo " Python Agent (external storage) vs. Ruby Console"
+ start_python_agent
+ ruby -I${MY_DIR} -I${MY_DIR}/../ruby -I${RUBY_LIB_DIR} ${MY_DIR}/ruby_console_test.rb localhost $BROKER_PORT $@
+ RETCODE=$?
+ stop_python_agent
+ if test x$RETCODE != x0; then
+ echo "FAIL qmf interop tests (Ruby Console/Python Agent)";
+ TESTS_FAILED=1
+ fi
+ fi
fi
# Also against the Pure-Python console: