qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject qpid-proton git commit: PROTON-927: Encode message creation and expiry time as null if unset
Date Fri, 09 Feb 2018 05:17:33 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 1d72bdcb2 -> d47ded4ee


PROTON-927: Encode message creation and expiry time as null if unset


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d47ded4e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d47ded4e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d47ded4e

Branch: refs/heads/master
Commit: d47ded4ee829adb7bd1ebe7d4b7c285f43639f5c
Parents: 1d72bdc
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Thu Feb 8 18:28:27 2018 -0500
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Thu Feb 8 18:40:49 2018 -0500

----------------------------------------------------------------------
 proton-c/src/core/message.c          |  6 +--
 tests/python/proton_tests/message.py | 61 ++++++++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d47ded4e/proton-c/src/core/message.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c
index 15b6dea..d890678 100644
--- a/proton-c/src/core/message.c
+++ b/proton-c/src/core/message.c
@@ -813,7 +813,7 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data)
     pn_data_exit(data);
   }
 
-  err = pn_data_fill(data, "DL[CzSSSCssttSIS]", PROPERTIES,
+  err = pn_data_fill(data, "DL[CzSSSCss?t?tSIS]", PROPERTIES,
                      msg->id,
                      pn_string_size(msg->user_id), pn_string_get(msg->user_id),
                      pn_string_get(msg->address),
@@ -822,8 +822,8 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data)
                      msg->correlation_id,
                      pn_string_get(msg->content_type),
                      pn_string_get(msg->content_encoding),
-                     msg->expiry_time,
-                     msg->creation_time,
+                     (bool)msg->expiry_time, msg->expiry_time,
+                     (bool)msg->creation_time, msg->creation_time,
                      pn_string_get(msg->group_id),
                      msg->group_sequence,
                      pn_string_get(msg->reply_to_group_id));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d47ded4e/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index a7f1dad..1be8a73 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -133,7 +133,65 @@ class CodecTest(Test):
     assert self.msg.subject == msg2.subject, (self.msg.subject, msg2.subject)
     assert self.msg.body == msg2.body, (self.msg.body, msg2.body)
 
-  def testDefaultPriorityEncodeAndDecode(self):
+  def testExpiryEncodeAsNull(self):
+    data = self.msg.encode()
+
+    decoder = Data()
+
+    # Skip past the headers
+    consumed = decoder.decode(data)
+    decoder.clear()
+    data = data[consumed:]
+
+    decoder.decode(data)
+    dproperties = decoder.get_py_described()
+    # Check we've got the correct described list
+    assert dproperties.descriptor == 0x73, (dproperties.descriptor)
+
+    properties = dproperties.value
+    assert properties[8] == None, properties[8]
+
+  def testCreationEncodeAsNull(self):
+    data = self.msg.encode()
+
+    decoder = Data()
+
+    # Skip past the headers
+    consumed = decoder.decode(data)
+    decoder.clear()
+    data = data[consumed:]
+
+    decoder.decode(data)
+    dproperties = decoder.get_py_described()
+    # Check we've got the correct described list
+    assert dproperties.descriptor == 0x73, (dproperties.descriptor)
+
+    properties = dproperties.value
+    assert properties[9] == None, properties[9]
+
+  def testDefaultCreationExpiryDecode(self):
+    # This is a message with everything filled explicitly as null or zero in LIST32 HEADER
and PROPERTIES lists
+    data = str2bin('\x00\x53\x70\xd0\x00\x00\x00\x0a\x00\x00\x00\x05\x42\x40\x40\x42\x52\x00\x00\x53\x73\xd0\x00\x00\x00\x12\x00\x00\x00\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x52\x00\x40')
+    msg2 = Message()
+    msg2.decode(data)
+    assert msg2.expiry_time == 0, (msg2.expiry_time)
+    assert msg2.creation_time == 0, (msg2.creation_time)
+
+    # The same message with LIST8s instead
+    data = str2bin('\x00\x53\x70\xc0\x07\x05\x42\x40\x40\x42\x52\x00\x00\x53\x73\xc0\x0f\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x52\x00\x40')
+    msg3 = Message()
+    msg3.decode(data)
+    assert msg2.expiry_time == 0, (msg2.expiry_time)
+    assert msg2.creation_time == 0, (msg2.creation_time)
+
+    # Minified message with zero length HEADER and PROPERTIES lists
+    data = str2bin('\x00\x53\x70\x45' '\x00\x53\x73\x45')
+    msg4 = Message()
+    msg4.decode(data)
+    assert msg2.expiry_time == 0, (msg2.expiry_time)
+    assert msg2.creation_time == 0, (msg2.creation_time)
+
+  def testDefaultPriorityEncode(self):
     assert self.msg.priority == 4, (self.msg.priority)
     self.msg.ttl = 0.003 # field after priority, so forces priority to be present
     data = self.msg.encode()
@@ -149,6 +207,7 @@ class CodecTest(Test):
     headers = dheaders.value
     assert headers[1] == None, (headers[1])
 
+  def testDefaultPriorityDecode(self):
     # This is a message with everything filled explicitly as null or zero in LIST32 HEADER
and PROPERTIES lists
     data = str2bin('\x00\x53\x70\xd0\x00\x00\x00\x0a\x00\x00\x00\x05\x42\x40\x40\x42\x52\x00\x00\x53\x73\xd0\x00\x00\x00\x22\x00\x00\x00\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x83\x00\x00\x00\x00\x00\x00\x00\x00\x83\x00\x00\x00\x00\x00\x00\x00\x00\x40\x52\x00\x40')
     msg2 = Message()


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


Mime
View raw message