You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2018/01/15 19:09:27 UTC

qpid-interop-test git commit: QPIDIT-107: Added support for new Proton API access to message properties. Tested against Proton Python and Qpid JMS shims, works correctly.

Repository: qpid-interop-test
Updated Branches:
  refs/heads/master d6d837edd -> 9b662ec6f


QPIDIT-107: Added support for new Proton API access to message properties. Tested against Proton Python and Qpid JMS shims, works correctly.


Project: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/commit/9b662ec6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/tree/9b662ec6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/diff/9b662ec6

Branch: refs/heads/master
Commit: 9b662ec6f14ed620a21590d8ada182050efff846
Parents: d6d837e
Author: Kim van der Riet <kv...@localhost.localdomain>
Authored: Mon Jan 15 14:09:11 2018 -0500
Committer: Kim van der Riet <kv...@localhost.localdomain>
Committed: Mon Jan 15 14:09:11 2018 -0500

----------------------------------------------------------------------
 .../src/qpidit/jms_hdrs_props_test/Receiver.cpp | 48 ++++++++++++++++++--
 .../src/qpidit/jms_hdrs_props_test/Sender.cpp   | 18 ++++----
 .../src/qpidit/jms_hdrs_props_test/Sender.hpp   |  4 --
 .../qpid_interop_test/jms_hdrs_props_test.py    |  4 +-
 4 files changed, 56 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/9b662ec6/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Receiver.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Receiver.cpp b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Receiver.cpp
index ae78d5e..8c8b7d9 100644
--- a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Receiver.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Receiver.cpp
@@ -404,9 +404,51 @@ namespace qpidit
         }
 
         void Receiver::processMessageProperties(const proton::message& msg) {
-            // TODO: Add this function when PROTON-1284 is fixed
-//            std::map<proton::value, proton::value> props;
-//            msg.properties().value() >> props;
+            // Find keys in map, iterate through them
+            typedef std::map<std::string, proton::scalar> property_map;
+            property_map props;
+            proton::get(msg.properties(), props);
+            for (property_map::const_iterator i=props.begin(); i!=props.end(); ++i) {
+                std::size_t ui1 = i->first.find('_');
+                std::size_t ui2 = i->first.find('_', ui1 + 1);
+                if (ui1 == 4 && ui2 > 5) { // ignore other properties that may be present
+                    std::string jmsPropertyType(i->first.substr(ui1+1, ui2-ui1-1));
+                    proton::scalar value(props[i->first]);
+                    Json::Value valueMap(Json::objectValue);
+                    if (jmsPropertyType.compare("boolean") == 0) {
+                        valueMap["boolean"] = proton::get<bool>(value)?"True":"False";
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("byte") == 0) {
+                        valueMap["byte"] = toHexStr<int8_t>(proton::get<int8_t>(value));
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("double") == 0) {
+                        //int64_t val = be64toh(*((int64_t*)body.data()));
+                        //std::cout << "value=" << value << std::endl;
+                        double d = proton::get<double>(value);
+                        //std::cout << "d=" << d << std::endl;
+                        //std::cout << std::hex << "d=0x" << (*((int64_t*)&d)) << std::endl;
+                        valueMap["double"] = toHexStr<int64_t>(*((int64_t*)&d), true, false);
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("float") == 0) {
+                        float f = proton::get<float>(value);
+                        valueMap["float"] = toHexStr<int32_t>(*((int32_t*)&f), true, false);
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("int") == 0) {
+                        valueMap["int"] = toHexStr<int32_t>(proton::get<int32_t>(value));;
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("long") == 0) {
+                        valueMap["long"] = toHexStr<int64_t>(proton::get<int64_t>(value));
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("short") == 0) {
+                        valueMap["short"] = toHexStr<int16_t>(proton::get<int16_t>(value));
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    } else if (jmsPropertyType.compare("string") == 0) {
+                        valueMap["string"] = proton::get<std::string>(value);
+                        _receivedPropertiesMap[i->first] = valueMap;
+                    }
+                    // Ignore any non-compliant types, no final else or throw
+                }
+            }
         }
 
         //static

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/9b662ec6/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.cpp b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.cpp
index f78206a..ec8b024 100644
--- a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.cpp
@@ -359,23 +359,23 @@ namespace qpidit
                 const std::string propertyValueType = _subMap.getMemberNames()[0]; // There is always only one entry in map
                 std::string val = _subMap[propertyValueType].asString();
                 if (propertyValueType.compare("boolean") == 0) {
-                    if (val.compare("False") == 0) setMessageProperty(msg, *i, false);
-                    else if (val.compare("True") == 0) setMessageProperty(msg, *i, true);
+                    if (val.compare("False") == 0) msg.properties().put(*i, false);
+                    else if (val.compare("True") == 0) msg.properties().put(*i, true);
                     else throw InvalidTestValueError(propertyValueType, val);
                 } else if (propertyValueType.compare("byte") == 0) {
-                    setMessageProperty(msg, *i, getIntegralValue<int8_t>(val));
+                    msg.properties().put(*i, getIntegralValue<int8_t>(val));
                 } else if (propertyValueType.compare("double") == 0) {
-                    setMessageProperty(msg, *i, getFloatValue<double, uint64_t>(val));
+                    msg.properties().put(*i, getFloatValue<double, uint64_t>(val));
                 } else if (propertyValueType.compare("float") == 0) {
-                    setMessageProperty(msg, *i, getFloatValue<float, uint64_t>(val));
+                    msg.properties().put(*i, getFloatValue<float, uint64_t>(val));
                 } else if (propertyValueType.compare("int") == 0) {
-                    setMessageProperty(msg, *i, getIntegralValue<int32_t>(val));
+                    msg.properties().put(*i, getIntegralValue<int32_t>(val));
                 } else if (propertyValueType.compare("long") == 0) {
-                    setMessageProperty(msg, *i, getIntegralValue<int64_t>(val));
+                    msg.properties().put(*i, getIntegralValue<int64_t>(val));
                 } else if (propertyValueType.compare("short") == 0) {
-                    setMessageProperty(msg, *i, getIntegralValue<int16_t>(val));
+                    msg.properties().put(*i, getIntegralValue<int16_t>(val));
                 } else if (propertyValueType.compare("string") == 0) {
-                    setMessageProperty(msg, *i, val);
+                    msg.properties().put(*i, val);
                 } else {
                     throw qpidit::UnknownJmsPropertyTypeError(propertyValueType);
                 }

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/9b662ec6/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.hpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.hpp b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.hpp
index c2e1fdc..4b5d6e7 100644
--- a/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/jms_hdrs_props_test/Sender.hpp
@@ -72,10 +72,6 @@ namespace qpidit
             static proton::message& setJmsReplyTo(proton::message& msg, const std::string& dt, const std::string& d);
 
             proton::message& addMessageProperties(proton::message& msg);
-            template<typename T> proton::message& setMessageProperty(proton::message& msg, const std::string& propertyName, T val) {
-                msg.properties().put(propertyName, val);
-                return msg;
-            }
 
             static proton::binary getJavaObjectBinary(const std::string& javaClassName, const std::string& valAsString);
             static uint32_t getTotalNumMessages(const Json::Value& testValueMap);

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/9b662ec6/src/python/qpid_interop_test/jms_hdrs_props_test.py
----------------------------------------------------------------------
diff --git a/src/python/qpid_interop_test/jms_hdrs_props_test.py b/src/python/qpid_interop_test/jms_hdrs_props_test.py
index 15a0572..6b3aded 100755
--- a/src/python/qpid_interop_test/jms_hdrs_props_test.py
+++ b/src/python/qpid_interop_test/jms_hdrs_props_test.py
@@ -373,8 +373,8 @@ def create_testcases():
     # TODO: Add part C and D (properties) when C++ client can handle them
 
     # Part C: Single message property on each message
-    #test_case_class_c = create_part_c_testcase_class()
-    #TEST_SUITE.addTest(unittest.makeSuite(test_case_class_c))
+    test_case_class_c = create_part_c_testcase_class()
+    TEST_SUITE.addTest(unittest.makeSuite(test_case_class_c))
 
     # Part D: All headers and all properties on one of each type of JMS message
     #for jms_message_type in sorted(TYPES.TYPE_MAP.keys()):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org