示例#1
0
 def _get_jms_message_header_kwargs(self):
     hdr_kwargs = {}
     hdr_annotations = {}
     for jms_header in list(self.test_headers_map.keys()):
         value_map = self.test_headers_map[jms_header]
         value_type = list(
             value_map.keys())[0]  # There is only ever one value in map
         value = value_map[value_type]
         if jms_header == 'JMS_TYPE_HEADER':
             if value_type == 'string':
                 hdr_kwargs['subject'] = value
             else:
                 raise InteropTestError(
                     'JmsSenderShim._get_jms_message_header_kwargs(): ' +
                     'JMS_TYPE_HEADER requires value type "string", type "%s" found'
                     % value_type)
         elif jms_header == 'JMS_CORRELATIONID_HEADER':
             if value_type == 'string':
                 hdr_kwargs['correlation_id'] = value
             elif value_type == 'bytes':
                 hdr_kwargs['correlation_id'] = base64.b64decode(value)
             else:
                 raise InteropTestError(
                     'JmsSenderShim._get_jms_message_header_kwargs(): ' +
                     'JMS_CORRELATIONID_HEADER requires value type "string" or "bytes", '
                     + 'type "%s" found' % value_type)
             hdr_annotations[proton.symbol(
                 u'x-opt-app-correlation-id')] = True
         elif jms_header == 'JMS_REPLYTO_HEADER':
             if value_type == 'queue':
                 hdr_kwargs['reply_to'] = value
                 hdr_annotations[proton.symbol(
                     u'x-opt-jms-reply-to')] = proton.byte(0)
             elif value_type == 'topic':
                 hdr_kwargs['reply_to'] = value
                 hdr_annotations[proton.symbol(
                     u'x-opt-jms-reply-to')] = proton.byte(1)
             elif value_type in ('temp_queue', 'temp_topic'):
                 raise InteropTestError(
                     'JmsSenderShim._get_jms_message_header_kwargs(): ' +
                     'JMS_REPLYTO_HEADER type "temp_queue" or "temp_topic" not handled'
                 )
             else:
                 raise InteropTestError(
                     'JmsSenderShim._get_jms_message_header_kwargs(): ' +
                     'JMS_REPLYTO_HEADER requires value type "queue" or "topic", '
                     + 'type "%s" found' % value_type)
         else:
             raise InteropTestError(
                 'JmsSenderShim._add_jms_message_headers(): Invalid JMS message header "%s"'
                 % jms_header)
     return (hdr_kwargs, hdr_annotations)
 def _receive_jms_streammessage(self, message):
     """Receives a JMS stream message"""
     assert self.jms_msg_type == 'JMS_STREAMMESSAGE_TYPE'
     assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(4)
     # Every message is a list with one item [value]
     assert len(message.body) == 1
     value = message.body[0]
     if self.current_subtype == 'boolean':
         return str(value)
     if self.current_subtype == 'byte':
         return hex(value)
     if self.current_subtype == 'bytes':
         return str(value)
     if self.current_subtype == 'char':
         return str(value)
     if self.current_subtype == 'double':
         return '0x%016x' % unpack('!Q', pack('!d', value))[0]
     if self.current_subtype == 'float':
         return '0x%08x' % unpack('!L', pack('!f', value))[0]
     if self.current_subtype == 'int':
         return hex(value)
     if self.current_subtype == 'long':
         return hex(int(value))
     if self.current_subtype == 'short':
         return hex(value)
     if self.current_subtype == 'string':
         return str(value)
     raise InteropTestError(
         'JmsRecieverShim._receive_jms_streammessage(): ' +
         'JMS message type %s: Unknown or unsupported subtype \'%s\'' %
         (self.jms_msg_type, self.current_subtype))
 def _add_jms_message_properties(self, message):
     """Adds message properties to the supplied message from self.test_properties_map"""
     for property_name in list(self.test_properties_map.keys()):
         value_map = self.test_properties_map[property_name]
         value_type = list(value_map.keys())[0] # There is only ever one value in map
         value = value_map[value_type]
         if message.properties is None:
             message.properties = {}
         if value_type == 'boolean':
             message.properties[property_name] = value == 'True'
         elif value_type == 'byte':
             message.properties[property_name] = proton.byte(int(value, 16))
         elif value_type == 'double':
             message.properties[property_name] = struct.unpack('!d', _compat.decode_hex(value[2:]))[0]
         elif value_type == 'float':
             message.properties[property_name] = proton.float32(struct.unpack('!f',
                                                                              _compat.decode_hex(value[2:]))[0])
         elif value_type == 'int':
             message.properties[property_name] = proton.int32(int(value, 16))
         elif value_type == 'long':
             message.properties[property_name] = _compat.str2long(value, 16)
         elif value_type == 'short':
             message.properties[property_name] = proton.short(int(value, 16))
         elif value_type == 'string':
             message.properties[property_name] = value
         else:
             raise InteropTestError('JmsSenderShim._add_jms_message_properties: ' +
                                    'Unknown or unhandled message property type ?%s"' % value_type)
 def _create_jms_streammessage(self, test_value_type, test_value, hdr_kwargs, hdr_annotations):
     """Create a JMS stream message"""
     if test_value_type == 'boolean':
         body_list = [test_value == 'True']
     elif test_value_type == 'byte':
         body_list = [proton.byte(int(test_value, 16))]
     elif test_value_type == 'bytes':
         body_list = [base64.b64decode(test_value)]
     elif test_value_type == 'char':
         body_list = [proton.char(base64.b64decode(test_value).decode('utf-8'))]
     elif test_value_type == 'double':
         body_list = [struct.unpack('!d', test_value[2:].decode('hex'))[0]]
     elif test_value_type == 'float':
         body_list = [proton.float32(struct.unpack('!f', test_value[2:].decode('hex'))[0])]
     elif test_value_type == 'int':
         body_list = [proton.int32(int(test_value, 16))]
     elif test_value_type == 'long':
         body_list = [_compat.str2long(test_value, 16)]
     elif test_value_type == 'short':
         body_list = [proton.short(int(test_value, 16))]
     elif test_value_type == 'string':
         body_list = [test_value]
     else:
         raise InteropTestError('JmsSenderShim._create_jms_streammessage: Unknown or unsupported subtype "%s"' %
                                test_value_type)
     return proton.Message(id=(self.sent+1),
                           body=body_list,
                           inferred=True,
                           annotations=JmsHdrsPropsTestSender.merge_dicts(create_annotation('JMS_STREAMMESSAGE_TYPE'),
                                                                          hdr_annotations),
                           **hdr_kwargs)
示例#5
0
 def _receive_jms_message(self, message):
     """"Receives a JMS message (without a body)"""
     assert self.jms_msg_type == 'JMS_MESSAGE_TYPE'
     assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == proton.byte(0)
     if message.body is not None:
         raise InteropTestError('_receive_jms_message: Invalid body for type JMS_MESSAGE_TYPE: %s' %
                                str(message.body))
示例#6
0
 def _create_jms_mapmessage(self, test_value_type, test_value, name):
     """Create a JMS map message"""
     if test_value_type == 'boolean':
         value = test_value == 'True'
     elif test_value_type == 'byte':
         value = proton.byte(int(test_value, 16))
     elif test_value_type == 'bytes':
         value = test_value.encode('utf-8')
     elif test_value_type == 'char':
         value = proton.char(test_value)
     elif test_value_type == 'double':
         value = struct.unpack('!d', _compat.decode_hex(test_value[2:]))[0]
     elif test_value_type == 'float':
         value = proton.float32(
             struct.unpack('!f', _compat.decode_hex(test_value[2:]))[0])
     elif test_value_type == 'int':
         value = proton.int32(int(test_value, 16))
     elif test_value_type == 'long':
         value = _compat.str2long(test_value, 16)
     elif test_value_type == 'short':
         value = proton.short(int(test_value, 16))
     elif test_value_type == 'string':
         value = test_value
     else:
         raise InteropTestError('JmsMessagesTestSender._create_jms_mapmessage: ' \
                                'Unknown or unsupported subtype "%s"' % test_value_type)
     return proton.Message(
         id=(self.sent + 1),
         body={name: value},
         inferred=False,
         annotations=create_annotation('JMS_MAPMESSAGE_TYPE'))
示例#7
0
 def _create_jms_mapmessage(self, test_value_type, test_value, name):
     """Create a JMS map message"""
     if test_value_type == 'boolean':
         value = test_value == 'True'
     elif test_value_type == 'byte':
         value = byte(int(test_value, 16))
     elif test_value_type == 'bytes':
         value = str(test_value)  # remove unicode
     elif test_value_type == 'char':
         value = char(test_value)
     elif test_value_type == 'double':
         value = unpack('!d', test_value[2:].decode('hex'))[0]
     elif test_value_type == 'float':
         value = float32(unpack('!f', test_value[2:].decode('hex'))[0])
     elif test_value_type == 'int':
         value = int32(int(test_value, 16))
     elif test_value_type == 'long':
         value = long(test_value, 16)
     elif test_value_type == 'short':
         value = short(int(test_value, 16))
     elif test_value_type == 'string':
         value = test_value
     else:
         raise InteropTestError(
             'JmsMessagesTestSender._create_jms_mapmessage: Unknown or unsupported subtype "%s"'
             % test_value_type)
     return Message(id=(self.sent + 1),
                    body={name: value},
                    inferred=False,
                    annotations=create_annotation('JMS_MAPMESSAGE_TYPE'))
示例#8
0
 def _create_jms_streammessage(self, test_value_type, test_value):
     """Create a JMS stream message"""
     if test_value_type == 'boolean':
         body_list = [test_value == 'True']
     elif test_value_type == 'byte':
         body_list = [byte(int(test_value, 16))]
     elif test_value_type == 'bytes':
         body_list = [str(test_value)]
     elif test_value_type == 'char':
         body_list = [char(test_value)]
     elif test_value_type == 'double':
         body_list = [unpack('!d', test_value[2:].decode('hex'))[0]]
     elif test_value_type == 'float':
         body_list = [
             float32(unpack('!f', test_value[2:].decode('hex'))[0])
         ]
     elif test_value_type == 'int':
         body_list = [int32(int(test_value, 16))]
     elif test_value_type == 'long':
         body_list = [long(test_value, 16)]
     elif test_value_type == 'short':
         body_list = [short(int(test_value, 16))]
     elif test_value_type == 'string':
         body_list = [test_value]
     else:
         raise InteropTestError(
             'JmsMessagesTestSender._create_jms_streammessage: Unknown or unsupported subtype "%s"'
             % test_value_type)
     return Message(id=(self.sent + 1),
                    body=body_list,
                    inferred=True,
                    annotations=create_annotation('JMS_STREAMMESSAGE_TYPE'))
 def _recieve_jms_mapmessage(self, message):
     """Receives a JMS map message"""
     assert self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE'
     assert message.annotations[
         QPID_JMS_TYPE_ANNOTATION_NAME] == proton.byte(2)
     key, value = list(message.body.items())[0]
     assert key[:-3] == self.current_subtype
     if self.current_subtype == 'boolean':
         return str(value)
     if self.current_subtype == 'byte':
         return hex(value)
     if self.current_subtype == 'bytes':
         return base64.b64encode(value).decode('utf-8')
     if self.current_subtype == 'char':
         if _compat.IS_PY3:
             return base64.b64encode(bytes(value, 'utf-8')).decode('utf-8')
         return base64.b64encode(bytes(value)).decode('utf-8')
     if self.current_subtype == 'double':
         return '0x%016x' % struct.unpack('!Q', struct.pack('!d', value))[0]
     if self.current_subtype == 'float':
         return '0x%08x' % struct.unpack('!L', struct.pack('!f', value))[0]
     if self.current_subtype == 'int':
         return hex(value)
     if self.current_subtype == 'long':
         return hex(int(value))
     if self.current_subtype == 'short':
         return hex(value)
     if self.current_subtype == 'string':
         return str(value)
     raise InteropTestError(
         'JMS message type %s: Unknown or unsupported subtype \'%s\'' %
         (self.jms_msg_type, self.current_subtype))
 def _recieve_jms_mapmessage(self, message):
     """"Receives a JMS map message"""
     assert self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE'
     assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(2)
     key, value = message.body.items()[0]
     assert key[:-3] == self.current_subtype
     if self.current_subtype == 'boolean':
         return str(value)
     if self.current_subtype == 'byte':
         return hex(value)
     if self.current_subtype == 'bytes':
         return str(value)
     if self.current_subtype == 'char':
         return str(value)
     if self.current_subtype == 'double':
         return '0x%016x' % unpack('!Q', pack('!d', value))[0]
     if self.current_subtype == 'float':
         return '0x%08x' % unpack('!L', pack('!f', value))[0]
     if self.current_subtype == 'int':
         return hex(value)
     if self.current_subtype == 'long':
         return hex(int(value))
     if self.current_subtype == 'short':
         return hex(value)
     if self.current_subtype == 'string':
         return str(value)
     raise InteropTestError(
         'JMS message type %s: Unknown or unsupported subtype \'%s\'' %
         (self.jms_msg_type, self.current_subtype))
示例#11
0
 def _create_jms_mapmessage(self, test_value_type, test_value, name,
                            hdr_kwargs, hdr_annotations):
     """Create a JMS map message"""
     if test_value_type == 'boolean':
         value = test_value == 'True'
     elif test_value_type == 'byte':
         value = proton.byte(int(test_value, 16))
     elif test_value_type == 'bytes':
         value = base64.b64decode(test_value)
     elif test_value_type == 'char':
         value = proton.char(base64.b64decode(test_value).decode('utf-8'))
     elif test_value_type == 'double':
         value = struct.unpack('!d', test_value[2:].decode('hex'))[0]
     elif test_value_type == 'float':
         value = proton.float32(
             struct.unpack('!f', test_value[2:].decode('hex'))[0])
     elif test_value_type == 'int':
         value = proton.int32(int(test_value, 16))
     elif test_value_type == 'long':
         value = int(test_value, 16)
     elif test_value_type == 'short':
         value = proton.short(int(test_value, 16))
     elif test_value_type == 'string':
         value = test_value
     else:
         raise InteropTestError(
             'JmsSenderShim._create_jms_mapmessage: Unknown or unsupported subtype "%s"'
             % test_value_type)
     return proton.Message(id=(self.sent + 1),
                           body={name: value},
                           inferred=False,
                           annotations=JmsHdrsPropsTestSender.merge_dicts(
                               create_annotation('JMS_MAPMESSAGE_TYPE'),
                               hdr_annotations),
                           **hdr_kwargs)
示例#12
0
 def encode_amqp_type(amqp_type, test_value):
     """Encode an AMQP type from a stringified test_value"""
     if amqp_type == 'null':
         return None
     if amqp_type == 'boolean':
         return True if test_value == 'True' else False
     if amqp_type == 'ubyte':
         return proton.ubyte(int(test_value, 16))
     if amqp_type == 'ushort':
         return proton.ushort(int(test_value, 16))
     if amqp_type == 'uint':
         return proton.uint(int(test_value, 16))
     if amqp_type == 'ulong':
         return proton.ulong(int(test_value, 16))
     if amqp_type == 'byte':
         return proton.byte(int(test_value, 16))
     if amqp_type == 'short':
         return proton.short(int(test_value, 16))
     if amqp_type == 'int':
         return proton.int32(int(test_value, 16))
     if amqp_type == 'long':
         return _compat.str2long(test_value, 16)
     if amqp_type == 'float':
         return proton.float32(struct.unpack('!f', _compat.decode_hex(test_value[2:]))[0])
     if amqp_type == 'double':
         return struct.unpack('!d', _compat.decode_hex(test_value[2:]))[0]
     if amqp_type == 'decimal32':
         return proton.decimal32(int(test_value[2:], 16))
     if amqp_type == 'decimal64':
         return proton.decimal64(_compat.str2long(test_value[2:], 16))
     if amqp_type == 'decimal128':
         return proton.decimal128(_compat.decode_hex(test_value[2:]))
     if amqp_type == 'char':
         if len(test_value) == 1: # Format 'a'
             return proton.char(test_value)
         return proton.char(_compat.unichr(int(test_value, 16)))
     if amqp_type == 'timestamp':
         return proton.timestamp(int(test_value, 16))
     if amqp_type == 'uuid':
         return uuid.UUID(test_value)
     if amqp_type == 'binary':
         return test_value.encode('utf-8')
     if amqp_type == 'string':
         return _compat.unicode(test_value)
     if amqp_type == 'symbol':
         return proton.symbol(test_value)
     if amqp_type == 'list':
         return AmqpTypesTestSender.encode_amqp_list(test_value)
     if amqp_type == 'map':
         return AmqpTypesTestSender.encode_amqp_map(test_value)
     if amqp_type == 'array':
         #return AmqpTypesTestSender.encode_amqp_array(test_value)
         print('send: Unsupported AMQP type "%s"' % amqp_type)
         return None
     print('send: Unknown AMQP type "%s"' % amqp_type)
     return None
 def _receive_jms_bytesmessage(self, message):
     """Receives a JMS bytes message"""
     assert self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE'
     assert message.annotations[
         QPID_JMS_TYPE_ANNOTATION_NAME] == proton.byte(3)
     if self.current_subtype == 'boolean':
         if message.body == b'\x00':
             return 'False'
         if message.body == b'\x01':
             return 'True'
         raise InteropTestError(
             '_receive_jms_bytesmessage: Invalid encoding for subtype boolean: %s'
             % str(message.body))
     if self.current_subtype == 'byte':
         return hex(struct.unpack('b', message.body)[0])
     if self.current_subtype == 'bytes':
         return base64.b64encode(message.body).decode('utf-8')
     if self.current_subtype == 'char':
         if len(message.body) == 2:  # format 'a' or '\xNN'
             if _compat.IS_PY3:
                 return base64.b64encode(bytes([message.body[1]])).decode(
                     'utf-8')  # strip leading '\x00' char
             return base64.b64encode(bytes(message.body[1])).decode(
                 'utf-8')  # strip leading '\x00' char
         raise InteropTestError(
             'Unexpected string length for type char: %d' %
             len(message.body))
     if self.current_subtype == 'double':
         return '0x%016x' % struct.unpack('!Q', message.body)[0]
     if self.current_subtype == 'float':
         return '0x%08x' % struct.unpack('!L', message.body)[0]
     if self.current_subtype == 'int':
         return hex(struct.unpack('!i', message.body)[0])
     if self.current_subtype == 'long':
         return hex(struct.unpack('!q', message.body)[0])
     if self.current_subtype == 'short':
         return hex(struct.unpack('!h', message.body)[0])
     if self.current_subtype == 'string':
         # NOTE: first 2 bytes are string length, must be present
         if len(message.body) >= 2:
             str_len = struct.unpack('!H', message.body[:2])[0]
             str_body = message.body[2:].decode('utf-8')
             if len(str_body) != str_len:
                 raise InteropTestError(
                     'String length mismatch: size=%d, but len(\'%s\')=%d' %
                     (str_len, str_body, len(str_body)))
             return str_body
         raise InteropTestError('Malformed string binary: len(\'%s\')=%d' %
                                (repr(message.body), len(message.body)))
     raise InteropTestError(
         'JMS message type %s: Unknown or unsupported subtype \'%s\'' %
         (self.jms_msg_type, self.current_subtype))
示例#14
0
 def _create_jms_streammessage(self, test_value_type, test_value):
     """Create a JMS stream message"""
     if test_value_type == 'boolean':
         body_list = [test_value == 'True']
     elif test_value_type == 'byte':
         body_list = [proton.byte(int(test_value, 16))]
     elif test_value_type == 'bytes':
         body_list = [test_value.encode('utf-8')]
     elif test_value_type == 'char':
         body_list = [proton.char(test_value)]
     elif test_value_type == 'double':
         body_list = [
             struct.unpack('!d', _compat.decode_hex(test_value[2:]))[0]
         ]
     elif test_value_type == 'float':
         body_list = [
             proton.float32(
                 struct.unpack('!f', _compat.decode_hex(test_value[2:]))[0])
         ]
     elif test_value_type == 'int':
         body_list = [proton.int32(int(test_value, 16))]
     elif test_value_type == 'long':
         body_list = [_compat.str2long(test_value, 16)]
     elif test_value_type == 'short':
         body_list = [proton.short(int(test_value, 16))]
     elif test_value_type == 'string':
         body_list = [test_value]
     else:
         raise InteropTestError('JmsMessagesTestSender._create_jms_streammessage: ' \
                                'Unknown or unsupported subtype "%s"' %
                                test_value_type)
     return proton.Message(
         id=(self.sent + 1),
         body=body_list,
         inferred=True,
         annotations=create_annotation('JMS_STREAMMESSAGE_TYPE'))
示例#15
0
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

from proton import byte, symbol

QPID_JMS_TYPE_ANNOTATION_NAME = symbol(u'x-opt-jms-msg-type')

QPID_JMS_TYPE_ANNOTATIONS = {
    'JMS_MESSAGE_TYPE': byte(0),
    'JMS_BYTESMESSAGE_TYPE': byte(3),
    'JMS_MAPMESSAGE_TYPE': byte(2),
    'JMS_OBJECTMESSAGE_TYPE': byte(1),
    'JMS_STREAMMESSAGE_TYPE': byte(4),
    'JMS_TEXTMESSAGE_TYPE': byte(5)
}


def create_annotation(jms_msg_type):
    """Function which creates a message annotation for JMS message type as used by the Qpid JMS client"""
    return {
        QPID_JMS_TYPE_ANNOTATION_NAME: QPID_JMS_TYPE_ANNOTATIONS[jms_msg_type]
    }
示例#16
0
 def create_message(self, test_value):
     """
     Creates a single message with the test value translated from its string representation to the appropriate
     AMQP value (set in self.amqp_type).
     """
     if self.amqp_type == 'null':
         return Message(id=(self.sent + 1), body=None)
     elif self.amqp_type == 'boolean':
         return Message(id=(self.sent + 1),
                        body=True if test_value == 'True' else False)
     elif self.amqp_type == 'ubyte':
         return Message(id=(self.sent + 1), body=ubyte(int(test_value, 16)))
     elif self.amqp_type == 'ushort':
         return Message(id=(self.sent + 1),
                        body=ushort(int(test_value, 16)))
     elif self.amqp_type == 'uint':
         return Message(id=(self.sent + 1), body=uint(int(test_value, 16)))
     elif self.amqp_type == 'ulong':
         return Message(id=(self.sent + 1), body=ulong(int(test_value, 16)))
     elif self.amqp_type == 'byte':
         return Message(id=(self.sent + 1), body=byte(int(test_value, 16)))
     elif self.amqp_type == 'short':
         return Message(id=(self.sent + 1), body=short(int(test_value, 16)))
     elif self.amqp_type == 'int':
         return Message(id=(self.sent + 1), body=int32(int(test_value, 16)))
     elif self.amqp_type == 'long':
         return Message(id=(self.sent + 1), body=long(int(test_value, 16)))
     elif self.amqp_type == 'float':
         return Message(id=(self.sent + 1),
                        body=float32(
                            unpack('!f', test_value[2:].decode('hex'))[0]))
     elif self.amqp_type == 'double':
         return Message(id=(self.sent + 1),
                        body=unpack('!d', test_value[2:].decode('hex'))[0])
     elif self.amqp_type == 'decimal32':
         return Message(id=(self.sent + 1),
                        body=decimal32(int(test_value[2:], 16)))
     elif self.amqp_type == 'decimal64':
         l64 = long(test_value[2:], 16)
         return Message(id=(self.sent + 1), body=decimal64(l64))
     elif self.amqp_type == 'decimal128':
         return Message(id=(self.sent + 1),
                        body=decimal128(test_value[2:].decode('hex')))
     elif self.amqp_type == 'char':
         if len(test_value) == 1:  # Format 'a'
             return Message(id=(self.sent + 1), body=char(test_value))
         else:
             val = int(test_value, 16)
             return Message(id=(self.sent + 1), body=char(unichr(val)))
     elif self.amqp_type == 'timestamp':
         return Message(id=(self.sent + 1),
                        body=timestamp(int(test_value, 16)))
     elif self.amqp_type == 'uuid':
         return Message(id=(self.sent + 1), body=UUID(test_value))
     elif self.amqp_type == 'binary':
         return Message(id=(self.sent + 1), body=bytes(test_value))
     elif self.amqp_type == 'string':
         return Message(id=(self.sent + 1), body=unicode(test_value))
     elif self.amqp_type == 'symbol':
         return Message(id=(self.sent + 1), body=symbol(test_value))
     elif self.amqp_type == 'list':
         return Message(id=(self.sent + 1), body=test_value)
     elif self.amqp_type == 'map':
         return Message(id=(self.sent + 1), body=test_value)
     else:
         print 'send: Unsupported AMQP type "%s"' % self.amqp_type
         return None
 def _receive_jms_textmessage(self, message):
     """"Receives a JMS text message"""
     assert self.jms_msg_type == 'JMS_TEXTMESSAGE_TYPE'
     assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(5)
     return message.body
 def _recieve_jms_objectmessage(self, message):
     """"Receives a JMS Object message"""
     assert self.jms_msg_type == 'JMS_OBJECTMESSAGE_TYPE'
     assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(1)
     return self._get_java_obj(message.body)