qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: NO-JIRA: Measure size of encoded data.
Date Mon, 16 Mar 2015 16:45:22 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 7b9b516d4 -> fac7c86c8


NO-JIRA: Measure size of encoded data.

Introduce pn_data_size() to calculate the buffer space required to encode a data object.

- encoder.c measures full size of data.
- interop.py verifies computed size matches actual decode size.
- update java/jython compatilbility layer.

Code review at https://github.com/apache/qpid-proton/pull/11.

Did not (yet) implement size caching as suggested in the review as invalidating
the cache is a little involved. Leaving it for another day.


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

Branch: refs/heads/master
Commit: fac7c86c8bc818ea845d6426fd85095a189522d6
Parents: 7b9b516
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Mar 16 12:38:04 2015 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Mar 16 12:44:53 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py     |   6 +
 proton-c/include/proton/codec.h                 |   9 +
 proton-c/src/codec/codec.c                      |   5 +
 proton-c/src/codec/encoder.c                    | 182 ++++++++-----------
 proton-c/src/codec/encoder.h                    |   1 +
 .../java/org/apache/qpid/proton/codec/Data.java |   1 +
 .../apache/qpid/proton/codec/impl/DataImpl.java |  10 +-
 proton-j/src/main/resources/ccodec.py           |   3 +
 tests/python/proton_tests/interop.py            |   8 +-
 9 files changed, 119 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index d69d3dc..68a499e 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -1515,6 +1515,12 @@ class Data:
     else:
       return dtype
 
+  def encoded_size(self):
+    """
+    Returns the size in bytes needed to encode the data in AMQP format.
+    """
+    return pn_data_encoded_size(self._data)
+
   def encode(self):
     """
     Returns a representation of the data encoded in AMQP format.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-c/include/proton/codec.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/codec.h b/proton-c/include/proton/codec.h
index c9e2d07..4c4d2c3 100644
--- a/proton-c/include/proton/codec.h
+++ b/proton-c/include/proton/codec.h
@@ -512,6 +512,15 @@ PN_EXTERN int pn_data_format(pn_data_t *data, char *bytes, size_t *size);
 PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size);
 
 /**
+ * Returns the number of bytes needed to encode a data object.
+ *
+ * @param data the data object
+ *
+ * @param ssize_t returns the size of the encoded data or an error code if data is invalid.
+ */
+PN_EXTERN ssize_t pn_data_encoded_size(pn_data_t *data);
+
+/**
  * Decodes a single value from the contents of the AMQP data stream
  * into the current data object. Note that if the pn_data_t object is
  * pointing to a current node, the decoded value will overwrite the

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-c/src/codec/codec.c
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/codec.c b/proton-c/src/codec/codec.c
index 49a03a8..25d3701 100644
--- a/proton-c/src/codec/codec.c
+++ b/proton-c/src/codec/codec.c
@@ -1423,6 +1423,11 @@ ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size)
   return pn_encoder_encode(data->encoder, data, bytes, size);
 }
 
+ssize_t pn_data_encoded_size(pn_data_t *data)
+{
+  return pn_encoder_size(data->encoder, data);
+}
+
 ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size)
 {
   return pn_decoder_decode(data->decoder, bytes, size, data);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-c/src/codec/encoder.c
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/encoder.c b/proton-c/src/codec/encoder.c
index 2b9218f..f960655 100644
--- a/proton-c/src/codec/encoder.c
+++ b/proton-c/src/codec/encoder.c
@@ -150,52 +150,44 @@ static uint8_t pn_node2code(pn_encoder_t *encoder, pni_node_t *node)
   }
 }
 
-static size_t pn_encoder_remaining(pn_encoder_t *encoder)
-{
-  return encoder->output ? (encoder->output + encoder->size - encoder->position)
: 0;
+static size_t pn_encoder_remaining(pn_encoder_t *encoder) {
+  char * end = encoder->output + encoder->size;
+  if (end > encoder->position)
+    return end - encoder->position;
+  else
+    return 0;
 }
 
-static inline int pn_encoder_writef8(pn_encoder_t *encoder, uint8_t value)
+static inline void pn_encoder_writef8(pn_encoder_t *encoder, uint8_t value)
 {
   if (pn_encoder_remaining(encoder)) {
     encoder->position[0] = value;
-    encoder->position++;
-    return 0;
-  } else {
-    return PN_OVERFLOW;
   }
+  encoder->position++;
 }
 
-static inline int pn_encoder_writef16(pn_encoder_t *encoder, uint16_t value)
+static inline void pn_encoder_writef16(pn_encoder_t *encoder, uint16_t value)
 {
-  if (pn_encoder_remaining(encoder) < 2) {
-    return PN_OVERFLOW;
-  } else {
+  if (pn_encoder_remaining(encoder) >= 2) {
     encoder->position[0] = 0xFF & (value >> 8);
     encoder->position[1] = 0xFF & (value     );
-    encoder->position += 2;
-    return 0;
   }
+  encoder->position += 2;
 }
 
-static inline int pn_encoder_writef32(pn_encoder_t *encoder, uint32_t value)
+static inline void pn_encoder_writef32(pn_encoder_t *encoder, uint32_t value)
 {
-  if (pn_encoder_remaining(encoder) < 4) {
-    return PN_OVERFLOW;
-  } else {
+  if (pn_encoder_remaining(encoder) >= 4) {
     encoder->position[0] = 0xFF & (value >> 24);
     encoder->position[1] = 0xFF & (value >> 16);
     encoder->position[2] = 0xFF & (value >>  8);
     encoder->position[3] = 0xFF & (value      );
-    encoder->position += 4;
-    return 0;
   }
+  encoder->position += 4;
 }
 
-static inline int pn_encoder_writef64(pn_encoder_t *encoder, uint64_t value) {
-  if (pn_encoder_remaining(encoder) < 8) {
-    return PN_OVERFLOW;
-  } else {
+static inline void pn_encoder_writef64(pn_encoder_t *encoder, uint64_t value) {
+  if (pn_encoder_remaining(encoder) >= 8) {
     encoder->position[0] = 0xFF & (value >> 56);
     encoder->position[1] = 0xFF & (value >> 48);
     encoder->position[2] = 0xFF & (value >> 40);
@@ -204,45 +196,31 @@ static inline int pn_encoder_writef64(pn_encoder_t *encoder, uint64_t
value) {
     encoder->position[5] = 0xFF & (value >> 16);
     encoder->position[6] = 0xFF & (value >>  8);
     encoder->position[7] = 0xFF & (value      );
-    encoder->position += 8;
-    return 0;
   }
+  encoder->position += 8;
 }
 
-static inline int pn_encoder_writef128(pn_encoder_t *encoder, char *value) {
-  if (pn_encoder_remaining(encoder) < 16) {
-    return PN_OVERFLOW;
-  } else {
+static inline void pn_encoder_writef128(pn_encoder_t *encoder, char *value) {
+  if (pn_encoder_remaining(encoder) >= 16) {
     memmove(encoder->position, value, 16);
-    encoder->position += 16;
-    return 0;
   }
+  encoder->position += 16;
 }
 
-static inline int pn_encoder_writev8(pn_encoder_t *encoder, const pn_bytes_t *value)
+static inline void pn_encoder_writev8(pn_encoder_t *encoder, const pn_bytes_t *value)
 {
-  if (pn_encoder_remaining(encoder) < 1 + value->size) {
-    return PN_OVERFLOW;
-  } else {
-    int e = pn_encoder_writef8(encoder, value->size);
-    if (e) return e;
+  pn_encoder_writef8(encoder, value->size);
+  if (pn_encoder_remaining(encoder) >= value->size)
     memmove(encoder->position, value->start, value->size);
-    encoder->position += value->size;
-    return 0;
-  }
+  encoder->position += value->size;
 }
 
-static inline int pn_encoder_writev32(pn_encoder_t *encoder, const pn_bytes_t *value)
+static inline void pn_encoder_writev32(pn_encoder_t *encoder, const pn_bytes_t *value)
 {
-  if (pn_encoder_remaining(encoder) < 4 + value->size) {
-    return PN_OVERFLOW;
-  } else {
-    int e = pn_encoder_writef32(encoder, value->size);
-    if (e) return e;
+  pn_encoder_writef32(encoder, value->size);
+  if (pn_encoder_remaining(encoder) >= value->size)
     memmove(encoder->position, value->start, value->size);
-    encoder->position += value->size;
-    return 0;
-  }
+  encoder->position += value->size;
 }
 
 /* True if node is an element of an array - not the descriptor. */
@@ -271,7 +249,6 @@ static int pni_encoder_enter(void *ctx, pn_data_t *data, pni_node_t *node)
 {
   pn_encoder_t *encoder = (pn_encoder_t *) ctx;
   pni_node_t *parent = pn_data_node(data, node->parent);
-  int err;
   pn_atom_t *atom = &node->atom;
   uint8_t code;
   conv_t c;
@@ -280,13 +257,11 @@ static int pni_encoder_enter(void *ctx, pn_data_t *data, pni_node_t
*node)
   if (pn_is_in_array(data, parent, node)) {
     code = pn_type2code(encoder, parent->type);
     if (pn_is_first_in_array(data, parent, node)) {
-      err = pn_encoder_writef8(encoder, code);
-      if (err) return err;
+      pn_encoder_writef8(encoder, code);
     }
   } else {
     code = pn_node2code(encoder, node);
-    err = pn_encoder_writef8(encoder, code);
-    if (err) return err;
+    pn_encoder_writef8(encoder, code);
   }
 
   switch (code) {
@@ -294,57 +269,51 @@ static int pni_encoder_enter(void *ctx, pn_data_t *data, pni_node_t
*node)
   case PNE_NULL:
   case PNE_TRUE:
   case PNE_FALSE: return 0;
-  case PNE_BOOLEAN: return pn_encoder_writef8(encoder, atom->u.as_bool);
-  case PNE_UBYTE: return pn_encoder_writef8(encoder, atom->u.as_ubyte);
-  case PNE_BYTE: return pn_encoder_writef8(encoder, atom->u.as_byte);
-  case PNE_USHORT: return pn_encoder_writef16(encoder, atom->u.as_ushort);
-  case PNE_SHORT: return pn_encoder_writef16(encoder, atom->u.as_short);
+  case PNE_BOOLEAN: pn_encoder_writef8(encoder, atom->u.as_bool); return 0;
+  case PNE_UBYTE: pn_encoder_writef8(encoder, atom->u.as_ubyte); return 0;
+  case PNE_BYTE: pn_encoder_writef8(encoder, atom->u.as_byte); return 0;
+  case PNE_USHORT: pn_encoder_writef16(encoder, atom->u.as_ushort); return 0;
+  case PNE_SHORT: pn_encoder_writef16(encoder, atom->u.as_short); return 0;
   case PNE_UINT0: return 0;
-  case PNE_SMALLUINT: return pn_encoder_writef8(encoder, atom->u.as_uint);
-  case PNE_UINT: return pn_encoder_writef32(encoder, atom->u.as_uint);
-  case PNE_SMALLINT: return pn_encoder_writef8(encoder, atom->u.as_int);
-  case PNE_INT: return pn_encoder_writef32(encoder, atom->u.as_int);
-  case PNE_UTF32: return pn_encoder_writef32(encoder, atom->u.as_char);
-  case PNE_ULONG: return pn_encoder_writef64(encoder, atom->u.as_ulong);
-  case PNE_SMALLULONG: return pn_encoder_writef8(encoder, atom->u.as_ulong);
-  case PNE_LONG: return pn_encoder_writef64(encoder, atom->u.as_long);
-  case PNE_SMALLLONG: return pn_encoder_writef8(encoder, atom->u.as_long);
-  case PNE_MS64: return pn_encoder_writef64(encoder, atom->u.as_timestamp);
-  case PNE_FLOAT: c.f = atom->u.as_float; return pn_encoder_writef32(encoder, c.i);
-  case PNE_DOUBLE: c.d = atom->u.as_double; return pn_encoder_writef64(encoder, c.l);
-  case PNE_DECIMAL32: return pn_encoder_writef32(encoder, atom->u.as_decimal32);
-  case PNE_DECIMAL64: return pn_encoder_writef64(encoder, atom->u.as_decimal64);
-  case PNE_DECIMAL128: return pn_encoder_writef128(encoder, atom->u.as_decimal128.bytes);
-  case PNE_UUID: return pn_encoder_writef128(encoder, atom->u.as_uuid.bytes);
-  case PNE_VBIN8: return pn_encoder_writev8(encoder, &atom->u.as_bytes);
-  case PNE_VBIN32: return pn_encoder_writev32(encoder, &atom->u.as_bytes);
-  case PNE_STR8_UTF8: return pn_encoder_writev8(encoder, &atom->u.as_bytes);
-  case PNE_STR32_UTF8: return pn_encoder_writev32(encoder, &atom->u.as_bytes);
-  case PNE_SYM8: return pn_encoder_writev8(encoder, &atom->u.as_bytes);
-  case PNE_SYM32: return pn_encoder_writev32(encoder, &atom->u.as_bytes);
+  case PNE_SMALLUINT: pn_encoder_writef8(encoder, atom->u.as_uint); return 0;
+  case PNE_UINT: pn_encoder_writef32(encoder, atom->u.as_uint); return 0;
+  case PNE_SMALLINT: pn_encoder_writef8(encoder, atom->u.as_int); return 0;
+  case PNE_INT: pn_encoder_writef32(encoder, atom->u.as_int); return 0;
+  case PNE_UTF32: pn_encoder_writef32(encoder, atom->u.as_char); return 0;
+  case PNE_ULONG: pn_encoder_writef64(encoder, atom->u.as_ulong); return 0;
+  case PNE_SMALLULONG: pn_encoder_writef8(encoder, atom->u.as_ulong); return 0;
+  case PNE_LONG: pn_encoder_writef64(encoder, atom->u.as_long); return 0;
+  case PNE_SMALLLONG: pn_encoder_writef8(encoder, atom->u.as_long); return 0;
+  case PNE_MS64: pn_encoder_writef64(encoder, atom->u.as_timestamp); return 0;
+  case PNE_FLOAT: c.f = atom->u.as_float; pn_encoder_writef32(encoder, c.i); return 0;
+  case PNE_DOUBLE: c.d = atom->u.as_double; pn_encoder_writef64(encoder, c.l); return
0;
+  case PNE_DECIMAL32: pn_encoder_writef32(encoder, atom->u.as_decimal32); return 0;
+  case PNE_DECIMAL64: pn_encoder_writef64(encoder, atom->u.as_decimal64); return 0;
+  case PNE_DECIMAL128: pn_encoder_writef128(encoder, atom->u.as_decimal128.bytes); return
0;
+  case PNE_UUID: pn_encoder_writef128(encoder, atom->u.as_uuid.bytes); return 0;
+  case PNE_VBIN8: pn_encoder_writev8(encoder, &atom->u.as_bytes); return 0;
+  case PNE_VBIN32: pn_encoder_writev32(encoder, &atom->u.as_bytes); return 0;
+  case PNE_STR8_UTF8: pn_encoder_writev8(encoder, &atom->u.as_bytes); return 0;
+  case PNE_STR32_UTF8: pn_encoder_writev32(encoder, &atom->u.as_bytes); return 0;
+  case PNE_SYM8: pn_encoder_writev8(encoder, &atom->u.as_bytes); return 0;
+  case PNE_SYM32: pn_encoder_writev32(encoder, &atom->u.as_bytes); return 0;
   case PNE_ARRAY32:
     node->start = encoder->position;
     node->small = false;
     // we'll backfill the size on exit
-    if (pn_encoder_remaining(encoder) < 4) return PN_OVERFLOW;
     encoder->position += 4;
-
-    err = pn_encoder_writef32(encoder, node->described ? node->children - 1 : node->children);
-    if (err) return err;
-
-    if (node->described) {
-      err = pn_encoder_writef8(encoder, 0);
-      if (err) return err;
-    }
+    pn_encoder_writef32(encoder, node->described ? node->children - 1 : node->children);
+    if (node->described)
+      pn_encoder_writef8(encoder, 0);
     return 0;
   case PNE_LIST32:
   case PNE_MAP32:
     node->start = encoder->position;
     node->small = false;
     // we'll backfill the size later
-    if (pn_encoder_remaining(encoder) < 4) return PN_OVERFLOW;
     encoder->position += 4;
-    return pn_encoder_writef32(encoder, node->children);
+    pn_encoder_writef32(encoder, node->children);
+    return 0;
   default:
     return pn_error_format(data->error, PN_ERR, "unrecognized encoding: %u", code);
   }
@@ -356,16 +325,12 @@ static int pni_encoder_exit(void *ctx, pn_data_t *data, pni_node_t *node)
 {
   pn_encoder_t *encoder = (pn_encoder_t *) ctx;
   char *pos;
-  int err;
 
   switch (node->atom.type) {
   case PN_ARRAY:
-    if ((node->described && node->children == 1) ||
-        (!node->described && node->children == 0)) {
-      int err = pn_encoder_writef8(encoder, pn_type2code(encoder, node->type));
-      if (err) return err;
+    if ((node->described && node->children == 1) || (!node->described &&
node->children == 0)) {
+      pn_encoder_writef8(encoder, pn_type2code(encoder, node->type));
     }
-    // fallthrough
   case PN_LIST:
   case PN_MAP:
     pos = encoder->position;
@@ -373,14 +338,14 @@ static int pni_encoder_exit(void *ctx, pn_data_t *data, pni_node_t *node)
     if (node->small) {
       // backfill size
       size_t size = pos - node->start - 1;
-      err = pn_encoder_writef8(encoder, size);
+      pn_encoder_writef8(encoder, size);
     } else {
       // backfill size
       size_t size = pos - node->start - 4;
-      err = pn_encoder_writef32(encoder, size);
+      pn_encoder_writef32(encoder, size);
     }
     encoder->position = pos;
-    return err;
+    return 0;
   default:
     return 0;
   }
@@ -394,6 +359,17 @@ ssize_t pn_encoder_encode(pn_encoder_t *encoder, pn_data_t *src, char
*dst, size
 
   int err = pni_data_traverse(src, pni_encoder_enter, pni_encoder_exit, encoder);
   if (err) return err;
+  size_t encoded = encoder->position - encoder->output;
+  return (encoded > size) ? PN_OVERFLOW : (ssize_t)encoded;
+}
 
-  return size - pn_encoder_remaining(encoder);
+ssize_t pn_encoder_size(pn_encoder_t *encoder, pn_data_t *src)
+{
+  encoder->output = 0;
+  encoder->position = 0;
+  encoder->size = 0;
+
+  int err = pni_data_traverse(src, pni_encoder_enter, pni_encoder_exit, encoder);
+  if (err) return err;
+  return encoder->position - encoder->output;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-c/src/codec/encoder.h
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/encoder.h b/proton-c/src/codec/encoder.h
index 228e6d2..20876cb 100644
--- a/proton-c/src/codec/encoder.h
+++ b/proton-c/src/codec/encoder.h
@@ -26,5 +26,6 @@ typedef struct pn_encoder_t pn_encoder_t;
 
 pn_encoder_t *pn_encoder(void);
 ssize_t pn_encoder_encode(pn_encoder_t *encoder, pn_data_t *src, char *dst, size_t size);
+ssize_t pn_encoder_size(pn_encoder_t *encoder, pn_data_t *src);
 
 #endif /* encoder.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
index 4f42488..9d9fd94 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/Data.java
@@ -98,6 +98,7 @@ public interface Data
 //    int print();
 //    int format(ByteBuffer buf);
     Binary encode();
+    long encodedSize();
     long encode(ByteBuffer buf);
     long decode(ByteBuffer buf);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
index c6520ed..7193fa7 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/impl/DataImpl.java
@@ -133,7 +133,7 @@ public class DataImpl implements Data
     }
 
     @Override
-    public Binary encode()
+    public long encodedSize()
     {
         int size = 0;
         Element elt = _first;
@@ -142,7 +142,13 @@ public class DataImpl implements Data
             size += elt.size();
             elt = elt.next();
         }
-        byte[] data = new byte[size];
+        return size;
+    }
+
+    @Override
+    public Binary encode()
+    {
+        byte[] data = new byte[(int)encodedSize()];
         ByteBuffer buf = ByteBuffer.wrap(data);
         encode(buf);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/proton-j/src/main/resources/ccodec.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/ccodec.py b/proton-j/src/main/resources/ccodec.py
index 02cecc9..629fe0a 100644
--- a/proton-j/src/main/resources/ccodec.py
+++ b/proton-j/src/main/resources/ccodec.py
@@ -300,6 +300,9 @@ def pn_data_encode(data, size):
   else:
     return len(enc), enc
 
+def pn_data_encoded_size(data):
+  return data.encodedSize()
+
 def pn_data_decode(data, encoded):
   return data.decode(ByteBuffer.wrap(array(encoded, 'b')))
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fac7c86c/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index 0d78deb..baf998d 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -54,7 +54,13 @@ class InteropTest(common.Test):
             buffer = buffer[n:]
         self.data.rewind()
 
-    def decode_data_file(self, name): self.decode_data(self.get_data(name))
+    def decode_data_file(self, name):
+        encoded = self.get_data(name)
+        self.decode_data(encoded)
+        encoded_size = self.data.encoded_size()
+        # Re-encode and verify pre-computed and actual encoded size match.
+        reencoded = self.data.encode()
+        assert encoded_size == len(reencoded), "%d != %d" % (encoded_size, len(reencoded))
 
     def decode_message_file(self, name):
         self.message.decode(self.get_data(name))


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


Mime
View raw message