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 2016/05/04 19:35:17 UTC
[1/7] qpid-interop-test git commit: QPIDIT-32: Added Maven pom files,
removed jars directory containing copies of dependent jars. Also
updated to latest Proton C++ API
Repository: qpid-interop-test
Updated Branches:
refs/heads/master 87e8eae63 -> 36c7b3be8
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/types/simple_type_tests.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/types/simple_type_tests.py b/src/python/qpid-interop-test/types/simple_type_tests.py
new file mode 100755
index 0000000..78551eb
--- /dev/null
+++ b/src/python/qpid-interop-test/types/simple_type_tests.py
@@ -0,0 +1,478 @@
+#!/usr/bin/env python
+
+"""
+Module to test AMQP primitive types across different APIs
+"""
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.
+#
+
+import argparse
+import unittest
+
+from itertools import product
+from json import dumps, loads
+from os import getenv, path
+from subprocess import check_output, CalledProcessError
+from sys import exit
+from time import mktime, time
+from uuid import UUID, uuid4
+
+from proton import int32, symbol, timestamp, ulong
+from test_type_map import TestTypeMap
+import broker_properties
+
+
+# TODO - propose a sensible default when installation details are worked out
+QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME')
+
+
+class AmqpPrimitiveTypes(TestTypeMap):
+ """
+ Class which contains all the described AMQP primitive types and the test values to be used in testing.
+ """
+
+ TYPE_MAP = {
+ 'null': ['None'],
+ 'boolean': ['True',
+ 'False'],
+ 'ubyte': ['0x0',
+ '0x7f',
+ '0x80',
+ '0xff'],
+ 'ushort': ['0x0',
+ '0x7fff',
+ '0x8000',
+ '0xffff'],
+ 'uint': ['0x0',
+ '0x7fffffff',
+ '0x80000000',
+ '0xffffffff'],
+ 'ulong': ['0x0',
+ '0x1',
+ '0xff',
+ '0x100',
+ '0x7fffffffffffffff',
+ '0x8000000000000000',
+ '0xffffffffffffffff'],
+ 'byte': ['-0x80',
+ '-0x1',
+ '0x0',
+ '0x7f'],
+ 'short': ['-0x8000',
+ '-0x1',
+ '0x0',
+ '0x7fff'],
+ 'int': ['-0x80000000',
+ '-0x1',
+ '0x0',
+ '0x7fffffff'],
+ 'long': ['-0x8000000000000000',
+ '-0x81',
+ '-0x80',
+ '-0x1',
+ '0x0',
+ '0x7f',
+ '0x80',
+ '0x7fffffffffffffff'],
+ # float and double: Because of difficulty with rounding of floating point numbers, we use the binary
+ # representation instead which should be exact when comparing sent and received values.
+ 'float': ['0x00000000', # 0.0
+ '0x80000000', # -0.0
+ '0x40490fdb', # pi (3.14159265359) positive decimal
+ '0xc02df854', # -e (-2.71828182846) negative decimal
+ '0x00000001', # Smallest positive denormalized number
+ '0x80000001', # Smallest negative denormalized number
+ '0x007fffff', # Largest positive denormalized number
+ '0x807fffff', # Largest negative denormalized number
+ '0x00800000', # Smallest positive normalized number
+ '0x80800000', # Smallest negative normalized number
+ '0x7f7fffff', # Largest positive normalized number
+ '0xff7fffff', # Largest negative normalized number
+ #'0x7f800000', # +Infinity # PROTON-1149 - fails on RHEL7
+ #'0xff800000', # -Infinity # PROTON-1149 - fails on RHEL7
+ '0x7fc00000', # +NaN
+ '0xffc00000'], # -NaN
+ 'double': ['0x0000000000000000', # 0.0
+ '0x8000000000000000', # -0.0
+ '0x400921fb54442eea', # pi (3.14159265359) positive decimal
+ '0xc005bf0a8b145fcf', # -e (-2.71828182846) negative decimal
+ '0x0000000000000001', # Smallest positive denormalized number
+ '0x8000000000000001', # Smallest negative denormalized number
+ '0x000fffffffffffff', # Largest positive denormalized number
+ '0x800fffffffffffff', # Largest negative denormalized number
+ '0x0010000000000000', # Smallest positive normalized number
+ '0x8010000000000000', # Smallest negative normalized number
+ '0x7fefffffffffffff', # Largest positive normalized number
+ '0xffefffffffffffff', # Largest negative normalized number
+ '0x7ff0000000000000', # +Infinity
+ '0xfff0000000000000', # -Infinity
+ '0x7ff8000000000000', # +NaN
+ '0xfff8000000000000'], # -NaN
+ # decimal32, decimal64, decimal128:
+ # Until more formal support for decimal32, decimal64 and decimal128 are included in Python, we use
+ # a hex format for basic tests, and treat the data as a binary blob.
+ 'decimal32': ['0x00000000',
+ '0x40490fdb',
+ '0xc02df854',
+ '0xff7fffff'],
+ 'decimal64': ['0x0000000000000000',
+ '0x400921fb54442eea',
+ '0xc005bf0a8b145fcf',
+ '0xffefffffffffffff'],
+ 'decimal128': ['0x00000000000000000000000000000000',
+ '0xff0102030405060708090a0b0c0d0e0f'],
+ 'char': [u'a',
+ u'Z',
+ u'0x1',
+ u'0x7f',
+ u'0x16b5', # Rune 'G'
+ u'0x10ffff'],
+ # timestamp: Must be in milliseconds since the Unix epoch
+ 'timestamp': ['0x0',
+ '0x%x' % int(mktime((2000, 1, 1, 0, 0, 0, 5, 1, 0))*1000),
+ '0x%x' % int(time()*1000)
+ ],
+ 'uuid': [str(UUID(int=0x0)),
+ str(UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')),
+ str(uuid4())],
+ 'binary': [bytes(),
+ bytes(12345),
+ b'Hello, world!',
+ b'\\x01\\x02\\x03\\x04\\x05abcde\\x80\\x81\\xfe\\xff',
+ b'The quick brown fox jumped over the lazy dog 0123456789.' * 100
+ ],
+ # strings must be unicode to comply with AMQP spec
+ 'string': [u'',
+ u'Hello, world!',
+ u'"Hello, world!"',
+ u"Charlie's peach",
+ u'The quick brown fox jumped over the lazy dog 0123456789.' * 100
+ ],
+ 'symbol': ['',
+ 'myDomain.123',
+ 'domain.0123456789.' * 100],
+ 'list': [[],
+ ['ubyte:1', 'int:-2', 'float:3.14'],
+ ['string:a', 'string:b', 'string:c'],
+ ['ulong:12345', 'timestamp:%d' % (time()*1000), 'short:-2500', 'uuid:%s' % uuid4(), 'symbol:a.b.c', 'none:', 'decimal64:0x400921fb54442eea'],
+ [[], 'none', ['ubyte:1', 'ubyte:2', 'ubyte:3'], 'boolean:True', 'boolean:False', {'string:hello': 'long:1234', 'string:goodbye': 'boolean:True'}],
+ [[], [[], [[], [], []], []], []],
+ ['short:0', 'short:1', 'short:2', 'short:3', 'short:4', 'short:5', 'short:6', 'short:7', 'short:8', 'short:9'] * 100
+ ],
+ 'map': [{},
+ {'string:one': 'ubyte:1',
+ 'string:two': 'ushort:2'},
+ {'none:': 'string:None',
+ 'string:None': 'none:',
+ 'string:One': 'long:-1234567890',
+ 'short:2': 'int:2',
+ 'boolean:True': 'string:True',
+ 'string:False': 'boolean:False',
+ #['string:AAA', 'ushort:5951']: 'string:list value',
+ #{'byte:-55': 'ubyte:200',
+ # 'boolean:True': 'string:Hello, world!'}: 'symbol:map.value',
+ #'string:list': [],
+ 'string:map': {'char:A': 'int:1',
+ 'char:B': 'int:2'}},
+ ],
+ # TODO: Support all AMQP types in array (including keys)
+# 'array': [[],
+# [1, 2, 3],
+# ['Hello', 'world'],
+# [[1, 2, 3],
+# ['a', 'b', 'c'],
+# [2.3, 3.4, 4,5],
+# [True, False, True, True]]
+# ]
+ }
+
+ BROKER_SKIP = {'null': {'ActiveMQ': 'Null type not sent in Proton Python binding: PROTON-1091',
+ 'qpid-cpp': 'Null type not sent in Proton Python binding: PROTON-1091',},
+ 'decimal32': {'ActiveMQ': 'decimal32 and decimal64 are sent byte reversed: PROTON-1160',
+ 'qpid-cpp': 'decimal32 not supported on qpid-cpp broker: QPIDIT-5, QPID-6328',},
+ 'decimal64': {'ActiveMQ': 'decimal32 and decimal64 are sent byte reversed: PROTON-1160',
+ 'qpid-cpp': 'decimal64 not supported on qpid-cpp broker: QPIDIT-6, QPID-6328',},
+ 'decimal128': {'qpid-cpp': 'decimal128 not supported on qpid-cpp broker: QPIDIT-3, QPID-6328',},
+ 'char': {'qpid-cpp': 'char not supported on qpid-cpp broker: QPIDIT-4, QPID-6328',},
+ }
+# BROKER_SKIP = {}
+
+
+class AmqpTypeTestCase(unittest.TestCase):
+ """
+ Abstract base class for AMQP Type test cases
+ """
+
+ def run_test(self, broker_addr, amqp_type, test_value_list, send_shim, receive_shim):
+ """
+ Run this test by invoking the shim send method to send the test values, followed by the shim receive method
+ to receive the values. Finally, compare the sent values with the received values.
+ """
+ if len(test_value_list) > 0:
+ # TODO: When Artemis can support it (in the next release), revert the queue name back to 'qpid-interop...'
+ # Currently, Artemis only supports auto-create queues for JMS, and the queue name must be prefixed by 'jms.queue.'
+ #queue_name = 'qpid-interop.simple_type_tests.%s.%s.%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
+ queue_name = 'jms.queue.qpid-interop.simple_type_tests.%s.%s.%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
+ send_error_text = send_shim.send(broker_addr, queue_name, amqp_type, dumps(test_value_list))
+ if len(send_error_text) > 0:
+ self.fail('Send shim \'%s\':\n%s' % (send_shim.NAME, send_error_text))
+ receive_text = receive_shim.receive(broker_addr, queue_name, amqp_type, len(test_value_list))
+ if isinstance(receive_text, list):
+ self.assertEqual(receive_text, test_value_list, msg='\n sent:%s\nreceived:%s' % \
+ (test_value_list, receive_text))
+ else:
+ self.fail(receive_text)
+ else:
+ self.fail('Type %s has no test values' % amqp_type)
+
+
+def create_testcase_class(broker_name, types, broker_addr, amqp_type, shim_product):
+ """
+ Class factory function which creates new subclasses to AmqpTypeTestCase.
+ """
+
+ def __repr__(self):
+ """Print the class name"""
+ return self.__class__.__name__
+
+ def add_test_method(cls, send_shim, receive_shim):
+ """Function which creates a new test method in class cls"""
+
+ @unittest.skipIf(types.skip_test(amqp_type, broker_name),
+ types.skip_test_message(amqp_type, broker_name))
+ def inner_test_method(self):
+ self.run_test(self.broker_addr, self.amqp_type, self.test_value_list, send_shim, receive_shim)
+
+ inner_test_method.__name__ = 'test_%s_%s->%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
+ setattr(cls, inner_test_method.__name__, inner_test_method)
+
+ class_name = amqp_type.title() + 'TestCase'
+ class_dict = {'__name__': class_name,
+ '__repr__': __repr__,
+ '__doc__': 'Test case for AMQP 1.0 simple type \'%s\'' % amqp_type,
+ 'amqp_type': amqp_type,
+ 'broker_addr': broker_addr,
+ 'test_value_list': types.get_test_values(amqp_type)}
+ new_class = type(class_name, (AmqpTypeTestCase,), class_dict)
+ for send_shim, receive_shim in shim_product:
+ add_test_method(new_class, send_shim, receive_shim)
+ return new_class
+
+
+class Shim(object):
+ """
+ Abstract shim class, parent of all shims.
+ """
+ NAME = None
+ SEND = None
+ RECEIVE = None
+ USE_SHELL = False
+
+ def send(self, broker_addr, queue_name, amqp_type, json_test_values_str):
+ """
+ Send the values of type amqp_type in test_value_list to queue queue_name. Return output (if any) from stdout.
+ """
+ arg_list = []
+ arg_list.extend(self.SEND)
+ arg_list.extend([broker_addr, queue_name, amqp_type])
+ arg_list.append(json_test_values_str)
+
+ try:
+ #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
+ return check_output(arg_list, shell=self.USE_SHELL)
+ except CalledProcessError as exc:
+ return str(exc) + '\n\nOutput:\n' + exc.output
+ except Exception as exc:
+ return str(exc)
+
+
+ def receive(self, broker_addr, queue_name, amqp_type, num_test_values):
+ """
+ Receive num_test_values messages containing type amqp_type from queue queue_name. If the first line returned
+ from stdout is the AMQP type, then the rest is assumed to be the returned test value list. Otherwise error
+ output is assumed.
+ """
+ output = ''
+ try:
+ arg_list = []
+ arg_list.extend(self.RECEIVE)
+ arg_list.extend([broker_addr, queue_name, amqp_type, str(num_test_values)])
+ #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
+ output = check_output(arg_list)
+ #print '<<<', output # DEBUG - useful to see text received from shim
+ str_tvl = output.split('\n')[0:-1] # remove trailing \n
+ if len(str_tvl) == 1:
+ return output
+ if len(str_tvl) == 2:
+ return loads(str_tvl[1])
+ else:
+ return loads("".join(str_tvl[1:]))
+ except CalledProcessError as exc:
+ return str(exc) + '\n\n' + exc.output
+ except Exception as exc:
+ return str(exc)
+
+
+class ProtonPythonShim(Shim):
+ """
+ Shim for qpid-proton Python client
+ """
+ NAME = 'ProtonPython'
+ SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src')
+ SEND = [path.join(SHIM_LOC, 'TypesSenderShim.py')]
+ RECEIVE = [path.join(SHIM_LOC, 'TypesReceiverShim.py')]
+
+
+class ProtonCppShim(Shim):
+ """
+ Shim for qpid-proton C++ client
+ """
+ NAME = 'ProtonCpp'
+ SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'src')
+ SEND = [path.join(SHIM_LOC, 'AmqpSender')]
+ RECEIVE = [path.join(SHIM_LOC, 'AmqpReceiver')]
+
+
+class QpidJmsShim(Shim):
+ """
+ Shim for qpid-jms JMS client
+ """
+ NAME = 'QpidJms'
+
+ # Installed qpid versions
+ QPID_JMS_VER = '0.4.0-SNAPSHOT'
+ QPID_PROTON_J_VER = '0.10-SNAPSHOT'
+
+ # Classpath components
+ QPID_INTEROP_TEST_SHIM_JAR = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'target', 'qpid-jms-shim.jar')
+ MAVEN_REPO_PATH = path.join(getenv('HOME'), '.m2', 'repository')
+ JMS_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'geronimo', 'specs', 'geronimo-jms_1.1_spec', '1.1.1',
+ 'geronimo-jms_1.1_spec-1.1.1.jar')
+ JMS_IMPL_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'qpid-jms-client', QPID_JMS_VER,
+ 'qpid-jms-client-' + QPID_JMS_VER + '.jar')
+ LOGGER_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'slf4j', 'slf4j-api', '1.5.6', 'slf4j-api-1.5.6.jar')
+ LOGGER_IMPL_JAR = path.join(QPID_INTEROP_TEST_HOME, 'jars', 'slf4j-nop-1.5.6.jar')
+ PROTON_J_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'proton-j', QPID_PROTON_J_VER,
+ 'proton-j-' + QPID_PROTON_J_VER + '.jar')
+ NETTY_JAR = path.join(MAVEN_REPO_PATH, 'io', 'netty', 'netty-all', '4.0.17.Final', 'netty-all-4.0.17.Final.jar')
+
+ CLASSPATH = ':'.join([QPID_INTEROP_TEST_SHIM_JAR,
+ JMS_API_JAR,
+ JMS_IMPL_JAR,
+ LOGGER_API_JAR,
+ LOGGER_IMPL_JAR,
+ PROTON_J_JAR,
+ NETTY_JAR])
+ JAVA_HOME = getenv('JAVA_HOME', '/usr/bin') # Default only works in Linux
+ JAVA_EXEC = path.join(JAVA_HOME, 'java')
+ SEND = [JAVA_EXEC, '-cp', CLASSPATH, 'org.apache.qpid.interop_test.shim.AmqpSender']
+ RECEIVE = [JAVA_EXEC, '-cp', CLASSPATH, 'org.apache.qpid.interop_test.shim.AmqpReceiver']
+
+
+# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For
+# every shim in this list, a test is dynamically constructed which tests it against itself as well as every
+# other shim in the list.
+#
+# As new shims are added, add them into this map to have them included in the test cases.
+#SHIM_MAP = {ProtonPythonShim.NAME: ProtonPythonShim()}
+#SHIM_MAP = {ProtonPythonShim.NAME: ProtonCppShim()}
+SHIM_MAP = {ProtonCppShim.NAME: ProtonCppShim(),
+ ProtonPythonShim.NAME: ProtonPythonShim()
+ }
+
+
+class TestOptions(object):
+ """
+ Class controlling command-line arguments used to control the test.
+ """
+ def __init__(self):
+ parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite '
+ 'for AMQP simple types')
+ parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT',
+ help='Broker against which to run test suite.')
+# test_group = parser.add_mutually_exclusive_group()
+# test_group.add_argument('--include-test', action='append', metavar='TEST-NAME',
+# help='Name of test to include')
+# test_group.add_argument('--exclude-test', action='append', metavar='TEST-NAME',
+# help='Name of test to exclude')
+# type_group = test_group.add_mutually_exclusive_group()
+# type_group.add_argument('--include-type', action='append', metavar='AMQP-TYPE',
+# help='Name of AMQP type to include. Supported types:\n%s' %
+# sorted(AmqpPrimitiveTypes.TYPE_MAP.keys()))
+ parser.add_argument('--exclude-type', action='append', metavar='AMQP-TYPE',
+ help='Name of AMQP type to exclude. Supported types:\n%s' %
+ sorted(AmqpPrimitiveTypes.TYPE_MAP.keys()))
+# shim_group = test_group.add_mutually_exclusive_group()
+# shim_group.add_argument('--include-shim', action='append', metavar='SHIM-NAME',
+# help='Name of shim to include. Supported shims:\n%s' % SHIM_NAMES)
+ parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME',
+ help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys()))
+ self.args = parser.parse_args()
+
+
+#--- Main program start ---
+
+if __name__ == '__main__':
+
+ ARGS = TestOptions().args
+ #print 'ARGS:', ARGS # debug
+
+ # Connect to broker to find broker type
+ CONNECTION_PROPS = broker_properties.getBrokerProperties(ARGS.broker)
+ if CONNECTION_PROPS is None:
+ print 'WARNING: Unable to get connection properties - unknown broker'
+ BROKER = 'unknown'
+ else:
+ print 'Test Broker: %s v.%s on %s' % (CONNECTION_PROPS[symbol(u'product')],
+ CONNECTION_PROPS[symbol(u'version')],
+ CONNECTION_PROPS[symbol(u'platform')])
+ print
+ BROKER = CONNECTION_PROPS[symbol(u'product')]
+
+ TYPES = AmqpPrimitiveTypes()
+
+ # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed
+ # per AMQP type used as the key in map AmqpPrimitiveTypes.TYPE_MAP.
+ TEST_CASE_CLASSES = []
+
+ # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created
+ # type classes, each of which contains a test for the combinations of client shims
+ TEST_SUITE = unittest.TestSuite()
+
+ # Remove shims excluded from the command-line
+ if ARGS.exclude_shim is not None:
+ for shim in ARGS.exclude_shim:
+ SHIM_MAP.pop(shim)
+ # Create test classes dynamically
+ for at in sorted(TYPES.get_type_list()):
+ if ARGS.exclude_type is None or at not in ARGS.exclude_type:
+ test_case_class = create_testcase_class(BROKER,
+ TYPES,
+ ARGS.broker,
+ at,
+ product(SHIM_MAP.values(), repeat=2))
+ TEST_CASE_CLASSES.append(test_case_class)
+ TEST_SUITE.addTest(unittest.makeSuite(test_case_class))
+
+ # Finally, run all the dynamically created tests
+ res = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE)
+ if not res.wasSuccessful():
+ exit(1) # Errors or failures present
+
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/utils/.gitignore
----------------------------------------------------------------------
diff --git a/utils/.gitignore b/utils/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/utils/.gitignore
@@ -0,0 +1 @@
+/target/
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/utils/pom.xml
----------------------------------------------------------------------
diff --git a/utils/pom.xml b/utils/pom.xml
new file mode 100644
index 0000000..72ea9da
--- /dev/null
+++ b/utils/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <name>qpid-interop-test-utils</name>
+ <url>https://qpid.apache.org</url>
+
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-interop-test-utils</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-interop-test-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ <optimize>true</optimize>
+ <debug>true</debug>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
new file mode 100644
index 0000000..8c461ce
--- /dev/null
+++ b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.obj_util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+public class BytesToJavaObj {
+ String hexObjStr = null;
+ Serializable obj = null;
+
+ public BytesToJavaObj(String hexObjStr) {
+ this.hexObjStr = hexObjStr;
+ }
+
+ public String run() {
+ byte[] bytes = hexStrToByteArray(this.hexObjStr);
+ this.obj = byteArrayToObject(bytes);
+ if (this.obj != null) {
+ return this.obj.getClass().getName() + ":" + this.obj.toString();
+ }
+ return "<null>";
+ }
+
+ protected Serializable byteArrayToObject(byte[] bytes) {
+ ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
+ ObjectInput in = null;
+ try {
+ in = new ObjectInputStream(bis);
+ return (Serializable) in.readObject();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ } finally {
+ try {
+ bis.close();
+ } catch (IOException e) {} // ignore
+ try {
+ in.close();
+ } catch (IOException e) {} // ignore
+ }
+ return null;
+ }
+
+ protected byte[] hexStrToByteArray(String hexStr) {
+ int len = hexStr.length();
+ byte[] data = new byte[len / 2];
+ for(int i=0; i<len; i+=2) {
+ data[i/2] = (byte)((Character.digit(hexStr.charAt(i), 16) << 4) + Character.digit(hexStr.charAt(i+1), 16));
+ }
+ return data;
+ }
+
+ // ========= main ==========
+
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.out.println("BytesToJavaObj: Incorrect argument count");
+ System.out.println("BytesToJavaObj: Expected argument: \"<java_serialized_obj_str_hex>\"");
+ System.exit(1);
+ }
+ BytesToJavaObj btjo = new BytesToJavaObj(args[0]);
+ System.out.println(btjo.run());
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
new file mode 100644
index 0000000..2bfbde0
--- /dev/null
+++ b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.obj_util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+//import java.util.Arrays;
+
+public class JavaObjToBytes {
+ String javaClassName = null;
+ String ctorArgStr = null;
+ Serializable obj = null;
+
+ public JavaObjToBytes(String javaClassName, String ctorArgStr) {
+ this.javaClassName = javaClassName;
+ this.ctorArgStr = ctorArgStr;
+ }
+
+ public byte[] run() {
+ createJavaObject();
+ return serializeJavaOjbect();
+ }
+
+ protected void createJavaObject() {
+ try {
+ Class<?> c = Class.forName(this.javaClassName);
+ if (this.javaClassName.compareTo("java.lang.Character") == 0) {
+ Constructor ctor = c.getConstructor(char.class);
+ if (this.ctorArgStr.length() == 1) {
+ // Use first character of string
+ obj = (Serializable)ctor.newInstance(this.ctorArgStr.charAt(0));
+ } else if (this.ctorArgStr.length() == 4 || this.ctorArgStr.length() == 6) {
+ // Format '\xNN' or '\xNNNN'
+ obj = (Serializable)ctor.newInstance((char)Integer.parseInt(this.ctorArgStr.substring(2), 16));
+ } else {
+ throw new Exception("JavaObjToBytes.createJavaObject() Malformed char string: \"" + this.ctorArgStr + "\"");
+ }
+ } else {
+ // Use string constructor
+ Constructor ctor = c.getConstructor(String.class);
+ obj = (Serializable)ctor.newInstance(this.ctorArgStr);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (NoSuchMethodException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InstantiationException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalAccessException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InvocationTargetException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ protected byte[] serializeJavaOjbect() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(this.obj);
+ return bos.toByteArray();
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {} // ignore
+ try {
+ bos.close();
+ } catch (IOException e) {} // ignore
+ }
+ return null;
+ }
+
+ // ========= main ==========
+
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.out.println("JavaObjToBytes: Incorrect argument count");
+ System.out.println("JavaObjToBytes: Expected argument: \"<java_class_name>:<ctor_arg_str>\"");
+ System.exit(1);
+ }
+ int colonIndex = args[0].indexOf(":");
+ if (colonIndex < 0) {
+ System.out.println("Error: Incorect argument format: " + args[0]);
+ System.exit(-1);
+ }
+ String javaClassName = args[0].substring(0, colonIndex);
+ String ctorArgStr = args[0].substring(colonIndex+1);
+ JavaObjToBytes jotb = new JavaObjToBytes(javaClassName, ctorArgStr);
+ byte[] bytes = jotb.run();
+ System.out.println(args[0]);
+ for (byte b: bytes) {
+ System.out.print(String.format("%02x", b));
+ }
+ System.out.println();
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/7] qpid-interop-test git commit: QPIDIT-32: Added Maven pom files,
removed jars directory containing copies of dependent jars. Also
updated to latest Proton C++ API
Posted by kp...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
new file mode 100644
index 0000000..cf3ad81
--- /dev/null
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.shim;
+
+import java.math.BigDecimal;
+import java.util.UUID;
+import java.util.Vector;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import org.apache.qpid.jms.JmsConnectionFactory;
+
+public class AmqpReceiver {
+ private static final String USER = "guest";
+ private static final String PASSWORD = "guest";
+ private static final int TIMEOUT = 1000;
+ private static final String[] SUPPORTED_AMQP_TYPES = {"null",
+ "boolean",
+ "ubyte",
+ "ushort",
+ "uint",
+ "ulong",
+ "byte",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "decimal32",
+ "decimal64",
+ "decimal128",
+ "char",
+ "timestamp",
+ "uuid",
+ "binary",
+ "string",
+ "symbol",
+ "list",
+ "map",
+ "array"};
+
+ public static void main(String[] args) throws Exception {
+ if (args.length < 4) {
+ System.out.println("AmqpReceiver: Insufficient number of arguments");
+ System.out.println("AmqpReceiver: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String amqpType = args[2];
+ int numTestValues = Integer.parseInt(args[3]);
+ Connection connection = null;
+
+ try {
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+
+ connection = factory.createConnection(USER, PASSWORD);
+ connection.setExceptionListener(new MyExceptionListener());
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(queueName);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ Vector<String> outList = new Vector<String>();
+ outList.add(amqpType);
+ if (isSupportedAmqpType(amqpType)) {
+ int actualCount = 0;
+ Message message = null;
+ for (int i = 1; i <= numTestValues; i++, actualCount++) {
+ message = messageConsumer.receive(TIMEOUT);
+ if (message == null)
+ break;
+ switch (amqpType) {
+ case "null":
+ long bodyLength = ((BytesMessage)message).getBodyLength();
+ if (bodyLength == 0L) {
+ outList.add("None");
+ } else {
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Expected 0 bytes, read " + bodyLength);
+ }
+ break;
+ case "boolean":
+ String bs = String.valueOf(((BytesMessage)message).readBoolean());
+ outList.add(Character.toUpperCase(bs.charAt(0)) + bs.substring(1));
+ break;
+ case "ubyte":
+ byte byteValue = ((BytesMessage)message).readByte();
+ short ubyteValue = (short)(byteValue & 0xff);
+ outList.add(String.valueOf(ubyteValue));
+ break;
+ case "ushort":
+ {
+ byte[] byteArray = new byte[2];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 2) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 2 bytes, read " + numBytes);
+ }
+ int ushortValue = 0;
+ for (int j=0; j<byteArray.length; j++) {
+ ushortValue = (ushortValue << 8) + (byteArray[j] & 0xff);
+ }
+ outList.add(String.valueOf(ushortValue));
+ break;
+ }
+ case "uint":
+ {
+ byte[] byteArray = new byte[4];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 4) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 4 bytes, read " + numBytes);
+ }
+ long uintValue = 0;
+ for (int j=0; j<byteArray.length; j++) {
+ uintValue = (uintValue << 8) + (byteArray[j] & 0xff);
+ }
+ outList.add(String.valueOf(uintValue));
+ break;
+ }
+ case "ulong":
+ case "timestamp":
+ {
+ // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
+ byte[] byteArray = new byte[8];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 8) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 8 bytes, read " + numBytes);
+ }
+ // TODO: shortcut in use here - this byte array should go through a Java type that can represent this as a number - such as BigInteger.
+ outList.add(String.format("0x%02x%02x%02x%02x%02x%02x%02x%02x", byteArray[0], byteArray[1],
+ byteArray[2], byteArray[3], byteArray[4], byteArray[5], byteArray[6], byteArray[7]));
+ break;
+ }
+ case "byte":
+ outList.add(String.valueOf(((BytesMessage)message).readByte()));
+ break;
+ case "short":
+ outList.add(String.valueOf(((BytesMessage)message).readShort()));
+ break;
+ case "int":
+ outList.add(String.valueOf(((BytesMessage)message).readInt()));
+ break;
+ case "long":
+ outList.add(String.valueOf(((BytesMessage)message).readLong()));
+ break;
+ case "float":
+ float f = ((BytesMessage)message).readFloat();
+ int i0 = Float.floatToRawIntBits(f);
+ outList.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "double":
+ double d = ((BytesMessage)message).readDouble();
+ long l = Double.doubleToRawLongBits(d);
+ outList.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "decimal32":
+ BigDecimal bd32 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd32.toString());
+ break;
+ case "decimal64":
+ BigDecimal bd64 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd64.toString());
+ break;
+ case "decimal128":
+ BigDecimal bd128 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd128.toString());
+ break;
+ case "char":
+ outList.add(String.format("%c", ((BytesMessage)message).readChar()));
+ break;
+ case "uuid":
+ UUID uuid = (UUID)((ObjectMessage)message).getObject();
+ outList.add(uuid.toString());
+ break;
+ case "binary":
+ BytesMessage bm = (BytesMessage)message;
+ int msgLen = (int)bm.getBodyLength();
+ byte[] ba = new byte[msgLen];
+ if (bm.readBytes(ba) == msgLen) {
+ outList.add(new String(ba));
+ } else {
+ // TODO: Raise exception or error here: size mismatch
+ }
+ break;
+ case "string":
+ outList.add(((TextMessage)message).getText());
+ break;
+ case "symbol":
+ outList.add(((BytesMessage)message).readUTF());
+ break;
+ case "list":
+ break;
+ case "map":
+ break;
+ case "array":
+ break;
+ default:
+ // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
+ connection.close();
+ throw new Exception("AmqpReceiver: Internal error: unsupported AMQP type \"" + amqpType + "\"");
+ }
+ }
+ } else {
+ System.out.println("ERROR: AmqpReceiver: AMQP type \"" + amqpType + "\" is not supported");
+ connection.close();
+ System.exit(1);
+ }
+
+ connection.close();
+
+ // No exception, print results
+ for (int i=0; i<outList.size(); i++) {
+ System.out.println(outList.get(i));
+ }
+ } catch (Exception exp) {
+ if (connection != null)
+ connection.close();
+ System.out.println("Caught exception, exiting.");
+ exp.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+
+ protected static boolean isSupportedAmqpType(String amqpType) {
+ for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
+ if (amqpType.equals(supportedAmqpType))
+ return true;
+ }
+ return false;
+ }
+
+ private static class MyExceptionListener implements ExceptionListener {
+ @Override
+ public void onException(JMSException exception) {
+ System.out.println("Connection ExceptionListener fired, exiting.");
+ exception.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
new file mode 100644
index 0000000..3fc5a90
--- /dev/null
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
@@ -0,0 +1,260 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.shim;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.MathContext;
+import java.util.Arrays;
+import java.util.UUID;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import org.apache.qpid.jms.JmsConnectionFactory;
+
+public class AmqpSender {
+ private static final String USER = "guest";
+ private static final String PASSWORD = "guest";
+ private static final String[] SUPPORTED_AMQP_TYPES = {"null",
+ "boolean",
+ "ubyte",
+ "ushort",
+ "uint",
+ "ulong",
+ "byte",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "decimal32",
+ "decimal64",
+ "decimal128",
+ "char",
+ "timestamp",
+ "uuid",
+ "binary",
+ "string",
+ "symbol",
+ "list",
+ "map",
+ "array"};
+
+ public static void main(String[] args) throws Exception {
+ if (args.length < 4) {
+ System.out.println("AmqpSender: Insufficient number of arguments");
+ System.out.println("AmqpSender: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String amqpType = args[2];
+ String[] testValueList = Arrays.copyOfRange(args, 3, args.length); // Use remaining args as test values
+
+ try {
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+
+ Connection connection = factory.createConnection();
+ connection.setExceptionListener(new MyExceptionListener());
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(queueName);
+
+ MessageProducer messageProducer = session.createProducer(queue);
+
+ if (isSupportedAmqpType(amqpType)) {
+ Message message = null;
+ for (String testValueStr : testValueList) {
+ switch (amqpType) {
+ case "null":
+ message = session.createBytesMessage();
+ break;
+ case "boolean":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBoolean(Boolean.parseBoolean(testValueStr));
+ break;
+ case "ubyte":
+ {
+ byte testValue = (byte)Short.parseShort(testValueStr);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeByte(testValue);
+ break;
+ }
+ case "ushort":
+ {
+ int testValue = Integer.parseInt(testValueStr);
+ byte[] byteArray = new byte[2];
+ byteArray[0] = (byte)(testValue >> 8);
+ byteArray[1] = (byte)(testValue);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "uint":
+ {
+ long testValue = Long.parseLong(testValueStr);
+ byte[] byteArray = new byte[4];
+ byteArray[0] = (byte)(testValue >> 24);
+ byteArray[1] = (byte)(testValue >> 16);
+ byteArray[2] = (byte)(testValue >> 8);
+ byteArray[3] = (byte)(testValue);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "ulong":
+ {
+ // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
+ BigInteger testValue = new BigInteger(testValueStr);
+ byte[] bigIntArray = testValue.toByteArray(); // may be 1 to 9 bytes depending on number
+ byte[] byteArray = {0, 0, 0, 0, 0, 0, 0, 0};
+ int effectiveBigIntArrayLen = bigIntArray.length > 8 ? 8 : bigIntArray.length; // Cap length at 8
+ int bigIntArrayOffs = bigIntArray.length > 8 ? bigIntArray.length - 8 : 0; // Offset when length > 8
+ for (int i=0; i<bigIntArray.length && i < 8; i++)
+ byteArray[8 - effectiveBigIntArrayLen + i] = bigIntArray[bigIntArrayOffs + i];
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "byte":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeByte(Byte.parseByte(testValueStr));
+ break;
+ case "short":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeShort(Short.parseShort(testValueStr));
+ break;
+ case "int":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeInt(Integer.parseInt(testValueStr));
+ break;
+ case "long":
+ case "timestamp":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeLong(Long.parseLong(testValueStr));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValueStr.substring(2), 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValueStr.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValueStr.substring(3), 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "decimal32":
+ BigDecimal bd32 = new BigDecimal(testValueStr, MathContext.DECIMAL32);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd32);
+ break;
+ case "decimal64":
+ BigDecimal bd64 = new BigDecimal(testValueStr, MathContext.DECIMAL64);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd64);
+ break;
+ case "decimal128":
+ BigDecimal bd128 = new BigDecimal(testValueStr, MathContext.DECIMAL128);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd128);
+ break;
+ case "char":
+ char c = 0;
+ if (testValueStr.length() == 1) // Single char
+ c = testValueStr.charAt(0);
+ else if (testValueStr.length() == 6) // unicode format
+ c = (char)Integer.parseInt(testValueStr, 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeChar(c);
+ break;
+ case "uuid":
+ UUID uuid = UUID.fromString(testValueStr);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(uuid);
+ break;
+ case "binary":
+ message = session.createBytesMessage();
+ byte[] byteArray = testValueStr.getBytes();
+ ((BytesMessage)message).writeBytes(byteArray, 0, byteArray.length);
+ break;
+ case "string":
+ message = session.createTextMessage(testValueStr);
+ break;
+ case "symbol":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeUTF(testValueStr);
+ break;
+ case "list":
+ break;
+ case "map":
+ break;
+ case "array":
+ break;
+ default:
+ // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
+ connection.close();
+ throw new Exception("AmqpSender: Internal error: unsupported AMQP type \"" + amqpType + "\"");
+ }
+ messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ }
+ } else {
+ System.out.println("ERROR: AmqpSender: AMQP type \"" + amqpType + "\" is not supported");
+ connection.close();
+ System.exit(1);
+ }
+
+ connection.close();
+ } catch (Exception exp) {
+ System.out.println("Caught exception, exiting.");
+ exp.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+
+ protected static boolean isSupportedAmqpType(String amqpType) {
+ for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
+ if (amqpType.equals(supportedAmqpType))
+ return true;
+ }
+ return false;
+ }
+
+ private static class MyExceptionListener implements ExceptionListener {
+ @Override
+ public void onException(JMSException exception) {
+ System.out.println("Connection ExceptionListener fired, exiting.");
+ exception.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
new file mode 100644
index 0000000..f567638
--- /dev/null
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
@@ -0,0 +1,349 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.shim;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonReader;
+import javax.json.JsonWriter;
+import org.apache.qpid.jms.JmsConnectionFactory;
+
+public class JmsReceiverShim {
+ private static final String USER = "guest";
+ private static final String PASSWORD = "guest";
+ private static final int TIMEOUT = 1000;
+ private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
+ "JMS_MAPMESSAGE_TYPE",
+ "JMS_OBJECTMESSAGE_TYPE",
+ "JMS_STREAMMESSAGE_TYPE",
+ "JMS_TEXTMESSAGE_TYPE"};
+
+ // args[0]: Broker URL
+ // args[1]: Queue name
+ // args[2]: JMS message type
+ // args[3]: JSON Test number map
+ public static void main(String[] args) throws Exception {
+ if (args.length < 4) {
+ System.out.println("JmsReceiverShim: Insufficient number of arguments");
+ System.out.println("JmsReceiverShim: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String jmsMessageType = args[2];
+ if (!isSupportedJmsMessageType(jmsMessageType)) {
+ System.out.println("ERROR: JmsReceiverShim: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ System.exit(1);
+ }
+
+ JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
+ JsonObject numTestValuesMap = jsonReader.readObject();
+ jsonReader.close();
+
+ Connection connection = null;
+
+ try {
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+
+ connection = factory.createConnection(USER, PASSWORD);
+ connection.setExceptionListener(new MyExceptionListener());
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(queueName);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ List<String> keyList = new ArrayList<String>(numTestValuesMap.keySet());
+ Collections.sort(keyList);
+
+ Message message = null;
+ JsonObjectBuilder job = Json.createObjectBuilder();
+ for (String key: keyList) {
+ JsonArrayBuilder jab = Json.createArrayBuilder();
+ for (int i=0; i<numTestValuesMap.getJsonNumber(key).intValue(); ++i) {
+ message = messageConsumer.receive(TIMEOUT);
+ if (message == null) break;
+ switch (jmsMessageType) {
+ case "JMS_BYTESMESSAGE_TYPE":
+ switch (key) {
+ case "boolean":
+ jab.add(((BytesMessage)message).readBoolean()?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((BytesMessage)message).readByte()));
+ break;
+ case "bytes":
+ {
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
+ } else {
+ // NOTE: For this case, an empty byte array has nothing to return
+ jab.add(new String());
+ }
+ }
+ break;
+ case "char":
+ jab.add(formatChar(((BytesMessage)message).readChar()));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((BytesMessage)message).readDouble());
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((BytesMessage)message).readFloat());
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((BytesMessage)message).readInt()));
+ break;
+ case "long":
+ jab.add(formatLong(((BytesMessage)message).readLong()));
+ break;
+ case "object":
+ {
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(Arrays.copyOfRange(bytesBuff, 0, numBytesRead));
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ Object obj = ois.readObject();
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ } else {
+ jab.add("<object error>");
+ }
+ }
+ break;
+ case "short":
+ jab.add(formatShort(((BytesMessage)message).readShort()));
+ break;
+ case "string":
+ jab.add(((BytesMessage)message).readUTF());
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_STREAMMESSAGE_TYPE":
+ switch (key) {
+ case "boolean":
+ jab.add(((StreamMessage)message).readBoolean()?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((StreamMessage)message).readByte()));
+ break;
+ case "bytes":
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((StreamMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
+ } else {
+ System.out.println("StreamMessage.readBytes() returned " + numBytesRead);
+ jab.add("<bytes error>");
+ }
+ break;
+ case "char":
+ jab.add(formatChar(((StreamMessage)message).readChar()));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((StreamMessage)message).readDouble());
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((StreamMessage)message).readFloat());
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((StreamMessage)message).readInt()));
+ break;
+ case "long":
+ jab.add(formatLong(((StreamMessage)message).readLong()));
+ break;
+ case "object":
+ Object obj = ((StreamMessage)message).readObject();
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ break;
+ case "short":
+ jab.add(formatShort(((StreamMessage)message).readShort()));
+ break;
+ case "string":
+ jab.add(((StreamMessage)message).readString());
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_MAPMESSAGE_TYPE":
+ String name = String.format("%s%03d", key, i);
+ switch (key) {
+ case "boolean":
+ jab.add(((MapMessage)message).getBoolean(name)?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((MapMessage)message).getByte(name)));
+ break;
+ case "bytes":
+ jab.add(new String(((MapMessage)message).getBytes(name)));
+ break;
+ case "char":
+ jab.add(formatChar(((MapMessage)message).getChar(name)));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((MapMessage)message).getDouble(name));
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((MapMessage)message).getFloat(name));
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((MapMessage)message).getInt(name)));
+ break;
+ case "long":
+ jab.add(formatLong(((MapMessage)message).getLong(name)));
+ break;
+ case "object":
+ Object obj = ((MapMessage)message).getObject(name);
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ break;
+ case "short":
+ jab.add(formatShort(((MapMessage)message).getShort(name)));
+ break;
+ case "string":
+ jab.add(((MapMessage)message).getString(name));
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_OBJECTMESSAGE_TYPE":
+ jab.add(((ObjectMessage)message).getObject().toString());
+ break;
+ case "JMS_TEXTMESSAGE_TYPE":
+ jab.add(((TextMessage)message).getText());
+ break;
+ default:
+ connection.close();
+ throw new Exception("JmsReceiverShim: Internal error: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ }
+ }
+ job.add(key, jab);
+ }
+ connection.close();
+
+ System.out.println(jmsMessageType);
+ StringWriter out = new StringWriter();
+ JsonWriter jsonWriter = Json.createWriter(out);
+ jsonWriter.writeObject(job.build());
+ jsonWriter.close();
+ System.out.println(out.toString());
+ } catch (Exception exp) {
+ if (connection != null)
+ connection.close();
+ System.out.println("Caught exception, exiting.");
+ exp.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+
+ protected static String formatByte(byte b) {
+ boolean neg = false;
+ if (b < 0) {
+ neg = true;
+ b = (byte)-b;
+ }
+ return String.format("%s0x%x", neg?"-":"", b);
+ }
+
+ protected static String formatChar(char c) {
+ if (Character.isLetterOrDigit(c)) {
+ return String.format("%c", c);
+ }
+ char[] ca = {c};
+ return new String(ca);
+ }
+
+ protected static String formatInt(int i) {
+ boolean neg = false;
+ if (i < 0) {
+ neg = true;
+ i = -i;
+ }
+ return String.format("%s0x%x", neg?"-":"", i);
+ }
+
+ protected static String formatLong(long l) {
+ boolean neg = false;
+ if (l < 0) {
+ neg = true;
+ l = -l;
+ }
+ return String.format("%s0x%x", neg?"-":"", l);
+ }
+
+ protected static String formatShort(int s) {
+ boolean neg = false;
+ if (s < 0) {
+ neg = true;
+ s = -s;
+ }
+ return String.format("%s0x%x", neg?"-":"", s);
+ }
+
+ protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
+ for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
+ if (jmsMessageType.equals(supportedJmsMessageType))
+ return true;
+ }
+ return false;
+ }
+
+ private static class MyExceptionListener implements ExceptionListener {
+ @Override
+ public void onException(JMSException exception) {
+ System.out.println("Connection ExceptionListener fired, exiting.");
+ exception.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
new file mode 100644
index 0000000..e22be0a
--- /dev/null
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
@@ -0,0 +1,368 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+package org.apache.qpid.interop_test.shim;
+
+import java.io.Serializable;
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import org.apache.qpid.jms.JmsConnectionFactory;
+
+public class JmsSenderShim {
+ private static final String USER = "guest";
+ private static final String PASSWORD = "guest";
+ private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
+ "JMS_MAPMESSAGE_TYPE",
+ "JMS_OBJECTMESSAGE_TYPE",
+ "JMS_STREAMMESSAGE_TYPE",
+ "JMS_TEXTMESSAGE_TYPE"};
+
+ // args[0]: Broker URL
+ // args[1]: Queue name
+ // args[2]: JMS message type
+ // args[3]: JSON Test value map
+ public static void main(String[] args) throws Exception {
+ if (args.length < 4) {
+ System.out.println("JmsSenderShim: Insufficient number of arguments");
+ System.out.println("JmsSenderShim: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String jmsMessageType = args[2];
+ if (!isSupportedJmsMessageType(jmsMessageType)) {
+ System.out.println("ERROR: JmsReceiver: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ System.exit(1);
+ }
+
+ JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
+ JsonObject testValuesMap = jsonReader.readObject();
+ jsonReader.close();
+
+ try {
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+
+ Connection connection = factory.createConnection();
+ connection.setExceptionListener(new MyExceptionListener());
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(queueName);
+
+ MessageProducer messageProducer = session.createProducer(queue);
+
+ Message message = null;
+ List<String> keyList = new ArrayList<String>(testValuesMap.keySet());
+ Collections.sort(keyList);
+ for (String key: keyList) {
+ JsonArray testValues = testValuesMap.getJsonArray(key);
+ for (int i=0; i<testValues.size(); ++i) {
+ String testValue = testValues.getJsonString(i).getString();
+ switch (jmsMessageType) {
+ case "JMS_BYTESMESSAGE_TYPE":
+ message = createBytesMessage(session, key, testValue);
+ break;
+ case "JMS_MAPMESSAGE_TYPE":
+ message = createMapMessage(session, key, testValue, i);
+ break;
+ case "JMS_OBJECTMESSAGE_TYPE":
+ message = createObjectMessage(session, key, testValue);
+ break;
+ case "JMS_STREAMMESSAGE_TYPE":
+ message = createStreamMessage(session, key, testValue);
+ break;
+ case "JMS_TEXTMESSAGE_TYPE":
+ message = createTextMessage(session, testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message type \"" + jmsMessageType + "\"");
+ }
+ messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ }
+ }
+
+ connection.close();
+ } catch (Exception exp) {
+ System.out.println("Caught exception, exiting.");
+ exp.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+
+ protected static BytesMessage createBytesMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
+ BytesMessage message = session.createBytesMessage();
+ switch (testValueType) {
+ case "boolean":
+ message.writeBoolean(Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.writeByte(Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.writeBytes(testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X" or "\xNN"
+ message.writeChar(testValue.charAt(0));
+ } else {
+ throw new Exception("JmsSenderShim.createBytesMessage() Malformed char string: \"" + testValue + "\" of length " + testValue.length());
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.writeInt(Integer.decode(testValue));
+ break;
+ case "long":
+ message.writeLong(Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.writeObject(obj);
+ break;
+ case "short":
+ message.writeShort(Short.decode(testValue));
+ break;
+ case "string":
+ message.writeUTF(testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
+ }
+
+ protected static MapMessage createMapMessage(Session session, String testValueType, String testValue, int testValueNum) throws Exception, JMSException {
+ MapMessage message = session.createMapMessage();
+ String name = String.format("%s%03d", testValueType, testValueNum);
+ switch (testValueType) {
+ case "boolean":
+ message.setBoolean(name, Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.setByte(name, Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.setBytes(name, testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X"
+ message.setChar(name, testValue.charAt(0));
+ } else if (testValue.length() == 6) { // Char format: "\xNNNN"
+ message.setChar(name, (char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createMapMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.setDouble(name, Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.setFloat(name, Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.setInt(name, Integer.decode(testValue));
+ break;
+ case "long":
+ message.setLong(name, Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.setObject(name, obj);
+ break;
+ case "short":
+ message.setShort(name, Short.decode(testValue));
+ break;
+ case "string":
+ message.setString(name, testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
+ }
+
+ protected static ObjectMessage createObjectMessage(Session session, String className, String testValue) throws Exception, JMSException {
+ Serializable obj = createJavaObject(className, testValue);
+ if (obj == null) {
+ // TODO: Handle error here
+ System.out.println("createObjectMessage: obj == null");
+ return null;
+ }
+ ObjectMessage message = session.createObjectMessage();
+ message.setObject(obj);
+ return message;
+ }
+
+ protected static StreamMessage createStreamMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
+ StreamMessage message = session.createStreamMessage();
+ switch (testValueType) {
+ case "boolean":
+ message.writeBoolean(Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.writeByte(Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.writeBytes(testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X"
+ message.writeChar(testValue.charAt(0));
+ } else if (testValue.length() == 6) { // Char format: "\xNNNN"
+ message.writeChar((char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.writeInt(Integer.decode(testValue));
+ break;
+ case "long":
+ message.writeLong(Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.writeObject(obj);
+ break;
+ case "short":
+ message.writeShort(Short.decode(testValue));
+ break;
+ case "string":
+ message.writeString(testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
+ }
+
+ protected static Serializable createJavaObject(String className, String testValue) throws Exception {
+ Serializable obj = null;
+ try {
+ Class<?> c = Class.forName(className);
+ if (className.compareTo("java.lang.Character") == 0) {
+ Constructor ctor = c.getConstructor(char.class);
+ if (testValue.length() == 1) {
+ // Use first character of string
+ obj = (Serializable)ctor.newInstance(testValue.charAt(0));
+ } else if (testValue.length() == 4 || testValue.length() == 6) {
+ // Format '\xNN' or '\xNNNN'
+ obj = (Serializable)ctor.newInstance((char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ } else {
+ // Use string constructor
+ Constructor ctor = c.getConstructor(String.class);
+ obj = (Serializable)ctor.newInstance(testValue);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (NoSuchMethodException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InstantiationException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalAccessException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InvocationTargetException e) {
+ e.printStackTrace(System.out);
+ }
+ return obj;
+ }
+
+ // value has format "classname:ctorstrvalue"
+ protected static Serializable createObject(String value) throws Exception {
+ Serializable obj = null;
+ int colonIndex = value.indexOf(":");
+ if (colonIndex >= 0) {
+ String className = value.substring(0, colonIndex);
+ String testValue = value.substring(colonIndex+1);
+ obj = createJavaObject(className, testValue);
+ } else {
+ throw new Exception("createObject(): Malformed value string");
+ }
+ return obj;
+ }
+
+ protected static TextMessage createTextMessage(Session session, String valueStr) throws JMSException {
+ return session.createTextMessage(valueStr);
+ }
+
+ protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
+ for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
+ if (jmsMessageType.equals(supportedJmsMessageType))
+ return true;
+ }
+ return false;
+ }
+
+ private static class MyExceptionListener implements ExceptionListener {
+ @Override
+ public void onException(JMSException exception) {
+ System.out.println("Connection ExceptionListener fired, exiting.");
+ exception.printStackTrace(System.out);
+ System.exit(1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/.gitignore
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/.gitignore b/shims/qpid-proton-cpp/.gitignore
new file mode 100644
index 0000000..84c048a
--- /dev/null
+++ b/shims/qpid-proton-cpp/.gitignore
@@ -0,0 +1 @@
+/build/
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.cpp b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.cpp
index 0965092..fb76f0e 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.cpp
@@ -25,7 +25,8 @@
#include <json/json.h>
#include "proton/connection.hpp"
#include "proton/container.hpp"
-#include <proton/types.hpp>
+#include "proton/delivery.hpp"
+#include "proton/receiver.hpp"
#include "qpidit/QpidItErrors.hpp"
namespace qpidit
@@ -50,7 +51,7 @@ namespace qpidit
}
void AmqpReceiver::on_container_start(proton::container &c) {
- _receiver = c.open_receiver(_brokerUrl);
+ /*_receiver = */c.open_receiver(_brokerUrl);
}
void AmqpReceiver::on_message(proton::delivery &d, proton::message &m) {
@@ -148,7 +149,7 @@ namespace qpidit
}
_received++;
if (_received >= _expected) {
- d.link().close();
+ d.receiver().close();
d.connection().close();
}
}
@@ -165,8 +166,8 @@ namespace qpidit
std::cerr << "AmqpReceiver:on_transport_error()" << std::endl;
}
- void AmqpReceiver::on_unhandled_error(const proton::condition &c) {
- std::cerr << "AmqpReceiver:on_unhandled_error() condition=" << c.name() << std::endl;
+ void AmqpReceiver::on_unhandled_error(const proton::error_condition &c) {
+ std::cerr << "AmqpReceiver:on_unhandled_error() name=" << c.name() << " description=" << c.description() << std::endl;
}
// protected
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.hpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.hpp b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.hpp
index 812043f..c11fbaf 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpReceiver.hpp
@@ -25,7 +25,7 @@
#include <iomanip>
#include <json/value.h>
#include "proton/handler.hpp"
-#include "proton/receiver.hpp"
+#include "proton/types.hpp"
#include <sstream>
namespace qpidit
@@ -38,7 +38,6 @@ namespace qpidit
protected:
const std::string _brokerUrl;
const std::string _amqpType;
- proton::receiver _receiver;
uint32_t _expected;
uint32_t _received;
Json::Value _receivedValueList;
@@ -52,7 +51,7 @@ namespace qpidit
void on_connection_error(proton::connection &c);
void on_sender_error(proton::sender& l);
void on_transport_error(proton::transport &t);
- void on_unhandled_error(const proton::condition &c);
+ void on_unhandled_error(const proton::error_condition &c);
protected:
static void checkMessageType(const proton::message& msg, proton::type_id msgType);
static Json::Value& getMap(Json::Value& jsonMap, const proton::value& val);
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.cpp b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.cpp
index a4015eb..960308e 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.cpp
@@ -25,7 +25,8 @@
#include <json/json.h>
#include "proton/connection.hpp"
#include "proton/container.hpp"
-#include "proton/decimal.hpp"
+#include "proton/sender.hpp"
+#include "proton/tracker.hpp"
namespace qpidit
{
@@ -65,10 +66,10 @@ namespace qpidit
}
}
- void AmqpSender::on_delivery_accept(proton::delivery &d) {
+ void AmqpSender::on_tracker_accept(proton::tracker &t) {
_msgsConfirmed++;
if (_msgsConfirmed == _totalMsgs) {
- d.connection().close();
+ t.connection().close();
}
}
@@ -88,8 +89,8 @@ namespace qpidit
std::cerr << "AmqpSender:on_transport_error()" << std::endl;
}
- void AmqpSender::on_unhandled_error(const proton::condition &c) {
- std::cerr << "AmqpSender:on_unhandled_error()" << " condition=" << c.name() << std::endl;
+ void AmqpSender::on_unhandled_error(const proton::error_condition &c) {
+ std::cerr << "AmqpSender:on_unhandled_error()" << " name=" << c.name() << " description=" << c.description() << std::endl;
}
// protected
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.hpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.hpp b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.hpp
index 90ec217..f27c371 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/AmqpSender.hpp
@@ -47,13 +47,13 @@ namespace qpidit
virtual ~AmqpSender();
void on_container_start(proton::container &c);
void on_sendable(proton::sender &s);
- void on_delivery_accept(proton::delivery &d);
+ void on_tracker_accept(proton::tracker &t);
void on_transport_close(proton::transport &t);
void on_connection_error(proton::connection &c);
- void on_sender_error(proton::sender& l);
+ void on_sender_error(proton::sender& s);
void on_transport_error(proton::transport &t);
- void on_unhandled_error(const proton::condition &c);
+ void on_unhandled_error(const proton::error_condition &c);
protected:
proton::message& setMessage(proton::message& msg, const Json::Value& testValue);
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp b/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
index 0fc700d..f062577 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
@@ -23,9 +23,9 @@
#include <iostream>
#include <json/json.h>
-#include <map>
#include "proton/connection.hpp"
#include "proton/container.hpp"
+#include "proton/delivery.hpp"
#include "qpidit/QpidItErrors.hpp"
namespace qpidit
@@ -44,7 +44,6 @@ namespace qpidit
_brokerUrl(brokerUrl),
_jmsMessageType(jmsMessageType),
_testNumberMap(testNumberMap),
- _receiver(),
_subTypeList(testNumberMap.getMemberNames()),
_subTypeIndex(0),
_expected(getTotalNumExpectedMsgs(testNumberMap)),
@@ -60,7 +59,7 @@ namespace qpidit
}
void JmsReceiver::on_container_start(proton::container &c) {
- _receiver = c.open_receiver(_brokerUrl);
+ c.open_receiver(_brokerUrl);
}
void JmsReceiver::on_message(proton::delivery &d, proton::message &m) {
@@ -97,8 +96,7 @@ namespace qpidit
}
_received++;
if (_received >= _expected) {
- _receiver.close();
- d.link().close();
+ d.receiver().close();
d.connection().close();
}
}
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.hpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.hpp b/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.hpp
index ffaf1ff..198a957 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.hpp
@@ -25,7 +25,6 @@
#include <iomanip>
#include <json/value.h>
#include "proton/handler.hpp"
-#include "proton/receiver.hpp"
#include "proton/types.hpp"
#include <sstream>
@@ -43,7 +42,6 @@ namespace qpidit
const std::string _brokerUrl;
const std::string _jmsMessageType;
const Json::Value _testNumberMap;
- proton::receiver _receiver;
Json::Value::Members _subTypeList;
int _subTypeIndex;
uint32_t _expected;
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
index 3b03ef5..102fc1d 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
@@ -22,12 +22,12 @@
#include "qpidit/shim/JmsSender.hpp"
#include <cerrno>
-#include <iostream>
#include <iomanip>
+#include <iostream>
#include <json/json.h>
#include "proton/connection.hpp"
#include "proton/container.hpp"
-#include "qpidit/QpidItErrors.hpp"
+#include "proton/tracker.hpp"
#include <stdio.h>
namespace qpidit
@@ -72,11 +72,10 @@ namespace qpidit
}
}
- void JmsSender::on_delivery_accept(proton::delivery &d) {
+ void JmsSender::on_tracker_accept(proton::tracker &t) {
_msgsConfirmed++;
if (_msgsConfirmed == _totalMsgs) {
- d.link().close();
- d.connection().close();
+ t.connection().close();
}
}
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
index 962f012..f953b43 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
@@ -53,7 +53,7 @@ namespace qpidit
virtual ~JmsSender();
void on_container_start(proton::container &c);
void on_sendable(proton::sender &s);
- void on_delivery_accept(proton::delivery &d);
+ void on_tracker_accept(proton::tracker &t);
void on_transport_close(proton::transport &t);
protected:
void sendMessages(proton::sender &s, const std::string& subType, const Json::Value& testValueMap);
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java b/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java
deleted file mode 100644
index 8c461ce..0000000
--- a/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.obj_util;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-
-public class BytesToJavaObj {
- String hexObjStr = null;
- Serializable obj = null;
-
- public BytesToJavaObj(String hexObjStr) {
- this.hexObjStr = hexObjStr;
- }
-
- public String run() {
- byte[] bytes = hexStrToByteArray(this.hexObjStr);
- this.obj = byteArrayToObject(bytes);
- if (this.obj != null) {
- return this.obj.getClass().getName() + ":" + this.obj.toString();
- }
- return "<null>";
- }
-
- protected Serializable byteArrayToObject(byte[] bytes) {
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInput in = null;
- try {
- in = new ObjectInputStream(bis);
- return (Serializable) in.readObject();
- } catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- } catch (IOException e) {
- e.printStackTrace(System.out);
- } finally {
- try {
- bis.close();
- } catch (IOException e) {} // ignore
- try {
- in.close();
- } catch (IOException e) {} // ignore
- }
- return null;
- }
-
- protected byte[] hexStrToByteArray(String hexStr) {
- int len = hexStr.length();
- byte[] data = new byte[len / 2];
- for(int i=0; i<len; i+=2) {
- data[i/2] = (byte)((Character.digit(hexStr.charAt(i), 16) << 4) + Character.digit(hexStr.charAt(i+1), 16));
- }
- return data;
- }
-
- // ========= main ==========
-
- public static void main(String[] args) {
- if (args.length != 1) {
- System.out.println("BytesToJavaObj: Incorrect argument count");
- System.out.println("BytesToJavaObj: Expected argument: \"<java_serialized_obj_str_hex>\"");
- System.exit(1);
- }
- BytesToJavaObj btjo = new BytesToJavaObj(args[0]);
- System.out.println(btjo.run());
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java b/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java
deleted file mode 100644
index 2bfbde0..0000000
--- a/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.obj_util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-//import java.util.Arrays;
-
-public class JavaObjToBytes {
- String javaClassName = null;
- String ctorArgStr = null;
- Serializable obj = null;
-
- public JavaObjToBytes(String javaClassName, String ctorArgStr) {
- this.javaClassName = javaClassName;
- this.ctorArgStr = ctorArgStr;
- }
-
- public byte[] run() {
- createJavaObject();
- return serializeJavaOjbect();
- }
-
- protected void createJavaObject() {
- try {
- Class<?> c = Class.forName(this.javaClassName);
- if (this.javaClassName.compareTo("java.lang.Character") == 0) {
- Constructor ctor = c.getConstructor(char.class);
- if (this.ctorArgStr.length() == 1) {
- // Use first character of string
- obj = (Serializable)ctor.newInstance(this.ctorArgStr.charAt(0));
- } else if (this.ctorArgStr.length() == 4 || this.ctorArgStr.length() == 6) {
- // Format '\xNN' or '\xNNNN'
- obj = (Serializable)ctor.newInstance((char)Integer.parseInt(this.ctorArgStr.substring(2), 16));
- } else {
- throw new Exception("JavaObjToBytes.createJavaObject() Malformed char string: \"" + this.ctorArgStr + "\"");
- }
- } else {
- // Use string constructor
- Constructor ctor = c.getConstructor(String.class);
- obj = (Serializable)ctor.newInstance(this.ctorArgStr);
- }
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- }
- catch (NoSuchMethodException e) {
- e.printStackTrace(System.out);
- }
- catch (InstantiationException e) {
- e.printStackTrace(System.out);
- }
- catch (IllegalAccessException e) {
- e.printStackTrace(System.out);
- }
- catch (InvocationTargetException e) {
- e.printStackTrace(System.out);
- }
- catch (Exception e) {
- e.printStackTrace(System.out);
- }
- }
-
- protected byte[] serializeJavaOjbect() {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(this.obj);
- return bos.toByteArray();
- } catch (IOException e) {
- e.printStackTrace(System.out);
- } finally {
- try {
- if (out != null) {
- out.close();
- }
- } catch (IOException e) {} // ignore
- try {
- bos.close();
- } catch (IOException e) {} // ignore
- }
- return null;
- }
-
- // ========= main ==========
-
- public static void main(String[] args) {
- if (args.length != 1) {
- System.out.println("JavaObjToBytes: Incorrect argument count");
- System.out.println("JavaObjToBytes: Expected argument: \"<java_class_name>:<ctor_arg_str>\"");
- System.exit(1);
- }
- int colonIndex = args[0].indexOf(":");
- if (colonIndex < 0) {
- System.out.println("Error: Incorect argument format: " + args[0]);
- System.exit(-1);
- }
- String javaClassName = args[0].substring(0, colonIndex);
- String ctorArgStr = args[0].substring(colonIndex+1);
- JavaObjToBytes jotb = new JavaObjToBytes(javaClassName, ctorArgStr);
- byte[] bytes = jotb.run();
- System.out.println(args[0]);
- for (byte b: bytes) {
- System.out.print(String.format("%02x", b));
- }
- System.out.println();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/.gitignore
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/.gitignore b/src/py/qpid-interop-test/.gitignore
deleted file mode 100644
index b3f6765..0000000
--- a/src/py/qpid-interop-test/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/interop_test_errors.pyc
-/shim_utils.pyc
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/__init__.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/__init__.py b/src/py/qpid-interop-test/__init__.py
deleted file mode 100644
index 7b8aee3..0000000
--- a/src/py/qpid-interop-test/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-#
-
-import broker_properties
-import interop_test_errors
-import test_type_map
-import types
-import jms
-
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/broker_properties.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/broker_properties.py b/src/py/qpid-interop-test/broker_properties.py
deleted file mode 100644
index 08cc9cc..0000000
--- a/src/py/qpid-interop-test/broker_properties.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""
-Module containing a small client which connects to the broker and
-gets the broker connection properties so as to identify the broker.
-"""
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.handlers import MessagingHandler
-from proton.reactor import Container
-
-class Client(MessagingHandler):
- """
- Client to connect to broker and collect connection properties, used to identify the test broker
- """
- def __init__(self, url):
- super(Client, self).__init__()
- self.url = url
- self.remote_properties = None
-
- def on_connection_remote_open(self, event):
- self.remote_properties = event.connection.remote_properties
- event.connection.close()
-
- def on_start(self, event):
- """Event loop start"""
- event.container.connect(url=self.url)
-
- def get_connection_properties(self):
- """Return the connection properties"""
- return self.remote_properties
-
-
-def getBrokerProperties(broker_url):
- """Start client, then return its connection properties"""
- MSG_HANDLER = Client(broker_url)
- Container(MSG_HANDLER).run()
- return MSG_HANDLER.get_connection_properties()
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/interop_test_errors.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/interop_test_errors.py b/src/py/qpid-interop-test/interop_test_errors.py
deleted file mode 100644
index 6be8959..0000000
--- a/src/py/qpid-interop-test/interop_test_errors.py
+++ /dev/null
@@ -1,29 +0,0 @@
-"""
-Module containing Error classes for interop testing
-"""
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-#
-
-class InteropTestError(StandardError):
- """
- Generic simple error class for use in interop tests
- """
- def __init__(self, error_message):
- super(InteropTestError, self).__init__(error_message)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/7] qpid-interop-test git commit: NO_JIRA: Fixed whitespace issues
in code: removed tabs, fixed indentation, removed trailing whitespace
Posted by kp...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4e6f4f29/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
index e22be0a..b68583c 100644
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsSenderShim.java
@@ -47,76 +47,75 @@ public class JmsSenderShim {
private static final String USER = "guest";
private static final String PASSWORD = "guest";
private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
- "JMS_MAPMESSAGE_TYPE",
- "JMS_OBJECTMESSAGE_TYPE",
- "JMS_STREAMMESSAGE_TYPE",
- "JMS_TEXTMESSAGE_TYPE"};
+ "JMS_MAPMESSAGE_TYPE",
+ "JMS_OBJECTMESSAGE_TYPE",
+ "JMS_STREAMMESSAGE_TYPE",
+ "JMS_TEXTMESSAGE_TYPE"};
// args[0]: Broker URL
// args[1]: Queue name
// args[2]: JMS message type
// args[3]: JSON Test value map
public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("JmsSenderShim: Insufficient number of arguments");
- System.out.println("JmsSenderShim: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String jmsMessageType = args[2];
- if (!isSupportedJmsMessageType(jmsMessageType)) {
- System.out.println("ERROR: JmsReceiver: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- System.exit(1);
- }
-
- JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
- JsonObject testValuesMap = jsonReader.readObject();
- jsonReader.close();
-
+ if (args.length < 4) {
+ System.out.println("JmsSenderShim: Insufficient number of arguments");
+ System.out.println("JmsSenderShim: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String jmsMessageType = args[2];
+ if (!isSupportedJmsMessageType(jmsMessageType)) {
+ System.out.println("ERROR: JmsReceiver: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ System.exit(1);
+ }
+
+ JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
+ JsonObject testValuesMap = jsonReader.readObject();
+ jsonReader.close();
+
try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
Connection connection = factory.createConnection();
connection.setExceptionListener(new MyExceptionListener());
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
Queue queue = session.createQueue(queueName);
MessageProducer messageProducer = session.createProducer(queue);
- Message message = null;
- List<String> keyList = new ArrayList<String>(testValuesMap.keySet());
- Collections.sort(keyList);
- for (String key: keyList) {
- JsonArray testValues = testValuesMap.getJsonArray(key);
- for (int i=0; i<testValues.size(); ++i) {
- String testValue = testValues.getJsonString(i).getString();
- switch (jmsMessageType) {
- case "JMS_BYTESMESSAGE_TYPE":
- message = createBytesMessage(session, key, testValue);
- break;
- case "JMS_MAPMESSAGE_TYPE":
- message = createMapMessage(session, key, testValue, i);
- break;
- case "JMS_OBJECTMESSAGE_TYPE":
- message = createObjectMessage(session, key, testValue);
- break;
- case "JMS_STREAMMESSAGE_TYPE":
- message = createStreamMessage(session, key, testValue);
- break;
- case "JMS_TEXTMESSAGE_TYPE":
- message = createTextMessage(session, testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message type \"" + jmsMessageType + "\"");
- }
- messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
- }
- }
-
+ Message message = null;
+ List<String> keyList = new ArrayList<String>(testValuesMap.keySet());
+ Collections.sort(keyList);
+ for (String key: keyList) {
+ JsonArray testValues = testValuesMap.getJsonArray(key);
+ for (int i=0; i<testValues.size(); ++i) {
+ String testValue = testValues.getJsonString(i).getString();
+ switch (jmsMessageType) {
+ case "JMS_BYTESMESSAGE_TYPE":
+ message = createBytesMessage(session, key, testValue);
+ break;
+ case "JMS_MAPMESSAGE_TYPE":
+ message = createMapMessage(session, key, testValue, i);
+ break;
+ case "JMS_OBJECTMESSAGE_TYPE":
+ message = createObjectMessage(session, key, testValue);
+ break;
+ case "JMS_STREAMMESSAGE_TYPE":
+ message = createStreamMessage(session, key, testValue);
+ break;
+ case "JMS_TEXTMESSAGE_TYPE":
+ message = createTextMessage(session, testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message type \"" + jmsMessageType + "\"");
+ }
+ messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ }
+ }
connection.close();
} catch (Exception exp) {
System.out.println("Caught exception, exiting.");
@@ -126,235 +125,235 @@ public class JmsSenderShim {
}
protected static BytesMessage createBytesMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
- BytesMessage message = session.createBytesMessage();
- switch (testValueType) {
- case "boolean":
- message.writeBoolean(Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.writeByte(Byte.decode(testValue));
- break;
- case "bytes":
- message.writeBytes(testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X" or "\xNN"
- message.writeChar(testValue.charAt(0));
- } else {
- throw new Exception("JmsSenderShim.createBytesMessage() Malformed char string: \"" + testValue + "\" of length " + testValue.length());
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.writeInt(Integer.decode(testValue));
- break;
- case "long":
- message.writeLong(Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.writeObject(obj);
- break;
- case "short":
- message.writeShort(Short.decode(testValue));
- break;
- case "string":
- message.writeUTF(testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
+ BytesMessage message = session.createBytesMessage();
+ switch (testValueType) {
+ case "boolean":
+ message.writeBoolean(Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.writeByte(Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.writeBytes(testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X" or "\xNN"
+ message.writeChar(testValue.charAt(0));
+ } else {
+ throw new Exception("JmsSenderShim.createBytesMessage() Malformed char string: \"" + testValue + "\" of length " + testValue.length());
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.writeInt(Integer.decode(testValue));
+ break;
+ case "long":
+ message.writeLong(Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.writeObject(obj);
+ break;
+ case "short":
+ message.writeShort(Short.decode(testValue));
+ break;
+ case "string":
+ message.writeUTF(testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
}
protected static MapMessage createMapMessage(Session session, String testValueType, String testValue, int testValueNum) throws Exception, JMSException {
- MapMessage message = session.createMapMessage();
- String name = String.format("%s%03d", testValueType, testValueNum);
- switch (testValueType) {
- case "boolean":
- message.setBoolean(name, Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.setByte(name, Byte.decode(testValue));
- break;
- case "bytes":
- message.setBytes(name, testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X"
- message.setChar(name, testValue.charAt(0));
- } else if (testValue.length() == 6) { // Char format: "\xNNNN"
- message.setChar(name, (char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createMapMessage() Malformed char string: \"" + testValue + "\"");
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.setDouble(name, Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.setFloat(name, Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.setInt(name, Integer.decode(testValue));
- break;
- case "long":
- message.setLong(name, Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.setObject(name, obj);
- break;
- case "short":
- message.setShort(name, Short.decode(testValue));
- break;
- case "string":
- message.setString(name, testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
+ MapMessage message = session.createMapMessage();
+ String name = String.format("%s%03d", testValueType, testValueNum);
+ switch (testValueType) {
+ case "boolean":
+ message.setBoolean(name, Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.setByte(name, Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.setBytes(name, testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X"
+ message.setChar(name, testValue.charAt(0));
+ } else if (testValue.length() == 6) { // Char format: "\xNNNN"
+ message.setChar(name, (char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createMapMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.setDouble(name, Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.setFloat(name, Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.setInt(name, Integer.decode(testValue));
+ break;
+ case "long":
+ message.setLong(name, Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.setObject(name, obj);
+ break;
+ case "short":
+ message.setShort(name, Short.decode(testValue));
+ break;
+ case "string":
+ message.setString(name, testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
}
protected static ObjectMessage createObjectMessage(Session session, String className, String testValue) throws Exception, JMSException {
- Serializable obj = createJavaObject(className, testValue);
- if (obj == null) {
- // TODO: Handle error here
- System.out.println("createObjectMessage: obj == null");
- return null;
- }
- ObjectMessage message = session.createObjectMessage();
- message.setObject(obj);
- return message;
+ Serializable obj = createJavaObject(className, testValue);
+ if (obj == null) {
+ // TODO: Handle error here
+ System.out.println("createObjectMessage: obj == null");
+ return null;
+ }
+ ObjectMessage message = session.createObjectMessage();
+ message.setObject(obj);
+ return message;
}
protected static StreamMessage createStreamMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
- StreamMessage message = session.createStreamMessage();
- switch (testValueType) {
- case "boolean":
- message.writeBoolean(Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.writeByte(Byte.decode(testValue));
- break;
- case "bytes":
- message.writeBytes(testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X"
- message.writeChar(testValue.charAt(0));
- } else if (testValue.length() == 6) { // Char format: "\xNNNN"
- message.writeChar((char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.writeInt(Integer.decode(testValue));
- break;
- case "long":
- message.writeLong(Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.writeObject(obj);
- break;
- case "short":
- message.writeShort(Short.decode(testValue));
- break;
- case "string":
- message.writeString(testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
+ StreamMessage message = session.createStreamMessage();
+ switch (testValueType) {
+ case "boolean":
+ message.writeBoolean(Boolean.parseBoolean(testValue));
+ break;
+ case "byte":
+ message.writeByte(Byte.decode(testValue));
+ break;
+ case "bytes":
+ message.writeBytes(testValue.getBytes());
+ break;
+ case "char":
+ if (testValue.length() == 1) { // Char format: "X"
+ message.writeChar(testValue.charAt(0));
+ } else if (testValue.length() == 6) { // Char format: "\xNNNN"
+ message.writeChar((char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValue.substring(3), 16);
+ message.writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValue.substring(2), 16);
+ message.writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "int":
+ message.writeInt(Integer.decode(testValue));
+ break;
+ case "long":
+ message.writeLong(Long.decode(testValue));
+ break;
+ case "object":
+ Object obj = (Object)createObject(testValue);
+ message.writeObject(obj);
+ break;
+ case "short":
+ message.writeShort(Short.decode(testValue));
+ break;
+ case "string":
+ message.writeString(testValue);
+ break;
+ default:
+ throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+ }
+ return message;
}
protected static Serializable createJavaObject(String className, String testValue) throws Exception {
- Serializable obj = null;
- try {
- Class<?> c = Class.forName(className);
- if (className.compareTo("java.lang.Character") == 0) {
- Constructor ctor = c.getConstructor(char.class);
- if (testValue.length() == 1) {
- // Use first character of string
- obj = (Serializable)ctor.newInstance(testValue.charAt(0));
- } else if (testValue.length() == 4 || testValue.length() == 6) {
- // Format '\xNN' or '\xNNNN'
- obj = (Serializable)ctor.newInstance((char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
- }
- } else {
- // Use string constructor
- Constructor ctor = c.getConstructor(String.class);
- obj = (Serializable)ctor.newInstance(testValue);
- }
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- }
- catch (NoSuchMethodException e) {
- e.printStackTrace(System.out);
- }
- catch (InstantiationException e) {
- e.printStackTrace(System.out);
- }
- catch (IllegalAccessException e) {
- e.printStackTrace(System.out);
- }
- catch (InvocationTargetException e) {
- e.printStackTrace(System.out);
- }
- return obj;
+ Serializable obj = null;
+ try {
+ Class<?> c = Class.forName(className);
+ if (className.compareTo("java.lang.Character") == 0) {
+ Constructor ctor = c.getConstructor(char.class);
+ if (testValue.length() == 1) {
+ // Use first character of string
+ obj = (Serializable)ctor.newInstance(testValue.charAt(0));
+ } else if (testValue.length() == 4 || testValue.length() == 6) {
+ // Format '\xNN' or '\xNNNN'
+ obj = (Serializable)ctor.newInstance((char)Integer.parseInt(testValue.substring(2), 16));
+ } else {
+ throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
+ }
+ } else {
+ // Use string constructor
+ Constructor ctor = c.getConstructor(String.class);
+ obj = (Serializable)ctor.newInstance(testValue);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (NoSuchMethodException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InstantiationException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalAccessException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InvocationTargetException e) {
+ e.printStackTrace(System.out);
+ }
+ return obj;
}
// value has format "classname:ctorstrvalue"
protected static Serializable createObject(String value) throws Exception {
- Serializable obj = null;
- int colonIndex = value.indexOf(":");
- if (colonIndex >= 0) {
- String className = value.substring(0, colonIndex);
- String testValue = value.substring(colonIndex+1);
- obj = createJavaObject(className, testValue);
- } else {
- throw new Exception("createObject(): Malformed value string");
- }
- return obj;
+ Serializable obj = null;
+ int colonIndex = value.indexOf(":");
+ if (colonIndex >= 0) {
+ String className = value.substring(0, colonIndex);
+ String testValue = value.substring(colonIndex+1);
+ obj = createJavaObject(className, testValue);
+ } else {
+ throw new Exception("createObject(): Malformed value string");
+ }
+ return obj;
}
protected static TextMessage createTextMessage(Session session, String valueStr) throws JMSException {
- return session.createTextMessage(valueStr);
+ return session.createTextMessage(valueStr);
}
protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
- for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
- if (jmsMessageType.equals(supportedJmsMessageType))
- return true;
- }
- return false;
+ for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
+ if (jmsMessageType.equals(supportedJmsMessageType))
+ return true;
+ }
+ return false;
}
private static class MyExceptionListener implements ExceptionListener {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/7] qpid-interop-test git commit: QPIDIT-32: Added Maven pom files,
removed jars directory containing copies of dependent jars. Also
updated to latest Proton C++ API
Posted by kp...@apache.org.
QPIDIT-32: Added Maven pom files, removed jars directory containing copies of dependent jars. Also updated to latest Proton C++ API
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/f4b87a1e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/tree/f4b87a1e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/diff/f4b87a1e
Branch: refs/heads/master
Commit: f4b87a1edcac4d17d25cb36a8d0c80a437657596
Parents: 87e8eae
Author: Kim van der Riet <kp...@apache.org>
Authored: Wed May 4 10:28:18 2016 -0400
Committer: Kim van der Riet <kp...@apache.org>
Committed: Wed May 4 10:28:18 2016 -0400
----------------------------------------------------------------------
.gitignore | 2 +-
QUICKSTART | 15 +-
etc/proton-python-amqp-types.patch | 201 --------
jars/README | 3 -
jars/javax.json-1.0.4.jar | Bin 85147 -> 0 bytes
jars/javax.json-api-1.0.jar | Bin 19754 -> 0 bytes
jars/slf4j-nop-1.5.6.jar | Bin 5283 -> 0 bytes
java-build.sh | 15 -
java-clean.sh | 5 -
pom.xml | 37 ++
shims/qpid-jms/.gitignore | 1 +
shims/qpid-jms/java-build.sh | 28 --
shims/qpid-jms/java-clean.sh | 5 -
shims/qpid-jms/pom.xml | 97 ++++
.../qpid/interop_test/shim/AmqpReceiver.java | 271 -----------
.../qpid/interop_test/shim/AmqpSender.java | 260 ----------
.../qpid/interop_test/shim/JmsReceiverShim.java | 349 --------------
.../qpid/interop_test/shim/JmsSenderShim.java | 368 --------------
.../qpid_interop_test/shim/AmqpReceiver.java | 271 +++++++++++
.../qpid/qpid_interop_test/shim/AmqpSender.java | 260 ++++++++++
.../qpid_interop_test/shim/JmsReceiverShim.java | 349 ++++++++++++++
.../qpid_interop_test/shim/JmsSenderShim.java | 368 ++++++++++++++
shims/qpid-proton-cpp/.gitignore | 1 +
.../src/qpidit/shim/AmqpReceiver.cpp | 11 +-
.../src/qpidit/shim/AmqpReceiver.hpp | 5 +-
.../src/qpidit/shim/AmqpSender.cpp | 11 +-
.../src/qpidit/shim/AmqpSender.hpp | 6 +-
.../src/qpidit/shim/JmsReceiver.cpp | 8 +-
.../src/qpidit/shim/JmsReceiver.hpp | 2 -
.../src/qpidit/shim/JmsSender.cpp | 9 +-
.../src/qpidit/shim/JmsSender.hpp | 2 +-
.../interop_test/obj_util/BytesToJavaObj.java | 83 ----
.../interop_test/obj_util/JavaObjToBytes.java | 129 -----
src/py/qpid-interop-test/.gitignore | 2 -
src/py/qpid-interop-test/__init__.py | 25 -
src/py/qpid-interop-test/broker_properties.py | 54 ---
src/py/qpid-interop-test/interop_test_errors.py | 29 --
.../qpid-interop-test/jms/jms_message_tests.py | 481 -------------------
src/py/qpid-interop-test/test_type_map.py | 78 ---
.../types/simple_type_tests.py | 478 ------------------
src/python/qpid-interop-test/.gitignore | 2 +
src/python/qpid-interop-test/__init__.py | 25 +
.../qpid-interop-test/broker_properties.py | 54 +++
.../qpid-interop-test/interop_test_errors.py | 29 ++
.../qpid-interop-test/jms/jms_message_tests.py | 454 +++++++++++++++++
src/python/qpid-interop-test/test_type_map.py | 78 +++
.../types/simple_type_tests.py | 478 ++++++++++++++++++
utils/.gitignore | 1 +
utils/pom.xml | 55 +++
.../obj_util/BytesToJavaObj.java | 83 ++++
.../obj_util/JavaObjToBytes.java | 129 +++++
51 files changed, 2804 insertions(+), 2903 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index b83d222..8b13789 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/target/
+
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/QUICKSTART
----------------------------------------------------------------------
diff --git a/QUICKSTART b/QUICKSTART
index 7ea266e..bfd2402 100644
--- a/QUICKSTART
+++ b/QUICKSTART
@@ -32,7 +32,7 @@ mvn -DskipTests install
3 Prepare the tests
-------------------
-(ONLY IF NEEDED): Edit src/py/qpid_interop/types/simple_type_tests.py as
+(ONLY IF NEEDED): Edit src/python/qpid_interop/types/simple_type_tests.py as
needed, particularly AmqpPrimitiveTypes.TYPE_MAP which controls the AMQP types
and test values for each type.
@@ -57,7 +57,7 @@ cd ../../..
Note that installation is still to be completed, this section will change to
reflect installation details when complete.
-Select one of the two following options:
+Select one of the following two options:
a. qpid-proton installed:
Assuming proton's "make install" has been run, from top level qpid-interop-test directory:
@@ -67,7 +67,7 @@ export QPID_INTEROP_TEST_HOME=<abs path to top level qpid-interop-test directory
b. qpid-proton built but not installed:
Assuming proton's "make" has been run from a "build" directory as described in the proton README (but not make install), from top level qpid-interop-test directory:
-export PYTHONPATH=<abs path to top level qpid-proton directory>/proton-c/bindings/python:<abs path to top level qpid-proton directory>/build/proton-c/bindings/python:src/py/qpid-interop-test
+export PYTHONPATH=<abs path to top level qpid-proton directory>/proton-c/bindings/python:<abs path to top level qpid-proton directory>/build/proton-c/bindings/python:src/python/qpid-interop-test
export LD_LIBRARY_PATH=<abs path to top level qpid-proton directory>/build/proton-c
export QPID_INTEROP_TEST_HOME=<abs path to top level qpid-interop-test directory>
@@ -79,11 +79,8 @@ NOTE: For qpidd, YOU MUST USE THE FOLLOWING PARAMETERS:
From top level directory:
AMQP type tests:
-./src/py/qpid-interop-test/types/simple_type_tests.py
-
-JMS message tests: In order to correctly set the Java CLASSPATH, the versions of Qpid-jms and Qpid-proton must be known. These are set as follows:
-./src/py/qpid-interop-test/jms/jms_message_tests.py --qpid-jms-ver <jms-version> --qpid-proton-ver <proton-version>
-For example:
-./src/py/qpid-interop-test/jms/jms_message_tests.py --qpid-jms-ver 0.9.0-SNAPSHOT --qpid-proton-ver 0.13.0-SNAPSHOT
+./src/python/qpid-interop-test/types/simple_type_tests.py
+JMS message tests:
+./src/python/qpid-interop-test/jms/jms_message_tests.py
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/etc/proton-python-amqp-types.patch
----------------------------------------------------------------------
diff --git a/etc/proton-python-amqp-types.patch b/etc/proton-python-amqp-types.patch
deleted file mode 100644
index a337f2d..0000000
--- a/etc/proton-python-amqp-types.patch
+++ /dev/null
@@ -1,201 +0,0 @@
-diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
-index 0567095..9bf2ce0 100644
---- a/proton-c/bindings/python/proton/__init__.py
-+++ b/proton-c/bindings/python/proton/__init__.py
-@@ -1290,6 +1290,56 @@ class char(unicode):
- def __repr__(self):
- return "char(%s)" % unicode.__repr__(self)
-
-+class byte(int):
-+
-+ def __repr__(self):
-+ return "byte(%s)" % int.__repr__(self)
-+
-+class short(int):
-+
-+ def __repr__(self):
-+ return "short(%s)" % int.__repr__(self)
-+
-+class int32(int):
-+
-+ def __repr__(self):
-+ return "int32(%s)" % int.__repr__(self)
-+
-+class ubyte(int):
-+
-+ def __repr__(self):
-+ return "ubyte(%s)" % int.__repr__(self)
-+
-+class ushort(int):
-+
-+ def __repr__(self):
-+ return "ushort(%s)" % int.__repr__(self)
-+
-+class uint(int):
-+
-+ def __repr__(self):
-+ return "uint(%s)" % int.__repr__(self)
-+
-+class float32(float):
-+
-+ def __repr__(self):
-+ return "float32(%s)" % float.__repr__(self)
-+
-+class decimal32(int):
-+
-+ def __repr__(self):
-+ return "decimal32(%s)" % int.__repr__(self)
-+
-+class decimal64(long):
-+
-+ def __repr__(self):
-+ return "decimal64(%s)" % long.__repr__(self)
-+
-+class decimal128(bytes):
-+
-+ def __repr__(self):
-+ return "decimal128(%s)" % bytes.__repr__(self)
-+
- class Described(object):
-
- def __init__(self, descriptor, value):
-@@ -1902,42 +1952,42 @@ class Data:
- If the current node is an unsigned byte, returns its value,
- returns 0 otherwise.
- """
-- return pn_data_get_ubyte(self._data)
-+ return ubyte(pn_data_get_ubyte(self._data))
-
- def get_byte(self):
- """
- If the current node is a signed byte, returns its value, returns 0
- otherwise.
- """
-- return pn_data_get_byte(self._data)
-+ return byte(pn_data_get_byte(self._data))
-
- def get_ushort(self):
- """
- If the current node is an unsigned short, returns its value,
- returns 0 otherwise.
- """
-- return pn_data_get_ushort(self._data)
-+ return ushort(pn_data_get_ushort(self._data))
-
- def get_short(self):
- """
- If the current node is a signed short, returns its value, returns
- 0 otherwise.
- """
-- return pn_data_get_short(self._data)
-+ return short(pn_data_get_short(self._data))
-
- def get_uint(self):
- """
- If the current node is an unsigned int, returns its value, returns
- 0 otherwise.
- """
-- return pn_data_get_uint(self._data)
-+ return uint(pn_data_get_uint(self._data))
-
- def get_int(self):
- """
- If the current node is a signed int, returns its value, returns 0
- otherwise.
- """
-- return int(pn_data_get_int(self._data))
-+ return int32(pn_data_get_int(self._data))
-
- def get_char(self):
- """
-@@ -1972,7 +2022,7 @@ class Data:
- If the current node is a float, returns its value, raises 0
- otherwise.
- """
-- return pn_data_get_float(self._data)
-+ return float32(pn_data_get_float(self._data))
-
- def get_double(self):
- """
-@@ -1987,7 +2037,7 @@ class Data:
- If the current node is a decimal32, returns its value, returns 0
- otherwise.
- """
-- return pn_data_get_decimal32(self._data)
-+ return decimal32(pn_data_get_decimal32(self._data))
-
- # XXX: need to convert
- def get_decimal64(self):
-@@ -1995,7 +2045,7 @@ class Data:
- If the current node is a decimal64, returns its value, returns 0
- otherwise.
- """
-- return pn_data_get_decimal64(self._data)
-+ return decimal64(pn_data_get_decimal64(self._data))
-
- # XXX: need to convert
- def get_decimal128(self):
-@@ -2003,7 +2053,7 @@ class Data:
- If the current node is a decimal128, returns its value, returns 0
- otherwise.
- """
-- return pn_data_get_decimal128(self._data)
-+ return decimal128(pn_data_get_decimal128(self._data))
-
- def get_uuid(self):
- """
-@@ -2155,18 +2205,29 @@ class Data:
- put_mappings = {
- None.__class__: lambda s, _: s.put_null(),
- bool: put_bool,
-- dict: put_dict,
-- list: put_sequence,
-- tuple: put_sequence,
-- unicode: put_string,
-- bytes: put_binary,
-- symbol: put_symbol,
-+ ubyte: put_ubyte,
-+ ushort: put_ushort,
-+ uint: put_uint,
-+ ulong: put_ulong,
-+ byte: put_byte,
-+ short: put_short,
-+ int32: put_int,
-+ int: put_long,
- long: put_long,
-+ float32: put_float,
-+ float: put_double,
-+ decimal32: put_decimal32,
-+ decimal64: put_decimal64,
-+ decimal128: put_decimal128,
- char: put_char,
-- ulong: put_ulong,
- timestamp: put_timestamp,
-- float: put_double,
- uuid.UUID: put_uuid,
-+ bytes: put_binary,
-+ unicode: put_string,
-+ symbol: put_symbol,
-+ list: put_sequence,
-+ tuple: put_sequence,
-+ dict: put_dict,
- Described: put_py_described,
- Array: put_py_array
- }
-@@ -4123,5 +4184,15 @@ __all__ = [
- "dispatch",
- "symbol",
- "timestamp",
-- "ulong"
-+ "ulong",
-+ "byte",
-+ "short",
-+ "int32",
-+ "ubyte",
-+ "ushort",
-+ "uint",
-+ "float32",
-+ "decimal32",
-+ "decimal64",
-+ "decimal128"
- ]
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/jars/README
----------------------------------------------------------------------
diff --git a/jars/README b/jars/README
deleted file mode 100644
index 4aea73f..0000000
--- a/jars/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory is a temporary landing place for jars that need to be included
-in the java CLASSPATH. Once this project has been Maven-ized, it is expected
-that this will be handled automatically by Maven and this dir will go away.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/jars/javax.json-1.0.4.jar
----------------------------------------------------------------------
diff --git a/jars/javax.json-1.0.4.jar b/jars/javax.json-1.0.4.jar
deleted file mode 100644
index 09967d8..0000000
Binary files a/jars/javax.json-1.0.4.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/jars/javax.json-api-1.0.jar
----------------------------------------------------------------------
diff --git a/jars/javax.json-api-1.0.jar b/jars/javax.json-api-1.0.jar
deleted file mode 100644
index d276c79..0000000
Binary files a/jars/javax.json-api-1.0.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/jars/slf4j-nop-1.5.6.jar
----------------------------------------------------------------------
diff --git a/jars/slf4j-nop-1.5.6.jar b/jars/slf4j-nop-1.5.6.jar
deleted file mode 100644
index 71fda42..0000000
Binary files a/jars/slf4j-nop-1.5.6.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/java-build.sh
----------------------------------------------------------------------
diff --git a/java-build.sh b/java-build.sh
deleted file mode 100755
index 27de828..0000000
--- a/java-build.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-# JARS
-#JMS_API=${HOME}/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:${HOME}/.m2/repository/org/apache/qpid/qpid-jms-client/0.4.0-SNAPSHOT/qpid-jms-client-0.4.0-SNAPSHOT.jar
-#JSON_API=../../jars/javax.json-api-1.0.jar
-#CLASSPATH=${JMS_API}:${JSON_API}
-CLASSPATH=
-
-BASEPATH=org/apache/qpid/interop_test/obj_util
-SRCPATH=src/main/java/${BASEPATH}
-TARGETPATH=target
-
-mkdir -p ${TARGETPATH}/classes
-javac -cp ${CLASSPATH} -Xlint:unchecked -d ${TARGETPATH}/classes ${SRCPATH}/JavaObjToBytes.java ${SRCPATH}/BytesToJavaObj.java
-jar -cf ${TARGETPATH}/JavaObjUtils.jar -C ${TARGETPATH}/classes ${BASEPATH}/JavaObjToBytes.class -C ${TARGETPATH}/classes ${BASEPATH}/BytesToJavaObj.class
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/java-clean.sh
----------------------------------------------------------------------
diff --git a/java-clean.sh b/java-clean.sh
deleted file mode 100755
index 7fc8be1..0000000
--- a/java-clean.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-TARGETPATH=target
-
-rm -rf ${TARGETPATH}/*.jar ${TARGETPATH}/classes/*
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..a00b546
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <name>qpid-interop-test-parent</name>
+ <url>https://qpid.apache.org</url>
+
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-interop-test-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <modules>
+ <module>shims/qpid-jms</module>
+ <module>utils</module>
+ </modules>
+
+ <dependencies>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/.gitignore
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/.gitignore b/shims/qpid-jms/.gitignore
index b83d222..c0fa915 100644
--- a/shims/qpid-jms/.gitignore
+++ b/shims/qpid-jms/.gitignore
@@ -1 +1,2 @@
+/cp.txt
/target/
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/java-build.sh
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/java-build.sh b/shims/qpid-jms/java-build.sh
deleted file mode 100755
index 587c5ca..0000000
--- a/shims/qpid-jms/java-build.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-# JARS
-MVN_LOCAL_REPOSITORY=${HOME}/.m2/repository
-QPID_JMS_CLIENT_LOCATION=${MVN_LOCAL_REPOSITORY}/org/apache/qpid/qpid-jms-client
-
-echo "Available qpid-jms client versions:"
-for d in ${QPID_JMS_CLIENT_LOCATION}/*; do
- if [ -d ${d} ]; then
- echo " ${d##*/}"
- fi
-done
-
-# TODO: get this from the above list, which needs sorting to find latest version by default
-JMS_VERSION=0.9.0-SNAPSHOT
-echo "Current qpid-jms client version: ${JMS_VERSION}"
-
-JMS_API=${MVN_LOCAL_REPOSITORY}/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:${QPID_JMS_CLIENT_LOCATION}/${JMS_VERSION}/qpid-jms-client-${JMS_VERSION}.jar
-JSON_API=../../jars/javax.json-api-1.0.jar
-CLASSPATH=${JMS_API}:${JSON_API}
-
-BASEPATH=org/apache/qpid/interop_test/shim
-SRCPATH=src/main/java/${BASEPATH}
-TARGETPATH=target
-
-mkdir -p ${TARGETPATH}/classes
-javac -cp ${CLASSPATH} -Xlint:unchecked -d ${TARGETPATH}/classes ${SRCPATH}/AmqpSender.java ${SRCPATH}/AmqpReceiver.java ${SRCPATH}/JmsSenderShim.java ${SRCPATH}/JmsReceiverShim.java
-jar -cf ${TARGETPATH}/qpid-jms-shim.jar -C ${TARGETPATH}/classes ${BASEPATH}/AmqpSender.class -C ${TARGETPATH}/classes ${BASEPATH}/AmqpSender\$1.class -C ${TARGETPATH}/classes ${BASEPATH}/AmqpSender\$MyExceptionListener.class -C ${TARGETPATH}/classes ${BASEPATH}/AmqpReceiver.class -C ${TARGETPATH}/classes ${BASEPATH}/AmqpReceiver\$1.class -C ${TARGETPATH}/classes ${BASEPATH}/AmqpReceiver\$MyExceptionListener.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsSenderShim.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsSenderShim\$1.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsSenderShim\$MyExceptionListener.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsReceiverShim.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsReceiverShim\$1.class -C ${TARGETPATH}/classes ${BASEPATH}/JmsReceiverShim\$MyExceptionListener.class
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/java-clean.sh
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/java-clean.sh b/shims/qpid-jms/java-clean.sh
deleted file mode 100755
index 7fc8be1..0000000
--- a/shims/qpid-jms/java-clean.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-TARGETPATH=target
-
-rm -rf ${TARGETPATH}/*.jar ${TARGETPATH}/classes/*
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/pom.xml
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/pom.xml b/shims/qpid-jms/pom.xml
new file mode 100644
index 0000000..23aef33
--- /dev/null
+++ b/shims/qpid-jms/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <name>qpid-interop-test-jms-shim</name>
+ <url>https://qpid.apache.org</url>
+
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-interop-test-jms-shim</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-interop-test-parent</artifactId>
+ <relativePath>../../pom.xml</relativePath>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ <optimize>true</optimize>
+ <debug>true</debug>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-classpath</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build-classpath</goal>
+ </goals>
+ <configuration>
+ <outputFile>cp.txt</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.json</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-jms-client</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.7.21</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpReceiver.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpReceiver.java b/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpReceiver.java
deleted file mode 100644
index cf3ad81..0000000
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpReceiver.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.shim;
-
-import java.math.BigDecimal;
-import java.util.UUID;
-import java.util.Vector;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import org.apache.qpid.jms.JmsConnectionFactory;
-
-public class AmqpReceiver {
- private static final String USER = "guest";
- private static final String PASSWORD = "guest";
- private static final int TIMEOUT = 1000;
- private static final String[] SUPPORTED_AMQP_TYPES = {"null",
- "boolean",
- "ubyte",
- "ushort",
- "uint",
- "ulong",
- "byte",
- "short",
- "int",
- "long",
- "float",
- "double",
- "decimal32",
- "decimal64",
- "decimal128",
- "char",
- "timestamp",
- "uuid",
- "binary",
- "string",
- "symbol",
- "list",
- "map",
- "array"};
-
- public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("AmqpReceiver: Insufficient number of arguments");
- System.out.println("AmqpReceiver: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String amqpType = args[2];
- int numTestValues = Integer.parseInt(args[3]);
- Connection connection = null;
-
- try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
-
- connection = factory.createConnection(USER, PASSWORD);
- connection.setExceptionListener(new MyExceptionListener());
- connection.start();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = session.createQueue(queueName);
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- Vector<String> outList = new Vector<String>();
- outList.add(amqpType);
- if (isSupportedAmqpType(amqpType)) {
- int actualCount = 0;
- Message message = null;
- for (int i = 1; i <= numTestValues; i++, actualCount++) {
- message = messageConsumer.receive(TIMEOUT);
- if (message == null)
- break;
- switch (amqpType) {
- case "null":
- long bodyLength = ((BytesMessage)message).getBodyLength();
- if (bodyLength == 0L) {
- outList.add("None");
- } else {
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Expected 0 bytes, read " + bodyLength);
- }
- break;
- case "boolean":
- String bs = String.valueOf(((BytesMessage)message).readBoolean());
- outList.add(Character.toUpperCase(bs.charAt(0)) + bs.substring(1));
- break;
- case "ubyte":
- byte byteValue = ((BytesMessage)message).readByte();
- short ubyteValue = (short)(byteValue & 0xff);
- outList.add(String.valueOf(ubyteValue));
- break;
- case "ushort":
- {
- byte[] byteArray = new byte[2];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 2) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 2 bytes, read " + numBytes);
- }
- int ushortValue = 0;
- for (int j=0; j<byteArray.length; j++) {
- ushortValue = (ushortValue << 8) + (byteArray[j] & 0xff);
- }
- outList.add(String.valueOf(ushortValue));
- break;
- }
- case "uint":
- {
- byte[] byteArray = new byte[4];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 4) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 4 bytes, read " + numBytes);
- }
- long uintValue = 0;
- for (int j=0; j<byteArray.length; j++) {
- uintValue = (uintValue << 8) + (byteArray[j] & 0xff);
- }
- outList.add(String.valueOf(uintValue));
- break;
- }
- case "ulong":
- case "timestamp":
- {
- // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
- byte[] byteArray = new byte[8];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 8) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 8 bytes, read " + numBytes);
- }
- // TODO: shortcut in use here - this byte array should go through a Java type that can represent this as a number - such as BigInteger.
- outList.add(String.format("0x%02x%02x%02x%02x%02x%02x%02x%02x", byteArray[0], byteArray[1],
- byteArray[2], byteArray[3], byteArray[4], byteArray[5], byteArray[6], byteArray[7]));
- break;
- }
- case "byte":
- outList.add(String.valueOf(((BytesMessage)message).readByte()));
- break;
- case "short":
- outList.add(String.valueOf(((BytesMessage)message).readShort()));
- break;
- case "int":
- outList.add(String.valueOf(((BytesMessage)message).readInt()));
- break;
- case "long":
- outList.add(String.valueOf(((BytesMessage)message).readLong()));
- break;
- case "float":
- float f = ((BytesMessage)message).readFloat();
- int i0 = Float.floatToRawIntBits(f);
- outList.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "double":
- double d = ((BytesMessage)message).readDouble();
- long l = Double.doubleToRawLongBits(d);
- outList.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "decimal32":
- BigDecimal bd32 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd32.toString());
- break;
- case "decimal64":
- BigDecimal bd64 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd64.toString());
- break;
- case "decimal128":
- BigDecimal bd128 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd128.toString());
- break;
- case "char":
- outList.add(String.format("%c", ((BytesMessage)message).readChar()));
- break;
- case "uuid":
- UUID uuid = (UUID)((ObjectMessage)message).getObject();
- outList.add(uuid.toString());
- break;
- case "binary":
- BytesMessage bm = (BytesMessage)message;
- int msgLen = (int)bm.getBodyLength();
- byte[] ba = new byte[msgLen];
- if (bm.readBytes(ba) == msgLen) {
- outList.add(new String(ba));
- } else {
- // TODO: Raise exception or error here: size mismatch
- }
- break;
- case "string":
- outList.add(((TextMessage)message).getText());
- break;
- case "symbol":
- outList.add(((BytesMessage)message).readUTF());
- break;
- case "list":
- break;
- case "map":
- break;
- case "array":
- break;
- default:
- // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
- connection.close();
- throw new Exception("AmqpReceiver: Internal error: unsupported AMQP type \"" + amqpType + "\"");
- }
- }
- } else {
- System.out.println("ERROR: AmqpReceiver: AMQP type \"" + amqpType + "\" is not supported");
- connection.close();
- System.exit(1);
- }
-
- connection.close();
-
- // No exception, print results
- for (int i=0; i<outList.size(); i++) {
- System.out.println(outList.get(i));
- }
- } catch (Exception exp) {
- if (connection != null)
- connection.close();
- System.out.println("Caught exception, exiting.");
- exp.printStackTrace(System.out);
- System.exit(1);
- }
- }
-
- protected static boolean isSupportedAmqpType(String amqpType) {
- for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
- if (amqpType.equals(supportedAmqpType))
- return true;
- }
- return false;
- }
-
- private static class MyExceptionListener implements ExceptionListener {
- @Override
- public void onException(JMSException exception) {
- System.out.println("Connection ExceptionListener fired, exiting.");
- exception.printStackTrace(System.out);
- System.exit(1);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpSender.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpSender.java b/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpSender.java
deleted file mode 100644
index 3fc5a90..0000000
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/AmqpSender.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.shim;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.math.MathContext;
-import java.util.Arrays;
-import java.util.UUID;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import org.apache.qpid.jms.JmsConnectionFactory;
-
-public class AmqpSender {
- private static final String USER = "guest";
- private static final String PASSWORD = "guest";
- private static final String[] SUPPORTED_AMQP_TYPES = {"null",
- "boolean",
- "ubyte",
- "ushort",
- "uint",
- "ulong",
- "byte",
- "short",
- "int",
- "long",
- "float",
- "double",
- "decimal32",
- "decimal64",
- "decimal128",
- "char",
- "timestamp",
- "uuid",
- "binary",
- "string",
- "symbol",
- "list",
- "map",
- "array"};
-
- public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("AmqpSender: Insufficient number of arguments");
- System.out.println("AmqpSender: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String amqpType = args[2];
- String[] testValueList = Arrays.copyOfRange(args, 3, args.length); // Use remaining args as test values
-
- try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
-
- Connection connection = factory.createConnection();
- connection.setExceptionListener(new MyExceptionListener());
- connection.start();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = session.createQueue(queueName);
-
- MessageProducer messageProducer = session.createProducer(queue);
-
- if (isSupportedAmqpType(amqpType)) {
- Message message = null;
- for (String testValueStr : testValueList) {
- switch (amqpType) {
- case "null":
- message = session.createBytesMessage();
- break;
- case "boolean":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBoolean(Boolean.parseBoolean(testValueStr));
- break;
- case "ubyte":
- {
- byte testValue = (byte)Short.parseShort(testValueStr);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeByte(testValue);
- break;
- }
- case "ushort":
- {
- int testValue = Integer.parseInt(testValueStr);
- byte[] byteArray = new byte[2];
- byteArray[0] = (byte)(testValue >> 8);
- byteArray[1] = (byte)(testValue);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "uint":
- {
- long testValue = Long.parseLong(testValueStr);
- byte[] byteArray = new byte[4];
- byteArray[0] = (byte)(testValue >> 24);
- byteArray[1] = (byte)(testValue >> 16);
- byteArray[2] = (byte)(testValue >> 8);
- byteArray[3] = (byte)(testValue);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "ulong":
- {
- // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
- BigInteger testValue = new BigInteger(testValueStr);
- byte[] bigIntArray = testValue.toByteArray(); // may be 1 to 9 bytes depending on number
- byte[] byteArray = {0, 0, 0, 0, 0, 0, 0, 0};
- int effectiveBigIntArrayLen = bigIntArray.length > 8 ? 8 : bigIntArray.length; // Cap length at 8
- int bigIntArrayOffs = bigIntArray.length > 8 ? bigIntArray.length - 8 : 0; // Offset when length > 8
- for (int i=0; i<bigIntArray.length && i < 8; i++)
- byteArray[8 - effectiveBigIntArrayLen + i] = bigIntArray[bigIntArrayOffs + i];
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "byte":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeByte(Byte.parseByte(testValueStr));
- break;
- case "short":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeShort(Short.parseShort(testValueStr));
- break;
- case "int":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeInt(Integer.parseInt(testValueStr));
- break;
- case "long":
- case "timestamp":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeLong(Long.parseLong(testValueStr));
- break;
- case "float":
- Long i = Long.parseLong(testValueStr.substring(2), 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "double":
- Long l1 = Long.parseLong(testValueStr.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValueStr.substring(3), 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "decimal32":
- BigDecimal bd32 = new BigDecimal(testValueStr, MathContext.DECIMAL32);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd32);
- break;
- case "decimal64":
- BigDecimal bd64 = new BigDecimal(testValueStr, MathContext.DECIMAL64);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd64);
- break;
- case "decimal128":
- BigDecimal bd128 = new BigDecimal(testValueStr, MathContext.DECIMAL128);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd128);
- break;
- case "char":
- char c = 0;
- if (testValueStr.length() == 1) // Single char
- c = testValueStr.charAt(0);
- else if (testValueStr.length() == 6) // unicode format
- c = (char)Integer.parseInt(testValueStr, 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeChar(c);
- break;
- case "uuid":
- UUID uuid = UUID.fromString(testValueStr);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(uuid);
- break;
- case "binary":
- message = session.createBytesMessage();
- byte[] byteArray = testValueStr.getBytes();
- ((BytesMessage)message).writeBytes(byteArray, 0, byteArray.length);
- break;
- case "string":
- message = session.createTextMessage(testValueStr);
- break;
- case "symbol":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeUTF(testValueStr);
- break;
- case "list":
- break;
- case "map":
- break;
- case "array":
- break;
- default:
- // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
- connection.close();
- throw new Exception("AmqpSender: Internal error: unsupported AMQP type \"" + amqpType + "\"");
- }
- messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
- }
- } else {
- System.out.println("ERROR: AmqpSender: AMQP type \"" + amqpType + "\" is not supported");
- connection.close();
- System.exit(1);
- }
-
- connection.close();
- } catch (Exception exp) {
- System.out.println("Caught exception, exiting.");
- exp.printStackTrace(System.out);
- System.exit(1);
- }
- }
-
- protected static boolean isSupportedAmqpType(String amqpType) {
- for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
- if (amqpType.equals(supportedAmqpType))
- return true;
- }
- return false;
- }
-
- private static class MyExceptionListener implements ExceptionListener {
- @Override
- public void onException(JMSException exception) {
- System.out.println("Connection ExceptionListener fired, exiting.");
- exception.printStackTrace(System.out);
- System.exit(1);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsReceiverShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsReceiverShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsReceiverShim.java
deleted file mode 100644
index f567638..0000000
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsReceiverShim.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.shim;
-
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.json.Json;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonReader;
-import javax.json.JsonWriter;
-import org.apache.qpid.jms.JmsConnectionFactory;
-
-public class JmsReceiverShim {
- private static final String USER = "guest";
- private static final String PASSWORD = "guest";
- private static final int TIMEOUT = 1000;
- private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
- "JMS_MAPMESSAGE_TYPE",
- "JMS_OBJECTMESSAGE_TYPE",
- "JMS_STREAMMESSAGE_TYPE",
- "JMS_TEXTMESSAGE_TYPE"};
-
- // args[0]: Broker URL
- // args[1]: Queue name
- // args[2]: JMS message type
- // args[3]: JSON Test number map
- public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("JmsReceiverShim: Insufficient number of arguments");
- System.out.println("JmsReceiverShim: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String jmsMessageType = args[2];
- if (!isSupportedJmsMessageType(jmsMessageType)) {
- System.out.println("ERROR: JmsReceiverShim: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- System.exit(1);
- }
-
- JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
- JsonObject numTestValuesMap = jsonReader.readObject();
- jsonReader.close();
-
- Connection connection = null;
-
- try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
-
- connection = factory.createConnection(USER, PASSWORD);
- connection.setExceptionListener(new MyExceptionListener());
- connection.start();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = session.createQueue(queueName);
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- List<String> keyList = new ArrayList<String>(numTestValuesMap.keySet());
- Collections.sort(keyList);
-
- Message message = null;
- JsonObjectBuilder job = Json.createObjectBuilder();
- for (String key: keyList) {
- JsonArrayBuilder jab = Json.createArrayBuilder();
- for (int i=0; i<numTestValuesMap.getJsonNumber(key).intValue(); ++i) {
- message = messageConsumer.receive(TIMEOUT);
- if (message == null) break;
- switch (jmsMessageType) {
- case "JMS_BYTESMESSAGE_TYPE":
- switch (key) {
- case "boolean":
- jab.add(((BytesMessage)message).readBoolean()?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((BytesMessage)message).readByte()));
- break;
- case "bytes":
- {
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
- } else {
- // NOTE: For this case, an empty byte array has nothing to return
- jab.add(new String());
- }
- }
- break;
- case "char":
- jab.add(formatChar(((BytesMessage)message).readChar()));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((BytesMessage)message).readDouble());
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((BytesMessage)message).readFloat());
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((BytesMessage)message).readInt()));
- break;
- case "long":
- jab.add(formatLong(((BytesMessage)message).readLong()));
- break;
- case "object":
- {
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- ByteArrayInputStream bais = new ByteArrayInputStream(Arrays.copyOfRange(bytesBuff, 0, numBytesRead));
- ObjectInputStream ois = new ObjectInputStream(bais);
- Object obj = ois.readObject();
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- } else {
- jab.add("<object error>");
- }
- }
- break;
- case "short":
- jab.add(formatShort(((BytesMessage)message).readShort()));
- break;
- case "string":
- jab.add(((BytesMessage)message).readUTF());
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_STREAMMESSAGE_TYPE":
- switch (key) {
- case "boolean":
- jab.add(((StreamMessage)message).readBoolean()?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((StreamMessage)message).readByte()));
- break;
- case "bytes":
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((StreamMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
- } else {
- System.out.println("StreamMessage.readBytes() returned " + numBytesRead);
- jab.add("<bytes error>");
- }
- break;
- case "char":
- jab.add(formatChar(((StreamMessage)message).readChar()));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((StreamMessage)message).readDouble());
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((StreamMessage)message).readFloat());
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((StreamMessage)message).readInt()));
- break;
- case "long":
- jab.add(formatLong(((StreamMessage)message).readLong()));
- break;
- case "object":
- Object obj = ((StreamMessage)message).readObject();
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- break;
- case "short":
- jab.add(formatShort(((StreamMessage)message).readShort()));
- break;
- case "string":
- jab.add(((StreamMessage)message).readString());
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_MAPMESSAGE_TYPE":
- String name = String.format("%s%03d", key, i);
- switch (key) {
- case "boolean":
- jab.add(((MapMessage)message).getBoolean(name)?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((MapMessage)message).getByte(name)));
- break;
- case "bytes":
- jab.add(new String(((MapMessage)message).getBytes(name)));
- break;
- case "char":
- jab.add(formatChar(((MapMessage)message).getChar(name)));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((MapMessage)message).getDouble(name));
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((MapMessage)message).getFloat(name));
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((MapMessage)message).getInt(name)));
- break;
- case "long":
- jab.add(formatLong(((MapMessage)message).getLong(name)));
- break;
- case "object":
- Object obj = ((MapMessage)message).getObject(name);
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- break;
- case "short":
- jab.add(formatShort(((MapMessage)message).getShort(name)));
- break;
- case "string":
- jab.add(((MapMessage)message).getString(name));
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_OBJECTMESSAGE_TYPE":
- jab.add(((ObjectMessage)message).getObject().toString());
- break;
- case "JMS_TEXTMESSAGE_TYPE":
- jab.add(((TextMessage)message).getText());
- break;
- default:
- connection.close();
- throw new Exception("JmsReceiverShim: Internal error: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- }
- }
- job.add(key, jab);
- }
- connection.close();
-
- System.out.println(jmsMessageType);
- StringWriter out = new StringWriter();
- JsonWriter jsonWriter = Json.createWriter(out);
- jsonWriter.writeObject(job.build());
- jsonWriter.close();
- System.out.println(out.toString());
- } catch (Exception exp) {
- if (connection != null)
- connection.close();
- System.out.println("Caught exception, exiting.");
- exp.printStackTrace(System.out);
- System.exit(1);
- }
- }
-
- protected static String formatByte(byte b) {
- boolean neg = false;
- if (b < 0) {
- neg = true;
- b = (byte)-b;
- }
- return String.format("%s0x%x", neg?"-":"", b);
- }
-
- protected static String formatChar(char c) {
- if (Character.isLetterOrDigit(c)) {
- return String.format("%c", c);
- }
- char[] ca = {c};
- return new String(ca);
- }
-
- protected static String formatInt(int i) {
- boolean neg = false;
- if (i < 0) {
- neg = true;
- i = -i;
- }
- return String.format("%s0x%x", neg?"-":"", i);
- }
-
- protected static String formatLong(long l) {
- boolean neg = false;
- if (l < 0) {
- neg = true;
- l = -l;
- }
- return String.format("%s0x%x", neg?"-":"", l);
- }
-
- protected static String formatShort(int s) {
- boolean neg = false;
- if (s < 0) {
- neg = true;
- s = -s;
- }
- return String.format("%s0x%x", neg?"-":"", s);
- }
-
- protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
- for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
- if (jmsMessageType.equals(supportedJmsMessageType))
- return true;
- }
- return false;
- }
-
- private static class MyExceptionListener implements ExceptionListener {
- @Override
- public void onException(JMSException exception) {
- System.out.println("Connection ExceptionListener fired, exiting.");
- exception.printStackTrace(System.out);
- System.exit(1);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsSenderShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsSenderShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsSenderShim.java
deleted file mode 100644
index e22be0a..0000000
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/interop_test/shim/JmsSenderShim.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * 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.
- */
-package org.apache.qpid.interop_test.shim;
-
-import java.io.Serializable;
-import java.io.StringReader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import org.apache.qpid.jms.JmsConnectionFactory;
-
-public class JmsSenderShim {
- private static final String USER = "guest";
- private static final String PASSWORD = "guest";
- private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
- "JMS_MAPMESSAGE_TYPE",
- "JMS_OBJECTMESSAGE_TYPE",
- "JMS_STREAMMESSAGE_TYPE",
- "JMS_TEXTMESSAGE_TYPE"};
-
- // args[0]: Broker URL
- // args[1]: Queue name
- // args[2]: JMS message type
- // args[3]: JSON Test value map
- public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("JmsSenderShim: Insufficient number of arguments");
- System.out.println("JmsSenderShim: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String jmsMessageType = args[2];
- if (!isSupportedJmsMessageType(jmsMessageType)) {
- System.out.println("ERROR: JmsReceiver: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- System.exit(1);
- }
-
- JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
- JsonObject testValuesMap = jsonReader.readObject();
- jsonReader.close();
-
- try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
-
- Connection connection = factory.createConnection();
- connection.setExceptionListener(new MyExceptionListener());
- connection.start();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = session.createQueue(queueName);
-
- MessageProducer messageProducer = session.createProducer(queue);
-
- Message message = null;
- List<String> keyList = new ArrayList<String>(testValuesMap.keySet());
- Collections.sort(keyList);
- for (String key: keyList) {
- JsonArray testValues = testValuesMap.getJsonArray(key);
- for (int i=0; i<testValues.size(); ++i) {
- String testValue = testValues.getJsonString(i).getString();
- switch (jmsMessageType) {
- case "JMS_BYTESMESSAGE_TYPE":
- message = createBytesMessage(session, key, testValue);
- break;
- case "JMS_MAPMESSAGE_TYPE":
- message = createMapMessage(session, key, testValue, i);
- break;
- case "JMS_OBJECTMESSAGE_TYPE":
- message = createObjectMessage(session, key, testValue);
- break;
- case "JMS_STREAMMESSAGE_TYPE":
- message = createStreamMessage(session, key, testValue);
- break;
- case "JMS_TEXTMESSAGE_TYPE":
- message = createTextMessage(session, testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message type \"" + jmsMessageType + "\"");
- }
- messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
- }
- }
-
- connection.close();
- } catch (Exception exp) {
- System.out.println("Caught exception, exiting.");
- exp.printStackTrace(System.out);
- System.exit(1);
- }
- }
-
- protected static BytesMessage createBytesMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
- BytesMessage message = session.createBytesMessage();
- switch (testValueType) {
- case "boolean":
- message.writeBoolean(Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.writeByte(Byte.decode(testValue));
- break;
- case "bytes":
- message.writeBytes(testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X" or "\xNN"
- message.writeChar(testValue.charAt(0));
- } else {
- throw new Exception("JmsSenderShim.createBytesMessage() Malformed char string: \"" + testValue + "\" of length " + testValue.length());
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.writeInt(Integer.decode(testValue));
- break;
- case "long":
- message.writeLong(Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.writeObject(obj);
- break;
- case "short":
- message.writeShort(Short.decode(testValue));
- break;
- case "string":
- message.writeUTF(testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
- }
-
- protected static MapMessage createMapMessage(Session session, String testValueType, String testValue, int testValueNum) throws Exception, JMSException {
- MapMessage message = session.createMapMessage();
- String name = String.format("%s%03d", testValueType, testValueNum);
- switch (testValueType) {
- case "boolean":
- message.setBoolean(name, Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.setByte(name, Byte.decode(testValue));
- break;
- case "bytes":
- message.setBytes(name, testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X"
- message.setChar(name, testValue.charAt(0));
- } else if (testValue.length() == 6) { // Char format: "\xNNNN"
- message.setChar(name, (char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createMapMessage() Malformed char string: \"" + testValue + "\"");
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.setDouble(name, Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.setFloat(name, Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.setInt(name, Integer.decode(testValue));
- break;
- case "long":
- message.setLong(name, Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.setObject(name, obj);
- break;
- case "short":
- message.setShort(name, Short.decode(testValue));
- break;
- case "string":
- message.setString(name, testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
- }
-
- protected static ObjectMessage createObjectMessage(Session session, String className, String testValue) throws Exception, JMSException {
- Serializable obj = createJavaObject(className, testValue);
- if (obj == null) {
- // TODO: Handle error here
- System.out.println("createObjectMessage: obj == null");
- return null;
- }
- ObjectMessage message = session.createObjectMessage();
- message.setObject(obj);
- return message;
- }
-
- protected static StreamMessage createStreamMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
- StreamMessage message = session.createStreamMessage();
- switch (testValueType) {
- case "boolean":
- message.writeBoolean(Boolean.parseBoolean(testValue));
- break;
- case "byte":
- message.writeByte(Byte.decode(testValue));
- break;
- case "bytes":
- message.writeBytes(testValue.getBytes());
- break;
- case "char":
- if (testValue.length() == 1) { // Char format: "X"
- message.writeChar(testValue.charAt(0));
- } else if (testValue.length() == 6) { // Char format: "\xNNNN"
- message.writeChar((char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
- }
- break;
- case "double":
- Long l1 = Long.parseLong(testValue.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValue.substring(3), 16);
- message.writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "float":
- Long i = Long.parseLong(testValue.substring(2), 16);
- message.writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "int":
- message.writeInt(Integer.decode(testValue));
- break;
- case "long":
- message.writeLong(Long.decode(testValue));
- break;
- case "object":
- Object obj = (Object)createObject(testValue);
- message.writeObject(obj);
- break;
- case "short":
- message.writeShort(Short.decode(testValue));
- break;
- case "string":
- message.writeString(testValue);
- break;
- default:
- throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
- }
- return message;
- }
-
- protected static Serializable createJavaObject(String className, String testValue) throws Exception {
- Serializable obj = null;
- try {
- Class<?> c = Class.forName(className);
- if (className.compareTo("java.lang.Character") == 0) {
- Constructor ctor = c.getConstructor(char.class);
- if (testValue.length() == 1) {
- // Use first character of string
- obj = (Serializable)ctor.newInstance(testValue.charAt(0));
- } else if (testValue.length() == 4 || testValue.length() == 6) {
- // Format '\xNN' or '\xNNNN'
- obj = (Serializable)ctor.newInstance((char)Integer.parseInt(testValue.substring(2), 16));
- } else {
- throw new Exception("JmsSenderShim.createStreamMessage() Malformed char string: \"" + testValue + "\"");
- }
- } else {
- // Use string constructor
- Constructor ctor = c.getConstructor(String.class);
- obj = (Serializable)ctor.newInstance(testValue);
- }
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- }
- catch (NoSuchMethodException e) {
- e.printStackTrace(System.out);
- }
- catch (InstantiationException e) {
- e.printStackTrace(System.out);
- }
- catch (IllegalAccessException e) {
- e.printStackTrace(System.out);
- }
- catch (InvocationTargetException e) {
- e.printStackTrace(System.out);
- }
- return obj;
- }
-
- // value has format "classname:ctorstrvalue"
- protected static Serializable createObject(String value) throws Exception {
- Serializable obj = null;
- int colonIndex = value.indexOf(":");
- if (colonIndex >= 0) {
- String className = value.substring(0, colonIndex);
- String testValue = value.substring(colonIndex+1);
- obj = createJavaObject(className, testValue);
- } else {
- throw new Exception("createObject(): Malformed value string");
- }
- return obj;
- }
-
- protected static TextMessage createTextMessage(Session session, String valueStr) throws JMSException {
- return session.createTextMessage(valueStr);
- }
-
- protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
- for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
- if (jmsMessageType.equals(supportedJmsMessageType))
- return true;
- }
- return false;
- }
-
- private static class MyExceptionListener implements ExceptionListener {
- @Override
- public void onException(JMSException exception) {
- System.out.println("Connection ExceptionListener fired, exiting.");
- exception.printStackTrace(System.out);
- System.exit(1);
- }
- }
-}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[6/7] qpid-interop-test git commit: NO_JIRA: Fixed whitespace issues
in code: removed tabs, fixed indentation, removed trailing whitespace
Posted by kp...@apache.org.
NO_JIRA: Fixed whitespace issues in code: removed tabs, fixed indentation, removed trailing whitespace
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/4e6f4f29
Tree: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/tree/4e6f4f29
Diff: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/diff/4e6f4f29
Branch: refs/heads/master
Commit: 4e6f4f29102bf645ca0e155bf60666d3696c426f
Parents: f4b87a1
Author: Kim van der Riet <kp...@apache.org>
Authored: Wed May 4 13:31:04 2016 -0400
Committer: Kim van der Riet <kp...@apache.org>
Committed: Wed May 4 13:31:04 2016 -0400
----------------------------------------------------------------------
.../qpid_interop_test/shim/AmqpReceiver.java | 358 ++++++-------
.../qpid/qpid_interop_test/shim/AmqpSender.java | 354 ++++++-------
.../qpid_interop_test/shim/JmsReceiverShim.java | 486 ++++++++---------
.../qpid_interop_test/shim/JmsSenderShim.java | 519 +++++++++----------
4 files changed, 858 insertions(+), 859 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4e6f4f29/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
index cf3ad81..6e96c4d 100644
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpReceiver.java
@@ -41,44 +41,44 @@ public class AmqpReceiver {
private static final String PASSWORD = "guest";
private static final int TIMEOUT = 1000;
private static final String[] SUPPORTED_AMQP_TYPES = {"null",
- "boolean",
- "ubyte",
- "ushort",
- "uint",
- "ulong",
- "byte",
- "short",
- "int",
- "long",
- "float",
- "double",
- "decimal32",
- "decimal64",
- "decimal128",
- "char",
- "timestamp",
- "uuid",
- "binary",
- "string",
- "symbol",
- "list",
- "map",
- "array"};
+ "boolean",
+ "ubyte",
+ "ushort",
+ "uint",
+ "ulong",
+ "byte",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "decimal32",
+ "decimal64",
+ "decimal128",
+ "char",
+ "timestamp",
+ "uuid",
+ "binary",
+ "string",
+ "symbol",
+ "list",
+ "map",
+ "array"};
public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("AmqpReceiver: Insufficient number of arguments");
- System.out.println("AmqpReceiver: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String amqpType = args[2];
- int numTestValues = Integer.parseInt(args[3]);
- Connection connection = null;
+ if (args.length < 4) {
+ System.out.println("AmqpReceiver: Insufficient number of arguments");
+ System.out.println("AmqpReceiver: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String amqpType = args[2];
+ int numTestValues = Integer.parseInt(args[3]);
+ Connection connection = null;
try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
connection = factory.createConnection(USER, PASSWORD);
connection.setExceptionListener(new MyExceptionListener());
@@ -96,156 +96,156 @@ public class AmqpReceiver {
int actualCount = 0;
Message message = null;
for (int i = 1; i <= numTestValues; i++, actualCount++) {
- message = messageConsumer.receive(TIMEOUT);
- if (message == null)
- break;
- switch (amqpType) {
- case "null":
- long bodyLength = ((BytesMessage)message).getBodyLength();
- if (bodyLength == 0L) {
- outList.add("None");
- } else {
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Expected 0 bytes, read " + bodyLength);
- }
- break;
- case "boolean":
- String bs = String.valueOf(((BytesMessage)message).readBoolean());
- outList.add(Character.toUpperCase(bs.charAt(0)) + bs.substring(1));
- break;
- case "ubyte":
- byte byteValue = ((BytesMessage)message).readByte();
- short ubyteValue = (short)(byteValue & 0xff);
- outList.add(String.valueOf(ubyteValue));
- break;
- case "ushort":
- {
- byte[] byteArray = new byte[2];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 2) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 2 bytes, read " + numBytes);
- }
- int ushortValue = 0;
- for (int j=0; j<byteArray.length; j++) {
- ushortValue = (ushortValue << 8) + (byteArray[j] & 0xff);
- }
- outList.add(String.valueOf(ushortValue));
- break;
- }
- case "uint":
- {
- byte[] byteArray = new byte[4];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 4) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 4 bytes, read " + numBytes);
- }
- long uintValue = 0;
- for (int j=0; j<byteArray.length; j++) {
- uintValue = (uintValue << 8) + (byteArray[j] & 0xff);
- }
- outList.add(String.valueOf(uintValue));
- break;
- }
- case "ulong":
- case "timestamp":
- {
- // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
- byte[] byteArray = new byte[8];
- int numBytes = ((BytesMessage)message).readBytes(byteArray);
- if (numBytes != 8) {
- // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
- throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 8 bytes, read " + numBytes);
- }
- // TODO: shortcut in use here - this byte array should go through a Java type that can represent this as a number - such as BigInteger.
- outList.add(String.format("0x%02x%02x%02x%02x%02x%02x%02x%02x", byteArray[0], byteArray[1],
- byteArray[2], byteArray[3], byteArray[4], byteArray[5], byteArray[6], byteArray[7]));
- break;
- }
- case "byte":
- outList.add(String.valueOf(((BytesMessage)message).readByte()));
- break;
- case "short":
- outList.add(String.valueOf(((BytesMessage)message).readShort()));
- break;
- case "int":
- outList.add(String.valueOf(((BytesMessage)message).readInt()));
- break;
- case "long":
- outList.add(String.valueOf(((BytesMessage)message).readLong()));
- break;
- case "float":
- float f = ((BytesMessage)message).readFloat();
- int i0 = Float.floatToRawIntBits(f);
- outList.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "double":
- double d = ((BytesMessage)message).readDouble();
- long l = Double.doubleToRawLongBits(d);
- outList.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "decimal32":
- BigDecimal bd32 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd32.toString());
- break;
- case "decimal64":
- BigDecimal bd64 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd64.toString());
- break;
- case "decimal128":
- BigDecimal bd128 = (BigDecimal)((ObjectMessage)message).getObject();
- outList.add(bd128.toString());
- break;
- case "char":
- outList.add(String.format("%c", ((BytesMessage)message).readChar()));
- break;
- case "uuid":
- UUID uuid = (UUID)((ObjectMessage)message).getObject();
- outList.add(uuid.toString());
- break;
- case "binary":
- BytesMessage bm = (BytesMessage)message;
- int msgLen = (int)bm.getBodyLength();
- byte[] ba = new byte[msgLen];
- if (bm.readBytes(ba) == msgLen) {
- outList.add(new String(ba));
- } else {
- // TODO: Raise exception or error here: size mismatch
- }
- break;
- case "string":
- outList.add(((TextMessage)message).getText());
- break;
- case "symbol":
- outList.add(((BytesMessage)message).readUTF());
- break;
- case "list":
- break;
- case "map":
- break;
- case "array":
- break;
- default:
- // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
- connection.close();
- throw new Exception("AmqpReceiver: Internal error: unsupported AMQP type \"" + amqpType + "\"");
- }
+ message = messageConsumer.receive(TIMEOUT);
+ if (message == null)
+ break;
+ switch (amqpType) {
+ case "null":
+ long bodyLength = ((BytesMessage)message).getBodyLength();
+ if (bodyLength == 0L) {
+ outList.add("None");
+ } else {
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Expected 0 bytes, read " + bodyLength);
+ }
+ break;
+ case "boolean":
+ String bs = String.valueOf(((BytesMessage)message).readBoolean());
+ outList.add(Character.toUpperCase(bs.charAt(0)) + bs.substring(1));
+ break;
+ case "ubyte":
+ byte byteValue = ((BytesMessage)message).readByte();
+ short ubyteValue = (short)(byteValue & 0xff);
+ outList.add(String.valueOf(ubyteValue));
+ break;
+ case "ushort":
+ {
+ byte[] byteArray = new byte[2];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 2) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 2 bytes, read " + numBytes);
+ }
+ int ushortValue = 0;
+ for (int j=0; j<byteArray.length; j++) {
+ ushortValue = (ushortValue << 8) + (byteArray[j] & 0xff);
+ }
+ outList.add(String.valueOf(ushortValue));
+ break;
+ }
+ case "uint":
+ {
+ byte[] byteArray = new byte[4];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 4) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 4 bytes, read " + numBytes);
+ }
+ long uintValue = 0;
+ for (int j=0; j<byteArray.length; j++) {
+ uintValue = (uintValue << 8) + (byteArray[j] & 0xff);
+ }
+ outList.add(String.valueOf(uintValue));
+ break;
+ }
+ case "ulong":
+ case "timestamp":
+ {
+ // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
+ byte[] byteArray = new byte[8];
+ int numBytes = ((BytesMessage)message).readBytes(byteArray);
+ if (numBytes != 8) {
+ // TODO: numBytes == -1 means no more bytes in stream - add error message for this case?
+ throw new Exception("AmqpReceiver: JMS BytesMessage size error: Exptected 8 bytes, read " + numBytes);
+ }
+ // TODO: shortcut in use here - this byte array should go through a Java type that can represent this as a number - such as BigInteger.
+ outList.add(String.format("0x%02x%02x%02x%02x%02x%02x%02x%02x", byteArray[0], byteArray[1],
+ byteArray[2], byteArray[3], byteArray[4], byteArray[5], byteArray[6], byteArray[7]));
+ break;
+ }
+ case "byte":
+ outList.add(String.valueOf(((BytesMessage)message).readByte()));
+ break;
+ case "short":
+ outList.add(String.valueOf(((BytesMessage)message).readShort()));
+ break;
+ case "int":
+ outList.add(String.valueOf(((BytesMessage)message).readInt()));
+ break;
+ case "long":
+ outList.add(String.valueOf(((BytesMessage)message).readLong()));
+ break;
+ case "float":
+ float f = ((BytesMessage)message).readFloat();
+ int i0 = Float.floatToRawIntBits(f);
+ outList.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "double":
+ double d = ((BytesMessage)message).readDouble();
+ long l = Double.doubleToRawLongBits(d);
+ outList.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "decimal32":
+ BigDecimal bd32 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd32.toString());
+ break;
+ case "decimal64":
+ BigDecimal bd64 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd64.toString());
+ break;
+ case "decimal128":
+ BigDecimal bd128 = (BigDecimal)((ObjectMessage)message).getObject();
+ outList.add(bd128.toString());
+ break;
+ case "char":
+ outList.add(String.format("%c", ((BytesMessage)message).readChar()));
+ break;
+ case "uuid":
+ UUID uuid = (UUID)((ObjectMessage)message).getObject();
+ outList.add(uuid.toString());
+ break;
+ case "binary":
+ BytesMessage bm = (BytesMessage)message;
+ int msgLen = (int)bm.getBodyLength();
+ byte[] ba = new byte[msgLen];
+ if (bm.readBytes(ba) == msgLen) {
+ outList.add(new String(ba));
+ } else {
+ // TODO: Raise exception or error here: size mismatch
+ }
+ break;
+ case "string":
+ outList.add(((TextMessage)message).getText());
+ break;
+ case "symbol":
+ outList.add(((BytesMessage)message).readUTF());
+ break;
+ case "list":
+ break;
+ case "map":
+ break;
+ case "array":
+ break;
+ default:
+ // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
+ connection.close();
+ throw new Exception("AmqpReceiver: Internal error: unsupported AMQP type \"" + amqpType + "\"");
+ }
}
} else {
- System.out.println("ERROR: AmqpReceiver: AMQP type \"" + amqpType + "\" is not supported");
- connection.close();
- System.exit(1);
+ System.out.println("ERROR: AmqpReceiver: AMQP type \"" + amqpType + "\" is not supported");
+ connection.close();
+ System.exit(1);
}
connection.close();
// No exception, print results
for (int i=0; i<outList.size(); i++) {
- System.out.println(outList.get(i));
+ System.out.println(outList.get(i));
}
} catch (Exception exp) {
- if (connection != null)
- connection.close();
+ if (connection != null)
+ connection.close();
System.out.println("Caught exception, exiting.");
exp.printStackTrace(System.out);
System.exit(1);
@@ -253,11 +253,11 @@ public class AmqpReceiver {
}
protected static boolean isSupportedAmqpType(String amqpType) {
- for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
- if (amqpType.equals(supportedAmqpType))
- return true;
- }
- return false;
+ for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
+ if (amqpType.equals(supportedAmqpType))
+ return true;
+ }
+ return false;
}
private static class MyExceptionListener implements ExceptionListener {
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4e6f4f29/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
index 3fc5a90..9c761d7 100644
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/AmqpSender.java
@@ -43,43 +43,43 @@ public class AmqpSender {
private static final String USER = "guest";
private static final String PASSWORD = "guest";
private static final String[] SUPPORTED_AMQP_TYPES = {"null",
- "boolean",
- "ubyte",
- "ushort",
- "uint",
- "ulong",
- "byte",
- "short",
- "int",
- "long",
- "float",
- "double",
- "decimal32",
- "decimal64",
- "decimal128",
- "char",
- "timestamp",
- "uuid",
- "binary",
- "string",
- "symbol",
- "list",
- "map",
- "array"};
+ "boolean",
+ "ubyte",
+ "ushort",
+ "uint",
+ "ulong",
+ "byte",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "decimal32",
+ "decimal64",
+ "decimal128",
+ "char",
+ "timestamp",
+ "uuid",
+ "binary",
+ "string",
+ "symbol",
+ "list",
+ "map",
+ "array"};
public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("AmqpSender: Insufficient number of arguments");
- System.out.println("AmqpSender: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String amqpType = args[2];
- String[] testValueList = Arrays.copyOfRange(args, 3, args.length); // Use remaining args as test values
-
+ if (args.length < 4) {
+ System.out.println("AmqpSender: Insufficient number of arguments");
+ System.out.println("AmqpSender: Expected arguments: broker_address, queue_name, amqp_type, test_val, test_val, ...");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String amqpType = args[2];
+ String[] testValueList = Arrays.copyOfRange(args, 3, args.length); // Use remaining args as test values
+
try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
Connection connection = factory.createConnection();
connection.setExceptionListener(new MyExceptionListener());
@@ -92,145 +92,145 @@ public class AmqpSender {
MessageProducer messageProducer = session.createProducer(queue);
if (isSupportedAmqpType(amqpType)) {
- Message message = null;
- for (String testValueStr : testValueList) {
- switch (amqpType) {
- case "null":
- message = session.createBytesMessage();
- break;
- case "boolean":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBoolean(Boolean.parseBoolean(testValueStr));
- break;
- case "ubyte":
- {
- byte testValue = (byte)Short.parseShort(testValueStr);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeByte(testValue);
- break;
- }
- case "ushort":
- {
- int testValue = Integer.parseInt(testValueStr);
- byte[] byteArray = new byte[2];
- byteArray[0] = (byte)(testValue >> 8);
- byteArray[1] = (byte)(testValue);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "uint":
- {
- long testValue = Long.parseLong(testValueStr);
- byte[] byteArray = new byte[4];
- byteArray[0] = (byte)(testValue >> 24);
- byteArray[1] = (byte)(testValue >> 16);
- byteArray[2] = (byte)(testValue >> 8);
- byteArray[3] = (byte)(testValue);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "ulong":
- {
- // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
- BigInteger testValue = new BigInteger(testValueStr);
- byte[] bigIntArray = testValue.toByteArray(); // may be 1 to 9 bytes depending on number
- byte[] byteArray = {0, 0, 0, 0, 0, 0, 0, 0};
- int effectiveBigIntArrayLen = bigIntArray.length > 8 ? 8 : bigIntArray.length; // Cap length at 8
- int bigIntArrayOffs = bigIntArray.length > 8 ? bigIntArray.length - 8 : 0; // Offset when length > 8
- for (int i=0; i<bigIntArray.length && i < 8; i++)
- byteArray[8 - effectiveBigIntArrayLen + i] = bigIntArray[bigIntArrayOffs + i];
- message = session.createBytesMessage();
- ((BytesMessage)message).writeBytes(byteArray);
- break;
- }
- case "byte":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeByte(Byte.parseByte(testValueStr));
- break;
- case "short":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeShort(Short.parseShort(testValueStr));
- break;
- case "int":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeInt(Integer.parseInt(testValueStr));
- break;
- case "long":
- case "timestamp":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeLong(Long.parseLong(testValueStr));
- break;
- case "float":
- Long i = Long.parseLong(testValueStr.substring(2), 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeFloat(Float.intBitsToFloat(i.intValue()));
- break;
- case "double":
- Long l1 = Long.parseLong(testValueStr.substring(2, 3), 16) << 60;
- Long l2 = Long.parseLong(testValueStr.substring(3), 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeDouble(Double.longBitsToDouble(l1 | l2));
- break;
- case "decimal32":
- BigDecimal bd32 = new BigDecimal(testValueStr, MathContext.DECIMAL32);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd32);
- break;
- case "decimal64":
- BigDecimal bd64 = new BigDecimal(testValueStr, MathContext.DECIMAL64);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd64);
- break;
- case "decimal128":
- BigDecimal bd128 = new BigDecimal(testValueStr, MathContext.DECIMAL128);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(bd128);
- break;
- case "char":
- char c = 0;
- if (testValueStr.length() == 1) // Single char
- c = testValueStr.charAt(0);
- else if (testValueStr.length() == 6) // unicode format
- c = (char)Integer.parseInt(testValueStr, 16);
- message = session.createBytesMessage();
- ((BytesMessage)message).writeChar(c);
- break;
- case "uuid":
- UUID uuid = UUID.fromString(testValueStr);
- message = session.createObjectMessage();
- ((ObjectMessage)message).setObject(uuid);
- break;
- case "binary":
- message = session.createBytesMessage();
- byte[] byteArray = testValueStr.getBytes();
- ((BytesMessage)message).writeBytes(byteArray, 0, byteArray.length);
- break;
- case "string":
- message = session.createTextMessage(testValueStr);
- break;
- case "symbol":
- message = session.createBytesMessage();
- ((BytesMessage)message).writeUTF(testValueStr);
- break;
- case "list":
- break;
- case "map":
- break;
- case "array":
- break;
- default:
- // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
- connection.close();
- throw new Exception("AmqpSender: Internal error: unsupported AMQP type \"" + amqpType + "\"");
- }
- messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
- }
+ Message message = null;
+ for (String testValueStr : testValueList) {
+ switch (amqpType) {
+ case "null":
+ message = session.createBytesMessage();
+ break;
+ case "boolean":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBoolean(Boolean.parseBoolean(testValueStr));
+ break;
+ case "ubyte":
+ {
+ byte testValue = (byte)Short.parseShort(testValueStr);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeByte(testValue);
+ break;
+ }
+ case "ushort":
+ {
+ int testValue = Integer.parseInt(testValueStr);
+ byte[] byteArray = new byte[2];
+ byteArray[0] = (byte)(testValue >> 8);
+ byteArray[1] = (byte)(testValue);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "uint":
+ {
+ long testValue = Long.parseLong(testValueStr);
+ byte[] byteArray = new byte[4];
+ byteArray[0] = (byte)(testValue >> 24);
+ byteArray[1] = (byte)(testValue >> 16);
+ byteArray[2] = (byte)(testValue >> 8);
+ byteArray[3] = (byte)(testValue);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "ulong":
+ {
+ // TODO: Tidy this ugliness up - perhaps use of vector<byte>?
+ BigInteger testValue = new BigInteger(testValueStr);
+ byte[] bigIntArray = testValue.toByteArray(); // may be 1 to 9 bytes depending on number
+ byte[] byteArray = {0, 0, 0, 0, 0, 0, 0, 0};
+ int effectiveBigIntArrayLen = bigIntArray.length > 8 ? 8 : bigIntArray.length; // Cap length at 8
+ int bigIntArrayOffs = bigIntArray.length > 8 ? bigIntArray.length - 8 : 0; // Offset when length > 8
+ for (int i=0; i<bigIntArray.length && i < 8; i++)
+ byteArray[8 - effectiveBigIntArrayLen + i] = bigIntArray[bigIntArrayOffs + i];
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeBytes(byteArray);
+ break;
+ }
+ case "byte":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeByte(Byte.parseByte(testValueStr));
+ break;
+ case "short":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeShort(Short.parseShort(testValueStr));
+ break;
+ case "int":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeInt(Integer.parseInt(testValueStr));
+ break;
+ case "long":
+ case "timestamp":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeLong(Long.parseLong(testValueStr));
+ break;
+ case "float":
+ Long i = Long.parseLong(testValueStr.substring(2), 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeFloat(Float.intBitsToFloat(i.intValue()));
+ break;
+ case "double":
+ Long l1 = Long.parseLong(testValueStr.substring(2, 3), 16) << 60;
+ Long l2 = Long.parseLong(testValueStr.substring(3), 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeDouble(Double.longBitsToDouble(l1 | l2));
+ break;
+ case "decimal32":
+ BigDecimal bd32 = new BigDecimal(testValueStr, MathContext.DECIMAL32);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd32);
+ break;
+ case "decimal64":
+ BigDecimal bd64 = new BigDecimal(testValueStr, MathContext.DECIMAL64);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd64);
+ break;
+ case "decimal128":
+ BigDecimal bd128 = new BigDecimal(testValueStr, MathContext.DECIMAL128);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(bd128);
+ break;
+ case "char":
+ char c = 0;
+ if (testValueStr.length() == 1) // Single char
+ c = testValueStr.charAt(0);
+ else if (testValueStr.length() == 6) // unicode format
+ c = (char)Integer.parseInt(testValueStr, 16);
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeChar(c);
+ break;
+ case "uuid":
+ UUID uuid = UUID.fromString(testValueStr);
+ message = session.createObjectMessage();
+ ((ObjectMessage)message).setObject(uuid);
+ break;
+ case "binary":
+ message = session.createBytesMessage();
+ byte[] byteArray = testValueStr.getBytes();
+ ((BytesMessage)message).writeBytes(byteArray, 0, byteArray.length);
+ break;
+ case "string":
+ message = session.createTextMessage(testValueStr);
+ break;
+ case "symbol":
+ message = session.createBytesMessage();
+ ((BytesMessage)message).writeUTF(testValueStr);
+ break;
+ case "list":
+ break;
+ case "map":
+ break;
+ case "array":
+ break;
+ default:
+ // Internal error, should never happen if SUPPORTED_AMQP_TYPES matches this case stmt
+ connection.close();
+ throw new Exception("AmqpSender: Internal error: unsupported AMQP type \"" + amqpType + "\"");
+ }
+ messageProducer.send(message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ }
} else {
- System.out.println("ERROR: AmqpSender: AMQP type \"" + amqpType + "\" is not supported");
- connection.close();
- System.exit(1);
+ System.out.println("ERROR: AmqpSender: AMQP type \"" + amqpType + "\" is not supported");
+ connection.close();
+ System.exit(1);
}
connection.close();
@@ -242,11 +242,11 @@ public class AmqpSender {
}
protected static boolean isSupportedAmqpType(String amqpType) {
- for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
- if (amqpType.equals(supportedAmqpType))
- return true;
- }
- return false;
+ for (String supportedAmqpType: SUPPORTED_AMQP_TYPES) {
+ if (amqpType.equals(supportedAmqpType))
+ return true;
+ }
+ return false;
}
private static class MyExceptionListener implements ExceptionListener {
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4e6f4f29/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
----------------------------------------------------------------------
diff --git a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
index f567638..6cdb886 100644
--- a/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
+++ b/shims/qpid-jms/src/main/java/org/apache/qpid/qpid_interop_test/shim/JmsReceiverShim.java
@@ -50,236 +50,236 @@ public class JmsReceiverShim {
private static final String PASSWORD = "guest";
private static final int TIMEOUT = 1000;
private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_BYTESMESSAGE_TYPE",
- "JMS_MAPMESSAGE_TYPE",
- "JMS_OBJECTMESSAGE_TYPE",
- "JMS_STREAMMESSAGE_TYPE",
- "JMS_TEXTMESSAGE_TYPE"};
+ "JMS_MAPMESSAGE_TYPE",
+ "JMS_OBJECTMESSAGE_TYPE",
+ "JMS_STREAMMESSAGE_TYPE",
+ "JMS_TEXTMESSAGE_TYPE"};
// args[0]: Broker URL
// args[1]: Queue name
// args[2]: JMS message type
// args[3]: JSON Test number map
public static void main(String[] args) throws Exception {
- if (args.length < 4) {
- System.out.println("JmsReceiverShim: Insufficient number of arguments");
- System.out.println("JmsReceiverShim: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
- System.exit(1);
- }
- String brokerAddress = "amqp://" + args[0];
- String queueName = args[1];
- String jmsMessageType = args[2];
- if (!isSupportedJmsMessageType(jmsMessageType)) {
- System.out.println("ERROR: JmsReceiverShim: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- System.exit(1);
- }
-
- JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
- JsonObject numTestValuesMap = jsonReader.readObject();
- jsonReader.close();
-
- Connection connection = null;
+ if (args.length < 4) {
+ System.out.println("JmsReceiverShim: Insufficient number of arguments");
+ System.out.println("JmsReceiverShim: Expected arguments: broker_address, queue_name, amqp_type, num_test_values");
+ System.exit(1);
+ }
+ String brokerAddress = "amqp://" + args[0];
+ String queueName = args[1];
+ String jmsMessageType = args[2];
+ if (!isSupportedJmsMessageType(jmsMessageType)) {
+ System.out.println("ERROR: JmsReceiverShim: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ System.exit(1);
+ }
+
+ JsonReader jsonReader = Json.createReader(new StringReader(args[3]));
+ JsonObject numTestValuesMap = jsonReader.readObject();
+ jsonReader.close();
+
+ Connection connection = null;
try {
- ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
+ ConnectionFactory factory = (ConnectionFactory)new JmsConnectionFactory(brokerAddress);
connection = factory.createConnection(USER, PASSWORD);
connection.setExceptionListener(new MyExceptionListener());
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
Queue queue = session.createQueue(queueName);
MessageConsumer messageConsumer = session.createConsumer(queue);
- List<String> keyList = new ArrayList<String>(numTestValuesMap.keySet());
- Collections.sort(keyList);
-
+ List<String> keyList = new ArrayList<String>(numTestValuesMap.keySet());
+ Collections.sort(keyList);
+
Message message = null;
JsonObjectBuilder job = Json.createObjectBuilder();
- for (String key: keyList) {
- JsonArrayBuilder jab = Json.createArrayBuilder();
- for (int i=0; i<numTestValuesMap.getJsonNumber(key).intValue(); ++i) {
- message = messageConsumer.receive(TIMEOUT);
- if (message == null) break;
- switch (jmsMessageType) {
- case "JMS_BYTESMESSAGE_TYPE":
- switch (key) {
- case "boolean":
- jab.add(((BytesMessage)message).readBoolean()?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((BytesMessage)message).readByte()));
- break;
- case "bytes":
- {
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
- } else {
- // NOTE: For this case, an empty byte array has nothing to return
- jab.add(new String());
- }
- }
- break;
- case "char":
- jab.add(formatChar(((BytesMessage)message).readChar()));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((BytesMessage)message).readDouble());
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((BytesMessage)message).readFloat());
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((BytesMessage)message).readInt()));
- break;
- case "long":
- jab.add(formatLong(((BytesMessage)message).readLong()));
- break;
- case "object":
- {
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- ByteArrayInputStream bais = new ByteArrayInputStream(Arrays.copyOfRange(bytesBuff, 0, numBytesRead));
- ObjectInputStream ois = new ObjectInputStream(bais);
- Object obj = ois.readObject();
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- } else {
- jab.add("<object error>");
- }
- }
- break;
- case "short":
- jab.add(formatShort(((BytesMessage)message).readShort()));
- break;
- case "string":
- jab.add(((BytesMessage)message).readUTF());
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_STREAMMESSAGE_TYPE":
- switch (key) {
- case "boolean":
- jab.add(((StreamMessage)message).readBoolean()?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((StreamMessage)message).readByte()));
- break;
- case "bytes":
- byte[] bytesBuff = new byte[65536];
- int numBytesRead = ((StreamMessage)message).readBytes(bytesBuff);
- if (numBytesRead >= 0) {
- jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
- } else {
- System.out.println("StreamMessage.readBytes() returned " + numBytesRead);
- jab.add("<bytes error>");
- }
- break;
- case "char":
- jab.add(formatChar(((StreamMessage)message).readChar()));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((StreamMessage)message).readDouble());
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((StreamMessage)message).readFloat());
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((StreamMessage)message).readInt()));
- break;
- case "long":
- jab.add(formatLong(((StreamMessage)message).readLong()));
- break;
- case "object":
- Object obj = ((StreamMessage)message).readObject();
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- break;
- case "short":
- jab.add(formatShort(((StreamMessage)message).readShort()));
- break;
- case "string":
- jab.add(((StreamMessage)message).readString());
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_MAPMESSAGE_TYPE":
- String name = String.format("%s%03d", key, i);
- switch (key) {
- case "boolean":
- jab.add(((MapMessage)message).getBoolean(name)?"True":"False");
- break;
- case "byte":
- jab.add(formatByte(((MapMessage)message).getByte(name)));
- break;
- case "bytes":
- jab.add(new String(((MapMessage)message).getBytes(name)));
- break;
- case "char":
- jab.add(formatChar(((MapMessage)message).getChar(name)));
- break;
- case "double":
- long l = Double.doubleToRawLongBits(((MapMessage)message).getDouble(name));
- jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
- break;
- case "float":
- int i0 = Float.floatToRawIntBits(((MapMessage)message).getFloat(name));
- jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
- break;
- case "int":
- jab.add(formatInt(((MapMessage)message).getInt(name)));
- break;
- case "long":
- jab.add(formatLong(((MapMessage)message).getLong(name)));
- break;
- case "object":
- Object obj = ((MapMessage)message).getObject(name);
- jab.add(obj.getClass().getName() + ":" + obj.toString());
- break;
- case "short":
- jab.add(formatShort(((MapMessage)message).getShort(name)));
- break;
- case "string":
- jab.add(((MapMessage)message).getString(name));
- break;
- default:
- throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
- }
- break;
- case "JMS_OBJECTMESSAGE_TYPE":
- jab.add(((ObjectMessage)message).getObject().toString());
- break;
- case "JMS_TEXTMESSAGE_TYPE":
- jab.add(((TextMessage)message).getText());
- break;
- default:
- connection.close();
- throw new Exception("JmsReceiverShim: Internal error: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
- }
- }
- job.add(key, jab);
- }
- connection.close();
-
- System.out.println(jmsMessageType);
- StringWriter out = new StringWriter();
- JsonWriter jsonWriter = Json.createWriter(out);
- jsonWriter.writeObject(job.build());
- jsonWriter.close();
- System.out.println(out.toString());
+ for (String key: keyList) {
+ JsonArrayBuilder jab = Json.createArrayBuilder();
+ for (int i=0; i<numTestValuesMap.getJsonNumber(key).intValue(); ++i) {
+ message = messageConsumer.receive(TIMEOUT);
+ if (message == null) break;
+ switch (jmsMessageType) {
+ case "JMS_BYTESMESSAGE_TYPE":
+ switch (key) {
+ case "boolean":
+ jab.add(((BytesMessage)message).readBoolean()?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((BytesMessage)message).readByte()));
+ break;
+ case "bytes":
+ {
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
+ } else {
+ // NOTE: For this case, an empty byte array has nothing to return
+ jab.add(new String());
+ }
+ }
+ break;
+ case "char":
+ jab.add(formatChar(((BytesMessage)message).readChar()));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((BytesMessage)message).readDouble());
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((BytesMessage)message).readFloat());
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((BytesMessage)message).readInt()));
+ break;
+ case "long":
+ jab.add(formatLong(((BytesMessage)message).readLong()));
+ break;
+ case "object":
+ {
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((BytesMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(Arrays.copyOfRange(bytesBuff, 0, numBytesRead));
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ Object obj = ois.readObject();
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ } else {
+ jab.add("<object error>");
+ }
+ }
+ break;
+ case "short":
+ jab.add(formatShort(((BytesMessage)message).readShort()));
+ break;
+ case "string":
+ jab.add(((BytesMessage)message).readUTF());
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_STREAMMESSAGE_TYPE":
+ switch (key) {
+ case "boolean":
+ jab.add(((StreamMessage)message).readBoolean()?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((StreamMessage)message).readByte()));
+ break;
+ case "bytes":
+ byte[] bytesBuff = new byte[65536];
+ int numBytesRead = ((StreamMessage)message).readBytes(bytesBuff);
+ if (numBytesRead >= 0) {
+ jab.add(new String(Arrays.copyOfRange(bytesBuff, 0, numBytesRead)));
+ } else {
+ System.out.println("StreamMessage.readBytes() returned " + numBytesRead);
+ jab.add("<bytes error>");
+ }
+ break;
+ case "char":
+ jab.add(formatChar(((StreamMessage)message).readChar()));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((StreamMessage)message).readDouble());
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((StreamMessage)message).readFloat());
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((StreamMessage)message).readInt()));
+ break;
+ case "long":
+ jab.add(formatLong(((StreamMessage)message).readLong()));
+ break;
+ case "object":
+ Object obj = ((StreamMessage)message).readObject();
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ break;
+ case "short":
+ jab.add(formatShort(((StreamMessage)message).readShort()));
+ break;
+ case "string":
+ jab.add(((StreamMessage)message).readString());
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_MAPMESSAGE_TYPE":
+ String name = String.format("%s%03d", key, i);
+ switch (key) {
+ case "boolean":
+ jab.add(((MapMessage)message).getBoolean(name)?"True":"False");
+ break;
+ case "byte":
+ jab.add(formatByte(((MapMessage)message).getByte(name)));
+ break;
+ case "bytes":
+ jab.add(new String(((MapMessage)message).getBytes(name)));
+ break;
+ case "char":
+ jab.add(formatChar(((MapMessage)message).getChar(name)));
+ break;
+ case "double":
+ long l = Double.doubleToRawLongBits(((MapMessage)message).getDouble(name));
+ jab.add(String.format("0x%16s", Long.toHexString(l)).replace(' ', '0'));
+ break;
+ case "float":
+ int i0 = Float.floatToRawIntBits(((MapMessage)message).getFloat(name));
+ jab.add(String.format("0x%8s", Integer.toHexString(i0)).replace(' ', '0'));
+ break;
+ case "int":
+ jab.add(formatInt(((MapMessage)message).getInt(name)));
+ break;
+ case "long":
+ jab.add(formatLong(((MapMessage)message).getLong(name)));
+ break;
+ case "object":
+ Object obj = ((MapMessage)message).getObject(name);
+ jab.add(obj.getClass().getName() + ":" + obj.toString());
+ break;
+ case "short":
+ jab.add(formatShort(((MapMessage)message).getShort(name)));
+ break;
+ case "string":
+ jab.add(((MapMessage)message).getString(name));
+ break;
+ default:
+ throw new Exception("JmsReceiverShim: Unknown subtype for " + jmsMessageType + ": \"" + key + "\"");
+ }
+ break;
+ case "JMS_OBJECTMESSAGE_TYPE":
+ jab.add(((ObjectMessage)message).getObject().toString());
+ break;
+ case "JMS_TEXTMESSAGE_TYPE":
+ jab.add(((TextMessage)message).getText());
+ break;
+ default:
+ connection.close();
+ throw new Exception("JmsReceiverShim: Internal error: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+ }
+ }
+ job.add(key, jab);
+ }
+ connection.close();
+
+ System.out.println(jmsMessageType);
+ StringWriter out = new StringWriter();
+ JsonWriter jsonWriter = Json.createWriter(out);
+ jsonWriter.writeObject(job.build());
+ jsonWriter.close();
+ System.out.println(out.toString());
} catch (Exception exp) {
- if (connection != null)
- connection.close();
+ if (connection != null)
+ connection.close();
System.out.println("Caught exception, exiting.");
exp.printStackTrace(System.out);
System.exit(1);
@@ -287,55 +287,55 @@ public class JmsReceiverShim {
}
protected static String formatByte(byte b) {
- boolean neg = false;
- if (b < 0) {
- neg = true;
- b = (byte)-b;
- }
- return String.format("%s0x%x", neg?"-":"", b);
+ boolean neg = false;
+ if (b < 0) {
+ neg = true;
+ b = (byte)-b;
+ }
+ return String.format("%s0x%x", neg?"-":"", b);
}
protected static String formatChar(char c) {
- if (Character.isLetterOrDigit(c)) {
- return String.format("%c", c);
- }
- char[] ca = {c};
- return new String(ca);
+ if (Character.isLetterOrDigit(c)) {
+ return String.format("%c", c);
+ }
+ char[] ca = {c};
+ return new String(ca);
}
protected static String formatInt(int i) {
- boolean neg = false;
- if (i < 0) {
- neg = true;
- i = -i;
- }
- return String.format("%s0x%x", neg?"-":"", i);
+ boolean neg = false;
+ if (i < 0) {
+ neg = true;
+ i = -i;
+ }
+ return String.format("%s0x%x", neg?"-":"", i);
}
protected static String formatLong(long l) {
- boolean neg = false;
- if (l < 0) {
- neg = true;
- l = -l;
- }
- return String.format("%s0x%x", neg?"-":"", l);
+ boolean neg = false;
+ if (l < 0) {
+ neg = true;
+ l = -l;
+ }
+ return String.format("%s0x%x", neg?"-":"", l);
}
protected static String formatShort(int s) {
- boolean neg = false;
- if (s < 0) {
- neg = true;
- s = -s;
- }
- return String.format("%s0x%x", neg?"-":"", s);
+ boolean neg = false;
+ if (s < 0) {
+ neg = true;
+ s = -s;
+ }
+ return String.format("%s0x%x", neg?"-":"", s);
}
protected static boolean isSupportedJmsMessageType(String jmsMessageType) {
- for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
- if (jmsMessageType.equals(supportedJmsMessageType))
- return true;
- }
- return false;
+ for (String supportedJmsMessageType: SUPPORTED_JMS_MESSAGE_TYPES) {
+ if (jmsMessageType.equals(supportedJmsMessageType))
+ return true;
+ }
+ return false;
}
private static class MyExceptionListener implements ExceptionListener {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[7/7] qpid-interop-test git commit: NO_JIRA: Fixed whitespace issues
in code: removed tabs, fixed indentation, removed trailing whitespace
Posted by kp...@apache.org.
NO_JIRA: Fixed whitespace issues in code: removed tabs, fixed indentation, removed trailing whitespace
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/36c7b3be
Tree: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/tree/36c7b3be
Diff: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/diff/36c7b3be
Branch: refs/heads/master
Commit: 36c7b3be80e71f41f4a2625cf3cec336f205c2c5
Parents: 4e6f4f2
Author: Kim van der Riet <kp...@apache.org>
Authored: Wed May 4 13:36:28 2016 -0400
Committer: Kim van der Riet <kp...@apache.org>
Committed: Wed May 4 13:36:28 2016 -0400
----------------------------------------------------------------------
.../obj_util/BytesToJavaObj.java | 110 +++++------
.../obj_util/JavaObjToBytes.java | 184 +++++++++----------
2 files changed, 147 insertions(+), 147 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/36c7b3be/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
index 8c461ce..0d97333 100644
--- a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
+++ b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/BytesToJavaObj.java
@@ -23,61 +23,61 @@ import java.io.ObjectInputStream;
import java.io.Serializable;
public class BytesToJavaObj {
- String hexObjStr = null;
- Serializable obj = null;
-
- public BytesToJavaObj(String hexObjStr) {
- this.hexObjStr = hexObjStr;
- }
-
- public String run() {
- byte[] bytes = hexStrToByteArray(this.hexObjStr);
- this.obj = byteArrayToObject(bytes);
- if (this.obj != null) {
- return this.obj.getClass().getName() + ":" + this.obj.toString();
- }
- return "<null>";
- }
-
- protected Serializable byteArrayToObject(byte[] bytes) {
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInput in = null;
- try {
- in = new ObjectInputStream(bis);
- return (Serializable) in.readObject();
- } catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- } catch (IOException e) {
- e.printStackTrace(System.out);
- } finally {
- try {
- bis.close();
- } catch (IOException e) {} // ignore
- try {
- in.close();
- } catch (IOException e) {} // ignore
- }
- return null;
- }
-
- protected byte[] hexStrToByteArray(String hexStr) {
- int len = hexStr.length();
- byte[] data = new byte[len / 2];
- for(int i=0; i<len; i+=2) {
- data[i/2] = (byte)((Character.digit(hexStr.charAt(i), 16) << 4) + Character.digit(hexStr.charAt(i+1), 16));
- }
- return data;
- }
-
+ String hexObjStr = null;
+ Serializable obj = null;
+
+ public BytesToJavaObj(String hexObjStr) {
+ this.hexObjStr = hexObjStr;
+ }
+
+ public String run() {
+ byte[] bytes = hexStrToByteArray(this.hexObjStr);
+ this.obj = byteArrayToObject(bytes);
+ if (this.obj != null) {
+ return this.obj.getClass().getName() + ":" + this.obj.toString();
+ }
+ return "<null>";
+ }
+
+ protected Serializable byteArrayToObject(byte[] bytes) {
+ ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
+ ObjectInput in = null;
+ try {
+ in = new ObjectInputStream(bis);
+ return (Serializable) in.readObject();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ } finally {
+ try {
+ bis.close();
+ } catch (IOException e) {} // ignore
+ try {
+ in.close();
+ } catch (IOException e) {} // ignore
+ }
+ return null;
+ }
+
+ protected byte[] hexStrToByteArray(String hexStr) {
+ int len = hexStr.length();
+ byte[] data = new byte[len / 2];
+ for(int i=0; i<len; i+=2) {
+ data[i/2] = (byte)((Character.digit(hexStr.charAt(i), 16) << 4) + Character.digit(hexStr.charAt(i+1), 16));
+ }
+ return data;
+ }
+
// ========= main ==========
-
+
public static void main(String[] args) {
- if (args.length != 1) {
- System.out.println("BytesToJavaObj: Incorrect argument count");
- System.out.println("BytesToJavaObj: Expected argument: \"<java_serialized_obj_str_hex>\"");
- System.exit(1);
- }
- BytesToJavaObj btjo = new BytesToJavaObj(args[0]);
- System.out.println(btjo.run());
- }
+ if (args.length != 1) {
+ System.out.println("BytesToJavaObj: Incorrect argument count");
+ System.out.println("BytesToJavaObj: Expected argument: \"<java_serialized_obj_str_hex>\"");
+ System.exit(1);
+ }
+ BytesToJavaObj btjo = new BytesToJavaObj(args[0]);
+ System.out.println(btjo.run());
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/36c7b3be/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
index 2bfbde0..a16f0b1 100644
--- a/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
+++ b/utils/src/main/java/org/apache/qpid/qpid_interop_test/obj_util/JavaObjToBytes.java
@@ -26,104 +26,104 @@ import java.lang.reflect.InvocationTargetException;
//import java.util.Arrays;
public class JavaObjToBytes {
- String javaClassName = null;
- String ctorArgStr = null;
- Serializable obj = null;
-
- public JavaObjToBytes(String javaClassName, String ctorArgStr) {
- this.javaClassName = javaClassName;
- this.ctorArgStr = ctorArgStr;
- }
-
- public byte[] run() {
- createJavaObject();
- return serializeJavaOjbect();
- }
-
+ String javaClassName = null;
+ String ctorArgStr = null;
+ Serializable obj = null;
+
+ public JavaObjToBytes(String javaClassName, String ctorArgStr) {
+ this.javaClassName = javaClassName;
+ this.ctorArgStr = ctorArgStr;
+ }
+
+ public byte[] run() {
+ createJavaObject();
+ return serializeJavaOjbect();
+ }
+
protected void createJavaObject() {
- try {
- Class<?> c = Class.forName(this.javaClassName);
- if (this.javaClassName.compareTo("java.lang.Character") == 0) {
- Constructor ctor = c.getConstructor(char.class);
- if (this.ctorArgStr.length() == 1) {
- // Use first character of string
- obj = (Serializable)ctor.newInstance(this.ctorArgStr.charAt(0));
- } else if (this.ctorArgStr.length() == 4 || this.ctorArgStr.length() == 6) {
- // Format '\xNN' or '\xNNNN'
- obj = (Serializable)ctor.newInstance((char)Integer.parseInt(this.ctorArgStr.substring(2), 16));
- } else {
- throw new Exception("JavaObjToBytes.createJavaObject() Malformed char string: \"" + this.ctorArgStr + "\"");
- }
- } else {
- // Use string constructor
- Constructor ctor = c.getConstructor(String.class);
- obj = (Serializable)ctor.newInstance(this.ctorArgStr);
- }
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace(System.out);
- }
- catch (NoSuchMethodException e) {
- e.printStackTrace(System.out);
- }
- catch (InstantiationException e) {
- e.printStackTrace(System.out);
- }
- catch (IllegalAccessException e) {
- e.printStackTrace(System.out);
- }
- catch (InvocationTargetException e) {
- e.printStackTrace(System.out);
- }
- catch (Exception e) {
- e.printStackTrace(System.out);
- }
+ try {
+ Class<?> c = Class.forName(this.javaClassName);
+ if (this.javaClassName.compareTo("java.lang.Character") == 0) {
+ Constructor ctor = c.getConstructor(char.class);
+ if (this.ctorArgStr.length() == 1) {
+ // Use first character of string
+ obj = (Serializable)ctor.newInstance(this.ctorArgStr.charAt(0));
+ } else if (this.ctorArgStr.length() == 4 || this.ctorArgStr.length() == 6) {
+ // Format '\xNN' or '\xNNNN'
+ obj = (Serializable)ctor.newInstance((char)Integer.parseInt(this.ctorArgStr.substring(2), 16));
+ } else {
+ throw new Exception("JavaObjToBytes.createJavaObject() Malformed char string: \"" + this.ctorArgStr + "\"");
+ }
+ } else {
+ // Use string constructor
+ Constructor ctor = c.getConstructor(String.class);
+ obj = (Serializable)ctor.newInstance(this.ctorArgStr);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (NoSuchMethodException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InstantiationException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalAccessException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (InvocationTargetException e) {
+ e.printStackTrace(System.out);
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
}
-
+
protected byte[] serializeJavaOjbect() {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(this.obj);
- return bos.toByteArray();
- } catch (IOException e) {
- e.printStackTrace(System.out);
- } finally {
- try {
- if (out != null) {
- out.close();
- }
- } catch (IOException e) {} // ignore
- try {
- bos.close();
- } catch (IOException e) {} // ignore
- }
- return null;
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(this.obj);
+ return bos.toByteArray();
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {} // ignore
+ try {
+ bos.close();
+ } catch (IOException e) {} // ignore
+ }
+ return null;
}
-
+
// ========= main ==========
-
+
public static void main(String[] args) {
- if (args.length != 1) {
- System.out.println("JavaObjToBytes: Incorrect argument count");
- System.out.println("JavaObjToBytes: Expected argument: \"<java_class_name>:<ctor_arg_str>\"");
- System.exit(1);
- }
- int colonIndex = args[0].indexOf(":");
- if (colonIndex < 0) {
- System.out.println("Error: Incorect argument format: " + args[0]);
- System.exit(-1);
- }
- String javaClassName = args[0].substring(0, colonIndex);
- String ctorArgStr = args[0].substring(colonIndex+1);
- JavaObjToBytes jotb = new JavaObjToBytes(javaClassName, ctorArgStr);
- byte[] bytes = jotb.run();
- System.out.println(args[0]);
- for (byte b: bytes) {
- System.out.print(String.format("%02x", b));
- }
- System.out.println();
+ if (args.length != 1) {
+ System.out.println("JavaObjToBytes: Incorrect argument count");
+ System.out.println("JavaObjToBytes: Expected argument: \"<java_class_name>:<ctor_arg_str>\"");
+ System.exit(1);
+ }
+ int colonIndex = args[0].indexOf(":");
+ if (colonIndex < 0) {
+ System.out.println("Error: Incorect argument format: " + args[0]);
+ System.exit(-1);
+ }
+ String javaClassName = args[0].substring(0, colonIndex);
+ String ctorArgStr = args[0].substring(colonIndex+1);
+ JavaObjToBytes jotb = new JavaObjToBytes(javaClassName, ctorArgStr);
+ byte[] bytes = jotb.run();
+ System.out.println(args[0]);
+ for (byte b: bytes) {
+ System.out.print(String.format("%02x", b));
+ }
+ System.out.println();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/7] qpid-interop-test git commit: QPIDIT-32: Added Maven pom files,
removed jars directory containing copies of dependent jars. Also
updated to latest Proton C++ API
Posted by kp...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/jms/jms_message_tests.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/jms/jms_message_tests.py b/src/py/qpid-interop-test/jms/jms_message_tests.py
deleted file mode 100755
index 44480f9..0000000
--- a/src/py/qpid-interop-test/jms/jms_message_tests.py
+++ /dev/null
@@ -1,481 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Module to test JMS message types across different APIs
-"""
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-#
-
-import argparse
-import unittest
-
-from itertools import product
-from json import dumps, loads
-from os import getenv, path
-from subprocess import check_output, CalledProcessError
-from sys import exit
-
-from proton import symbol
-from test_type_map import TestTypeMap
-import broker_properties
-
-
-# TODO - propose a sensible default when installation details are worked out
-QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME')
-
-class JmsMessageTypes(TestTypeMap):
- """
- Class which contains all the described JMS message types and the test values to be used in testing.
- """
-
- # The TYPE_SUBMAP defines test values for JMS message types that allow typed message content. Note that the
- # types defined here are understood to be *Java* types and the stringified values are to be interpreted
- # as the appropriate Java type by the send shim.
- TYPE_SUBMAP = {
- 'boolean': ['True',
- 'False'],
- 'byte': ['-0x80',
- '-0x1',
- '0x0',
- '0x7f'],
- 'bytes': [b'',
- b'12345',
- b'Hello, world',
- b'\\x01\\x02\\x03\\x04\\x05abcde\\x80\\x81\\xfe\\xff',
- b'The quick brown fox jumped over the lazy dog 0123456789.' * 100],
- 'char': ['a',
- 'Z',
- '\x01',
- '\x7f'],
- 'double': ['0x0000000000000000', # 0.0
- '0x8000000000000000', # -0.0
- '0x400921fb54442eea', # pi (3.14159265359) positive decimal
- '0xc005bf0a8b145fcf', # -e (-2.71828182846) negative decimal
- '0x0000000000000001', # Smallest positive denormalized number
- '0x8000000000000001', # Smallest negative denormalized number
- '0x000fffffffffffff', # Largest positive denormalized number
- '0x8010000000000000', # Largest negative denormalized number
- '0x7fefffffffffffff', # Largest positive normalized number
- '0xffefffffffffffff', # Largest negative normalized number
- '0x7ff0000000000000', # +Infinity
- '0xfff0000000000000', # -Infinity
- '0x7ff8000000000000'], # +NaN
- 'float': ['0x00000000', # 0.0
- '0x80000000', # -0.0
- '0x40490fdb', # pi (3.14159265359) positive decimal
- '0xc02df854', # -e (-2.71828182846) negative decimal
- '0x00000001', # Smallest positive denormalized number
- '0x80000001', # Smallest negative denormalized number
- '0x007fffff', # Largest positive denormalized number
- '0x807fffff', # Largest negative denormalized number
- '0x00800000', # Smallest positive normalized number
- '0x80800000', # Smallest negative normalized number
- '0x7f7fffff', # Largest positive normalized number
- '0xff7fffff', # Largest negative normalized number
- #'0x7f800000', # +Infinity # PROTON-1149 - fails on RHEL7
- #'0xff800000', # -Infinity # PROTON-1149 - fails on RHEL7
- '0x7fc00000'], # +NaN
- 'int': ['-0x80000000',
- '-0x81',
- '-0x80',
- '-0x1',
- '0x0',
- '0x7f',
- '0x80',
- '0x7fffffff'],
- 'long': ['-0x8000000000000000',
- '-0x81',
- '-0x80',
- '-0x1',
- '0x0',
- '0x7f',
- '0x80',
- '0x7fffffffffffffff'],
- 'short': ['-0x8000',
- '-0x1',
- '0x0',
- '0x7fff'],
- 'string': ['',
- 'Hello, world',
- '"Hello, world"',
- "Charlie's \"peach\"",
- 'Charlie\'s "peach"',
- 'The quick brown fox jumped over the lazy dog 0123456789.' * 100]
- }
-
- TYPE_MAP = {
- 'JMS_BYTESMESSAGE_TYPE': TYPE_SUBMAP,
- 'JMS_MAPMESSAGE_TYPE': TYPE_SUBMAP,
-# 'JMS_OBJECTMESSAGE_TYPE': {
-# 'java.lang.Boolean': ['true',
-# 'false'],
-# 'java.lang.Byte': ['-128',
-# '0',
-# '127'],
-# 'java.lang.Character': [u'a',
-# u'Z'],
-# 'java.lang.Double': ['0.0',
-# '3.141592654',
-# '-2.71828182846'],
-# 'java.lang.Float': ['0.0',
-# '3.14159',
-# '-2.71828'],
-# 'java.lang.Integer': ['-2147483648',
-# '-129',
-# '-128',
-# '-1',
-# '0',
-# '127',
-# '128',
-# '2147483647'],
-# 'java.lang.Long' : ['-9223372036854775808',
-# '-129',
-# '-128',
-# '-1',
-# '0',
-# '127',
-# '128',
-# '9223372036854775807'],
-# 'java.lang.Short': ['-32768',
-# '-129',
-# '-128',
-# '-1',
-# '0',
-# '127',
-# '128',
-# '32767'],
-# 'java.lang.String': [u'',
-# u'Hello, world',
-# u'"Hello, world"',
-# u"Charlie's \"peach\"",
-# u'Charlie\'s "peach"']
-# },
- 'JMS_STREAMMESSAGE_TYPE': TYPE_SUBMAP,
- 'JMS_TEXTMESSAGE_TYPE': {'text': ['',
- 'Hello, world',
- '"Hello, world"',
- "Charlie's \"peach\"",
- 'Charlie\'s "peach"',
- 'The quick brown fox jumped over the lazy dog 0123456789.' * 100]}
- }
-
- BROKER_SKIP = {}
-
-
-class JmsMessageTypeTestCase(unittest.TestCase):
- """
- Abstract base class for JMS message type test cases
- """
-
- def run_test(self, broker_addr, jms_message_type, test_values, send_shim, receive_shim):
- """
- Run this test by invoking the shim send method to send the test values, followed by the shim receive method
- to receive the values. Finally, compare the sent values with the received values.
- """
- if len(test_values) > 0:
- queue_name = 'jms.queue.qpid-interop.jms_message_type_tests.%s.%s.%s' % (jms_message_type, send_shim.NAME,
- receive_shim.NAME)
- send_error_text = send_shim.send(broker_addr, queue_name, jms_message_type, dumps(test_values))
- if len(send_error_text) > 0:
- self.fail('Send shim \'%s\':\n%s' % (send_shim.NAME, send_error_text))
- num_test_values = {}
- for index in test_values.keys():
- num_test_values[index] = len(test_values[index])
- receive_text = receive_shim.receive(broker_addr, queue_name, jms_message_type, dumps(num_test_values))
- if isinstance(receive_text, str):
- self.fail(receive_text)
- else:
- self.assertEqual(receive_text, test_values, msg='\n sent:%s\n\n received:%s' % \
- (test_values, receive_text))
- else:
- self.fail('Type %s has no test values' % jms_message_type)
-
-
-def create_testcase_class(broker_name, types, broker_addr, jms_message_type, shim_product):
- """
- Class factory function which creates new subclasses to JmsMessageTypeTestCase.
- """
-
- def __repr__(self):
- """Print the class name"""
- return self.__class__.__name__
-
- def add_test_method(cls, send_shim, receive_shim):
- """Function which creates a new test method in class cls"""
-
- @unittest.skipIf(types.skip_test(jms_message_type, broker_name),
- types.skip_test_message(jms_message_type, broker_name))
- def inner_test_method(self):
- self.run_test(self.broker_addr, self.jms_message_type, self.test_values, send_shim, receive_shim)
-
- inner_test_method.__name__ = 'test_%s_%s->%s' % (jms_message_type[4:-5], send_shim.NAME, receive_shim.NAME)
- setattr(cls, inner_test_method.__name__, inner_test_method)
-
- class_name = jms_message_type[4:-5].title() + 'TestCase'
- class_dict = {'__name__': class_name,
- '__repr__': __repr__,
- '__doc__': 'Test case for JMS message type \'%s\'' % jms_message_type,
- 'jms_message_type': jms_message_type,
- 'broker_addr': broker_addr,
- 'test_values': types.get_test_values(jms_message_type)}
- new_class = type(class_name, (JmsMessageTypeTestCase,), class_dict)
- for send_shim, receive_shim in shim_product:
- add_test_method(new_class, send_shim, receive_shim)
- return new_class
-
-class Shim(object):
- """
- Abstract shim class, parent of all shims.
- """
- NAME = None
- USE_SHELL = False
-
- def __init__(self, args):
- self.ARGS = args
- self.SEND = None
- self.RECEIVE = None
-
-
- def send(self, broker_addr, queue_name, jms_message_type, json_test_values_str):
- """
- Send the values of type jms_message_type in json_test_values_str to queue queue_name.
- Return output (if any) from stdout.
- """
- arg_list = []
- arg_list.extend(self.SEND)
- arg_list.extend([broker_addr, queue_name, jms_message_type])
- arg_list.append(json_test_values_str)
-
- try:
- #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
- return check_output(arg_list, shell=self.USE_SHELL)
- except CalledProcessError as exc:
- return str(exc) + '\n\nOutput:\n' + exc.output
- except Exception as exc:
- return str(exc)
-
-
- def receive(self, broker_addr, queue_name, jms_message_type, json_test_num_values_str):
- """
- Receive json_test_num_values_str messages containing type jms_message_type from queue queue_name.
- If the first line returned from stdout is the AMQP type, then the rest is assumed to be the returned
- test value list. Otherwise error output is assumed.
- """
- output = ''
- try:
- arg_list = []
- arg_list.extend(self.RECEIVE)
- arg_list.extend([broker_addr, queue_name, jms_message_type, json_test_num_values_str])
- #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
- output = check_output(arg_list)
- #print '<<<', output # DEBUG- useful to see text received from shim
- str_tvl = output.split('\n')[:-1] # remove trailing \n
- if len(str_tvl) == 1:
- return output
- if len(str_tvl) == 2:
- return loads(str_tvl[1])
- else:
- return loads("".join(str_tvl[1:]))
- except CalledProcessError as exc:
- return str(exc) + '\n\n' + exc.output
- except Exception as exc:
- return str(exc)
-
-
-class ProtonPythonShim(Shim):
- """
- Shim for qpid-proton Python client
- """
- NAME = 'ProtonPython'
- SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src')
-
- def __init__(self, args):
- super(ProtonPythonShim, self).__init__(args)
- self.SEND = [path.join(self.SHIM_LOC, 'JmsSenderShim.py')]
- self.RECEIVE = [path.join(self.SHIM_LOC, 'JmsReceiverShim.py')]
-
-
-class ProtonCppShim(Shim):
- """
- Shim for qpid-proton Python client
- """
- NAME = 'ProtonCpp'
- SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'src')
-
- def __init__(self, args):
- super(ProtonCppShim, self).__init__(args)
- self.SEND = [path.join(self.SHIM_LOC, 'JmsSender')]
- self.RECEIVE = [path.join(self.SHIM_LOC, 'JmsReceiver')]
-
-
-class QpidJmsShim(Shim):
- """
- Shim for qpid-jms JMS client
- """
- NAME = 'QpidJms'
-
- # Classpath components
- QPID_INTEROP_TEST_SHIM_JAR = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'target', 'qpid-jms-shim.jar')
- MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository'))
- JMS_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'geronimo', 'specs', 'geronimo-jms_1.1_spec', '1.1.1',
- 'geronimo-jms_1.1_spec-1.1.1.jar')
- JSON_API_JAR = path.join(QPID_INTEROP_TEST_HOME, 'jars', 'javax.json-api-1.0.jar')
- JSON_IMPL_JAR = path.join(QPID_INTEROP_TEST_HOME, 'jars', 'javax.json-1.0.4.jar')
- LOGGER_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'slf4j', 'slf4j-api', '1.5.6', 'slf4j-api-1.5.6.jar')
- LOGGER_IMPL_JAR = path.join(QPID_INTEROP_TEST_HOME, 'jars', 'slf4j-nop-1.5.6.jar')
- NETTY_JAR = path.join(MAVEN_REPO_PATH, 'io', 'netty', 'netty-all', '4.0.17.Final', 'netty-all-4.0.17.Final.jar')
-
- JAVA_HOME = getenv('JAVA_HOME', '/usr/lib/jvm/java') # Default only works in Linux
- JAVA_EXEC = path.join(JAVA_HOME, 'bin/java')
-
- def __init__(self, args):
- super(QpidJmsShim, self).__init__(args)
- # Installed qpid versions
- self.QPID_JMS_VER = self.ARGS.qpid_jms_ver
- self.QPID_PROTON_J_VER = self.ARGS.qpid_proton_ver
- self.JMS_IMPL_JAR = path.join(self.MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'qpid-jms-client',
- self.QPID_JMS_VER, 'qpid-jms-client-' + self.QPID_JMS_VER + '.jar')
- self.PROTON_J_JAR = path.join(self.MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'proton-j', self.QPID_PROTON_J_VER,
- 'proton-j-' + self.QPID_PROTON_J_VER + '.jar')
- self.JAR_LIST = [self.QPID_INTEROP_TEST_SHIM_JAR,
- self.JMS_API_JAR,
- self.JMS_IMPL_JAR,
- self.JSON_API_JAR,
- self.JSON_IMPL_JAR,
- self.LOGGER_API_JAR,
- self.LOGGER_IMPL_JAR,
- self.PROTON_J_JAR,
- self.NETTY_JAR]
- for jar in self.JAR_LIST:
- if not self.jarExists(jar):
- print '*** ERROR: Cannot find jar file "%s"' % jar
- self.CLASSPATH = ':'.join(self.JAR_LIST)
-
- self.SEND = [self.JAVA_EXEC, '-cp', self.CLASSPATH, 'org.apache.qpid.interop_test.shim.JmsSenderShim']
- self.RECEIVE = [self.JAVA_EXEC, '-cp', self.CLASSPATH, 'org.apache.qpid.interop_test.shim.JmsReceiverShim']
-
- def jarExists(self, jarPath):
- try:
- f = open(jarPath, 'rb')
- f.close()
- return True
- except IOError as e:
- pass
- return False
-
-
-# TODO: Complete the test options to give fine control over running tests
-class TestOptions(object):
- """
- Class controlling command-line arguments used to control the test.
- """
- def __init__(self, shims):
- parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite '
- 'for JMS message types')
- parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT',
- help='Broker against which to run test suite.')
-# test_group = parser.add_mutually_exclusive_group()
-# test_group.add_argument('--include-test', action='append', metavar='TEST-NAME',
-# help='Name of test to include')
-# test_group.add_argument('--exclude-test', action='append', metavar='TEST-NAME',
-# help='Name of test to exclude')
-# type_group = test_group.add_mutually_exclusive_group()
-# type_group.add_argument('--include-type', action='append', metavar='AMQP-TYPE',
-# help='Name of AMQP type to include. Supported types:\n%s' %
-# sorted(JmsMessageTypes.TYPE_MAP.keys()))
- parser.add_argument('--exclude-type', action='append', metavar='JMS-MESSAGE-TYPE',
- help='Name of JMS message type to exclude. Supported types:\n%s' %
- sorted(JmsMessageTypes.TYPE_MAP.keys()))
-# shim_group = test_group.add_mutually_exclusive_group()
-# shim_group.add_argument('--include-shim', action='append', metavar='SHIM-NAME',
-# help='Name of shim to include. Supported shims:\n%s' % SHIM_NAMES)
- parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME',
- help='Name of shim to exclude. Supported shims:\n%s' % sorted(shims))
- parser.add_argument('--qpid-jms-ver', action='store', required=True,
- help='qpid-jms version in Maven repository to use for test')
- parser.add_argument('--qpid-proton-ver', action='store',required=True,
- help='qpid-proton version in Maven repository to use for test')
- self.args = parser.parse_args()
-
-
-#--- Main program start ---
-
-if __name__ == '__main__':
-
- SHIMS = [ProtonCppShim.NAME, QpidJmsShim.NAME, ProtonPythonShim.NAME]
-
- ARGS = TestOptions(SHIMS).args
- #print 'ARGS:', ARGS # debug
-
- # SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For
- # every shim in this list, a test is dynamically constructed which tests it against itself as well as every
- # other shim in the list.
- #
- # As new shims are added, add them into this map to have them included in the test cases.
- #SHIM_MAP = {ProtonPythonShim.NAME: ProtonPythonShim()}
- #SHIM_MAP = {QpidJmsShim.NAME: QpidJmsShim()}
- #SHIM_MAP = {ProtonPythonShim.NAME: ProtonPythonShim(), QpidJmsShim.NAME: QpidJmsShim()}
- SHIM_MAP = {ProtonCppShim.NAME: ProtonCppShim(ARGS),
- QpidJmsShim.NAME: QpidJmsShim(ARGS),
- ProtonPythonShim.NAME: ProtonPythonShim(ARGS)}
- #SHIM_MAP = {ProtonCppShim.NAME: ProtonCppShim()}
-
- # Connect to broker to find broker type
- CONNECTION_PROPS = broker_properties.getBrokerProperties(ARGS.broker)
- if CONNECTION_PROPS is None:
- print 'WARNING: Unable to get connection properties - unknown broker'
- BROKER = 'unknown'
- else:
- print 'Test Broker: %s v.%s on %s' % (CONNECTION_PROPS[symbol(u'product')],
- CONNECTION_PROPS[symbol(u'version')],
- CONNECTION_PROPS[symbol(u'platform')])
- print
- BROKER = CONNECTION_PROPS[symbol(u'product')]
-
- TYPES = JmsMessageTypes()
-
- # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed
- # per AMQP type used as the key in map JmsMessageTypes.TYPE_MAP.
- TEST_CASE_CLASSES = []
-
- # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created
- # type classes, each of which contains a test for the combinations of client shims
- TEST_SUITE = unittest.TestSuite()
-
- # Remove shims excluded from the command-line
- if ARGS.exclude_shim is not None:
- for shim in ARGS.exclude_shim:
- SHIM_MAP.pop(shim)
- # Create test classes dynamically
- for jmt in sorted(TYPES.get_type_list()):
- if ARGS.exclude_type is None or jmt not in ARGS.exclude_type:
- test_case_class = create_testcase_class(BROKER,
- TYPES,
- ARGS.broker,
- jmt,
- product(SHIM_MAP.values(), repeat=2))
- TEST_CASE_CLASSES.append(test_case_class)
- TEST_SUITE.addTest(unittest.makeSuite(test_case_class))
-
- # Finally, run all the dynamically created tests
- res = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE)
- if not res.wasSuccessful():
- exit(1)
-
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/test_type_map.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/test_type_map.py b/src/py/qpid-interop-test/test_type_map.py
deleted file mode 100644
index 0a5b1fb..0000000
--- a/src/py/qpid-interop-test/test_type_map.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""
-Module containing Error classes for interop testing
-"""
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-#
-
-class TestTypeMap(object):
- """
- Class which contains all the described types and the test values to be used in testing against those types.
- """
-
- # TYPE_MAP: Map containing all described types as the indecies, and a list of values to be used in testing
- # that type as a list of values.
- #
- # Format: {'type_1' : [val_1_1, val_1_2, ...],
- # 'type_2' : [val_2_1, val_2_2, ...],
- # ...
- # }
- TYPE_MAP = {}
-
- # BROKER_SKIP: For know broker issues where a type would cause a test to fail or hang,
- # entries in BROKER_SKIP will cause the test to be skipped with a message.
- # This is a map containing AMQP types as a key, and a list of brokers for which this
- # type should be skipped.
- # Format: {'jms_msg_type_1' : {'broker_1' : 'skip msg for broker_1',
- # 'broker_2' : 'skip msg for broker_2',
- # ...
- # },
- # 'jms_msg_type_2' : {'broker_1' : 'skip msg for broker_1',
- # 'broker_2' : 'skip msg for broker_2',
- # ...
- # },
- # ...
- # }
- # where broker_1, broker_2, ... are broker product names as defined by the
- # connection property string it returns.
- BROKER_SKIP = {}
-
- def __init__(self):
- pass
-
- def get_type_list(self):
- """Return a list of types which this test suite supports"""
- return self.TYPE_MAP.keys()
-
- def get_test_values(self, test_type):
- """Return test values to use when testing the supplied type."""
- if test_type not in self.TYPE_MAP.keys():
- return None
- return self.TYPE_MAP[test_type]
-
- def skip_test_message(self, test_type, broker_name):
- """Return the message to use if a test is skipped"""
- if test_type in self.BROKER_SKIP.keys():
- if broker_name in self.BROKER_SKIP[test_type]:
- return str(self.BROKER_SKIP[test_type][broker_name])
- return None
-
- def skip_test(self, test_type, broker_name):
- """Return boolean True if test should be skipped"""
- return test_type in self.BROKER_SKIP.keys() and \
- broker_name in self.BROKER_SKIP[test_type]
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/py/qpid-interop-test/types/simple_type_tests.py
----------------------------------------------------------------------
diff --git a/src/py/qpid-interop-test/types/simple_type_tests.py b/src/py/qpid-interop-test/types/simple_type_tests.py
deleted file mode 100755
index 78551eb..0000000
--- a/src/py/qpid-interop-test/types/simple_type_tests.py
+++ /dev/null
@@ -1,478 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Module to test AMQP primitive types across different APIs
-"""
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-#
-
-import argparse
-import unittest
-
-from itertools import product
-from json import dumps, loads
-from os import getenv, path
-from subprocess import check_output, CalledProcessError
-from sys import exit
-from time import mktime, time
-from uuid import UUID, uuid4
-
-from proton import int32, symbol, timestamp, ulong
-from test_type_map import TestTypeMap
-import broker_properties
-
-
-# TODO - propose a sensible default when installation details are worked out
-QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME')
-
-
-class AmqpPrimitiveTypes(TestTypeMap):
- """
- Class which contains all the described AMQP primitive types and the test values to be used in testing.
- """
-
- TYPE_MAP = {
- 'null': ['None'],
- 'boolean': ['True',
- 'False'],
- 'ubyte': ['0x0',
- '0x7f',
- '0x80',
- '0xff'],
- 'ushort': ['0x0',
- '0x7fff',
- '0x8000',
- '0xffff'],
- 'uint': ['0x0',
- '0x7fffffff',
- '0x80000000',
- '0xffffffff'],
- 'ulong': ['0x0',
- '0x1',
- '0xff',
- '0x100',
- '0x7fffffffffffffff',
- '0x8000000000000000',
- '0xffffffffffffffff'],
- 'byte': ['-0x80',
- '-0x1',
- '0x0',
- '0x7f'],
- 'short': ['-0x8000',
- '-0x1',
- '0x0',
- '0x7fff'],
- 'int': ['-0x80000000',
- '-0x1',
- '0x0',
- '0x7fffffff'],
- 'long': ['-0x8000000000000000',
- '-0x81',
- '-0x80',
- '-0x1',
- '0x0',
- '0x7f',
- '0x80',
- '0x7fffffffffffffff'],
- # float and double: Because of difficulty with rounding of floating point numbers, we use the binary
- # representation instead which should be exact when comparing sent and received values.
- 'float': ['0x00000000', # 0.0
- '0x80000000', # -0.0
- '0x40490fdb', # pi (3.14159265359) positive decimal
- '0xc02df854', # -e (-2.71828182846) negative decimal
- '0x00000001', # Smallest positive denormalized number
- '0x80000001', # Smallest negative denormalized number
- '0x007fffff', # Largest positive denormalized number
- '0x807fffff', # Largest negative denormalized number
- '0x00800000', # Smallest positive normalized number
- '0x80800000', # Smallest negative normalized number
- '0x7f7fffff', # Largest positive normalized number
- '0xff7fffff', # Largest negative normalized number
- #'0x7f800000', # +Infinity # PROTON-1149 - fails on RHEL7
- #'0xff800000', # -Infinity # PROTON-1149 - fails on RHEL7
- '0x7fc00000', # +NaN
- '0xffc00000'], # -NaN
- 'double': ['0x0000000000000000', # 0.0
- '0x8000000000000000', # -0.0
- '0x400921fb54442eea', # pi (3.14159265359) positive decimal
- '0xc005bf0a8b145fcf', # -e (-2.71828182846) negative decimal
- '0x0000000000000001', # Smallest positive denormalized number
- '0x8000000000000001', # Smallest negative denormalized number
- '0x000fffffffffffff', # Largest positive denormalized number
- '0x800fffffffffffff', # Largest negative denormalized number
- '0x0010000000000000', # Smallest positive normalized number
- '0x8010000000000000', # Smallest negative normalized number
- '0x7fefffffffffffff', # Largest positive normalized number
- '0xffefffffffffffff', # Largest negative normalized number
- '0x7ff0000000000000', # +Infinity
- '0xfff0000000000000', # -Infinity
- '0x7ff8000000000000', # +NaN
- '0xfff8000000000000'], # -NaN
- # decimal32, decimal64, decimal128:
- # Until more formal support for decimal32, decimal64 and decimal128 are included in Python, we use
- # a hex format for basic tests, and treat the data as a binary blob.
- 'decimal32': ['0x00000000',
- '0x40490fdb',
- '0xc02df854',
- '0xff7fffff'],
- 'decimal64': ['0x0000000000000000',
- '0x400921fb54442eea',
- '0xc005bf0a8b145fcf',
- '0xffefffffffffffff'],
- 'decimal128': ['0x00000000000000000000000000000000',
- '0xff0102030405060708090a0b0c0d0e0f'],
- 'char': [u'a',
- u'Z',
- u'0x1',
- u'0x7f',
- u'0x16b5', # Rune 'G'
- u'0x10ffff'],
- # timestamp: Must be in milliseconds since the Unix epoch
- 'timestamp': ['0x0',
- '0x%x' % int(mktime((2000, 1, 1, 0, 0, 0, 5, 1, 0))*1000),
- '0x%x' % int(time()*1000)
- ],
- 'uuid': [str(UUID(int=0x0)),
- str(UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')),
- str(uuid4())],
- 'binary': [bytes(),
- bytes(12345),
- b'Hello, world!',
- b'\\x01\\x02\\x03\\x04\\x05abcde\\x80\\x81\\xfe\\xff',
- b'The quick brown fox jumped over the lazy dog 0123456789.' * 100
- ],
- # strings must be unicode to comply with AMQP spec
- 'string': [u'',
- u'Hello, world!',
- u'"Hello, world!"',
- u"Charlie's peach",
- u'The quick brown fox jumped over the lazy dog 0123456789.' * 100
- ],
- 'symbol': ['',
- 'myDomain.123',
- 'domain.0123456789.' * 100],
- 'list': [[],
- ['ubyte:1', 'int:-2', 'float:3.14'],
- ['string:a', 'string:b', 'string:c'],
- ['ulong:12345', 'timestamp:%d' % (time()*1000), 'short:-2500', 'uuid:%s' % uuid4(), 'symbol:a.b.c', 'none:', 'decimal64:0x400921fb54442eea'],
- [[], 'none', ['ubyte:1', 'ubyte:2', 'ubyte:3'], 'boolean:True', 'boolean:False', {'string:hello': 'long:1234', 'string:goodbye': 'boolean:True'}],
- [[], [[], [[], [], []], []], []],
- ['short:0', 'short:1', 'short:2', 'short:3', 'short:4', 'short:5', 'short:6', 'short:7', 'short:8', 'short:9'] * 100
- ],
- 'map': [{},
- {'string:one': 'ubyte:1',
- 'string:two': 'ushort:2'},
- {'none:': 'string:None',
- 'string:None': 'none:',
- 'string:One': 'long:-1234567890',
- 'short:2': 'int:2',
- 'boolean:True': 'string:True',
- 'string:False': 'boolean:False',
- #['string:AAA', 'ushort:5951']: 'string:list value',
- #{'byte:-55': 'ubyte:200',
- # 'boolean:True': 'string:Hello, world!'}: 'symbol:map.value',
- #'string:list': [],
- 'string:map': {'char:A': 'int:1',
- 'char:B': 'int:2'}},
- ],
- # TODO: Support all AMQP types in array (including keys)
-# 'array': [[],
-# [1, 2, 3],
-# ['Hello', 'world'],
-# [[1, 2, 3],
-# ['a', 'b', 'c'],
-# [2.3, 3.4, 4,5],
-# [True, False, True, True]]
-# ]
- }
-
- BROKER_SKIP = {'null': {'ActiveMQ': 'Null type not sent in Proton Python binding: PROTON-1091',
- 'qpid-cpp': 'Null type not sent in Proton Python binding: PROTON-1091',},
- 'decimal32': {'ActiveMQ': 'decimal32 and decimal64 are sent byte reversed: PROTON-1160',
- 'qpid-cpp': 'decimal32 not supported on qpid-cpp broker: QPIDIT-5, QPID-6328',},
- 'decimal64': {'ActiveMQ': 'decimal32 and decimal64 are sent byte reversed: PROTON-1160',
- 'qpid-cpp': 'decimal64 not supported on qpid-cpp broker: QPIDIT-6, QPID-6328',},
- 'decimal128': {'qpid-cpp': 'decimal128 not supported on qpid-cpp broker: QPIDIT-3, QPID-6328',},
- 'char': {'qpid-cpp': 'char not supported on qpid-cpp broker: QPIDIT-4, QPID-6328',},
- }
-# BROKER_SKIP = {}
-
-
-class AmqpTypeTestCase(unittest.TestCase):
- """
- Abstract base class for AMQP Type test cases
- """
-
- def run_test(self, broker_addr, amqp_type, test_value_list, send_shim, receive_shim):
- """
- Run this test by invoking the shim send method to send the test values, followed by the shim receive method
- to receive the values. Finally, compare the sent values with the received values.
- """
- if len(test_value_list) > 0:
- # TODO: When Artemis can support it (in the next release), revert the queue name back to 'qpid-interop...'
- # Currently, Artemis only supports auto-create queues for JMS, and the queue name must be prefixed by 'jms.queue.'
- #queue_name = 'qpid-interop.simple_type_tests.%s.%s.%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
- queue_name = 'jms.queue.qpid-interop.simple_type_tests.%s.%s.%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
- send_error_text = send_shim.send(broker_addr, queue_name, amqp_type, dumps(test_value_list))
- if len(send_error_text) > 0:
- self.fail('Send shim \'%s\':\n%s' % (send_shim.NAME, send_error_text))
- receive_text = receive_shim.receive(broker_addr, queue_name, amqp_type, len(test_value_list))
- if isinstance(receive_text, list):
- self.assertEqual(receive_text, test_value_list, msg='\n sent:%s\nreceived:%s' % \
- (test_value_list, receive_text))
- else:
- self.fail(receive_text)
- else:
- self.fail('Type %s has no test values' % amqp_type)
-
-
-def create_testcase_class(broker_name, types, broker_addr, amqp_type, shim_product):
- """
- Class factory function which creates new subclasses to AmqpTypeTestCase.
- """
-
- def __repr__(self):
- """Print the class name"""
- return self.__class__.__name__
-
- def add_test_method(cls, send_shim, receive_shim):
- """Function which creates a new test method in class cls"""
-
- @unittest.skipIf(types.skip_test(amqp_type, broker_name),
- types.skip_test_message(amqp_type, broker_name))
- def inner_test_method(self):
- self.run_test(self.broker_addr, self.amqp_type, self.test_value_list, send_shim, receive_shim)
-
- inner_test_method.__name__ = 'test_%s_%s->%s' % (amqp_type, send_shim.NAME, receive_shim.NAME)
- setattr(cls, inner_test_method.__name__, inner_test_method)
-
- class_name = amqp_type.title() + 'TestCase'
- class_dict = {'__name__': class_name,
- '__repr__': __repr__,
- '__doc__': 'Test case for AMQP 1.0 simple type \'%s\'' % amqp_type,
- 'amqp_type': amqp_type,
- 'broker_addr': broker_addr,
- 'test_value_list': types.get_test_values(amqp_type)}
- new_class = type(class_name, (AmqpTypeTestCase,), class_dict)
- for send_shim, receive_shim in shim_product:
- add_test_method(new_class, send_shim, receive_shim)
- return new_class
-
-
-class Shim(object):
- """
- Abstract shim class, parent of all shims.
- """
- NAME = None
- SEND = None
- RECEIVE = None
- USE_SHELL = False
-
- def send(self, broker_addr, queue_name, amqp_type, json_test_values_str):
- """
- Send the values of type amqp_type in test_value_list to queue queue_name. Return output (if any) from stdout.
- """
- arg_list = []
- arg_list.extend(self.SEND)
- arg_list.extend([broker_addr, queue_name, amqp_type])
- arg_list.append(json_test_values_str)
-
- try:
- #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
- return check_output(arg_list, shell=self.USE_SHELL)
- except CalledProcessError as exc:
- return str(exc) + '\n\nOutput:\n' + exc.output
- except Exception as exc:
- return str(exc)
-
-
- def receive(self, broker_addr, queue_name, amqp_type, num_test_values):
- """
- Receive num_test_values messages containing type amqp_type from queue queue_name. If the first line returned
- from stdout is the AMQP type, then the rest is assumed to be the returned test value list. Otherwise error
- output is assumed.
- """
- output = ''
- try:
- arg_list = []
- arg_list.extend(self.RECEIVE)
- arg_list.extend([broker_addr, queue_name, amqp_type, str(num_test_values)])
- #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
- output = check_output(arg_list)
- #print '<<<', output # DEBUG - useful to see text received from shim
- str_tvl = output.split('\n')[0:-1] # remove trailing \n
- if len(str_tvl) == 1:
- return output
- if len(str_tvl) == 2:
- return loads(str_tvl[1])
- else:
- return loads("".join(str_tvl[1:]))
- except CalledProcessError as exc:
- return str(exc) + '\n\n' + exc.output
- except Exception as exc:
- return str(exc)
-
-
-class ProtonPythonShim(Shim):
- """
- Shim for qpid-proton Python client
- """
- NAME = 'ProtonPython'
- SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src')
- SEND = [path.join(SHIM_LOC, 'TypesSenderShim.py')]
- RECEIVE = [path.join(SHIM_LOC, 'TypesReceiverShim.py')]
-
-
-class ProtonCppShim(Shim):
- """
- Shim for qpid-proton C++ client
- """
- NAME = 'ProtonCpp'
- SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'src')
- SEND = [path.join(SHIM_LOC, 'AmqpSender')]
- RECEIVE = [path.join(SHIM_LOC, 'AmqpReceiver')]
-
-
-class QpidJmsShim(Shim):
- """
- Shim for qpid-jms JMS client
- """
- NAME = 'QpidJms'
-
- # Installed qpid versions
- QPID_JMS_VER = '0.4.0-SNAPSHOT'
- QPID_PROTON_J_VER = '0.10-SNAPSHOT'
-
- # Classpath components
- QPID_INTEROP_TEST_SHIM_JAR = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'target', 'qpid-jms-shim.jar')
- MAVEN_REPO_PATH = path.join(getenv('HOME'), '.m2', 'repository')
- JMS_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'geronimo', 'specs', 'geronimo-jms_1.1_spec', '1.1.1',
- 'geronimo-jms_1.1_spec-1.1.1.jar')
- JMS_IMPL_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'qpid-jms-client', QPID_JMS_VER,
- 'qpid-jms-client-' + QPID_JMS_VER + '.jar')
- LOGGER_API_JAR = path.join(MAVEN_REPO_PATH, 'org', 'slf4j', 'slf4j-api', '1.5.6', 'slf4j-api-1.5.6.jar')
- LOGGER_IMPL_JAR = path.join(QPID_INTEROP_TEST_HOME, 'jars', 'slf4j-nop-1.5.6.jar')
- PROTON_J_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'proton-j', QPID_PROTON_J_VER,
- 'proton-j-' + QPID_PROTON_J_VER + '.jar')
- NETTY_JAR = path.join(MAVEN_REPO_PATH, 'io', 'netty', 'netty-all', '4.0.17.Final', 'netty-all-4.0.17.Final.jar')
-
- CLASSPATH = ':'.join([QPID_INTEROP_TEST_SHIM_JAR,
- JMS_API_JAR,
- JMS_IMPL_JAR,
- LOGGER_API_JAR,
- LOGGER_IMPL_JAR,
- PROTON_J_JAR,
- NETTY_JAR])
- JAVA_HOME = getenv('JAVA_HOME', '/usr/bin') # Default only works in Linux
- JAVA_EXEC = path.join(JAVA_HOME, 'java')
- SEND = [JAVA_EXEC, '-cp', CLASSPATH, 'org.apache.qpid.interop_test.shim.AmqpSender']
- RECEIVE = [JAVA_EXEC, '-cp', CLASSPATH, 'org.apache.qpid.interop_test.shim.AmqpReceiver']
-
-
-# SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For
-# every shim in this list, a test is dynamically constructed which tests it against itself as well as every
-# other shim in the list.
-#
-# As new shims are added, add them into this map to have them included in the test cases.
-#SHIM_MAP = {ProtonPythonShim.NAME: ProtonPythonShim()}
-#SHIM_MAP = {ProtonPythonShim.NAME: ProtonCppShim()}
-SHIM_MAP = {ProtonCppShim.NAME: ProtonCppShim(),
- ProtonPythonShim.NAME: ProtonPythonShim()
- }
-
-
-class TestOptions(object):
- """
- Class controlling command-line arguments used to control the test.
- """
- def __init__(self):
- parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite '
- 'for AMQP simple types')
- parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT',
- help='Broker against which to run test suite.')
-# test_group = parser.add_mutually_exclusive_group()
-# test_group.add_argument('--include-test', action='append', metavar='TEST-NAME',
-# help='Name of test to include')
-# test_group.add_argument('--exclude-test', action='append', metavar='TEST-NAME',
-# help='Name of test to exclude')
-# type_group = test_group.add_mutually_exclusive_group()
-# type_group.add_argument('--include-type', action='append', metavar='AMQP-TYPE',
-# help='Name of AMQP type to include. Supported types:\n%s' %
-# sorted(AmqpPrimitiveTypes.TYPE_MAP.keys()))
- parser.add_argument('--exclude-type', action='append', metavar='AMQP-TYPE',
- help='Name of AMQP type to exclude. Supported types:\n%s' %
- sorted(AmqpPrimitiveTypes.TYPE_MAP.keys()))
-# shim_group = test_group.add_mutually_exclusive_group()
-# shim_group.add_argument('--include-shim', action='append', metavar='SHIM-NAME',
-# help='Name of shim to include. Supported shims:\n%s' % SHIM_NAMES)
- parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME',
- help='Name of shim to exclude. Supported shims:\n%s' % sorted(SHIM_MAP.keys()))
- self.args = parser.parse_args()
-
-
-#--- Main program start ---
-
-if __name__ == '__main__':
-
- ARGS = TestOptions().args
- #print 'ARGS:', ARGS # debug
-
- # Connect to broker to find broker type
- CONNECTION_PROPS = broker_properties.getBrokerProperties(ARGS.broker)
- if CONNECTION_PROPS is None:
- print 'WARNING: Unable to get connection properties - unknown broker'
- BROKER = 'unknown'
- else:
- print 'Test Broker: %s v.%s on %s' % (CONNECTION_PROPS[symbol(u'product')],
- CONNECTION_PROPS[symbol(u'version')],
- CONNECTION_PROPS[symbol(u'platform')])
- print
- BROKER = CONNECTION_PROPS[symbol(u'product')]
-
- TYPES = AmqpPrimitiveTypes()
-
- # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed
- # per AMQP type used as the key in map AmqpPrimitiveTypes.TYPE_MAP.
- TEST_CASE_CLASSES = []
-
- # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created
- # type classes, each of which contains a test for the combinations of client shims
- TEST_SUITE = unittest.TestSuite()
-
- # Remove shims excluded from the command-line
- if ARGS.exclude_shim is not None:
- for shim in ARGS.exclude_shim:
- SHIM_MAP.pop(shim)
- # Create test classes dynamically
- for at in sorted(TYPES.get_type_list()):
- if ARGS.exclude_type is None or at not in ARGS.exclude_type:
- test_case_class = create_testcase_class(BROKER,
- TYPES,
- ARGS.broker,
- at,
- product(SHIM_MAP.values(), repeat=2))
- TEST_CASE_CLASSES.append(test_case_class)
- TEST_SUITE.addTest(unittest.makeSuite(test_case_class))
-
- # Finally, run all the dynamically created tests
- res = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE)
- if not res.wasSuccessful():
- exit(1) # Errors or failures present
-
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/.gitignore
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/.gitignore b/src/python/qpid-interop-test/.gitignore
new file mode 100644
index 0000000..b3f6765
--- /dev/null
+++ b/src/python/qpid-interop-test/.gitignore
@@ -0,0 +1,2 @@
+/interop_test_errors.pyc
+/shim_utils.pyc
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/__init__.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/__init__.py b/src/python/qpid-interop-test/__init__.py
new file mode 100644
index 0000000..7b8aee3
--- /dev/null
+++ b/src/python/qpid-interop-test/__init__.py
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.
+#
+
+import broker_properties
+import interop_test_errors
+import test_type_map
+import types
+import jms
+
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/broker_properties.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/broker_properties.py b/src/python/qpid-interop-test/broker_properties.py
new file mode 100644
index 0000000..08cc9cc
--- /dev/null
+++ b/src/python/qpid-interop-test/broker_properties.py
@@ -0,0 +1,54 @@
+"""
+Module containing a small client which connects to the broker and
+gets the broker connection properties so as to identify the broker.
+"""
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Client(MessagingHandler):
+ """
+ Client to connect to broker and collect connection properties, used to identify the test broker
+ """
+ def __init__(self, url):
+ super(Client, self).__init__()
+ self.url = url
+ self.remote_properties = None
+
+ def on_connection_remote_open(self, event):
+ self.remote_properties = event.connection.remote_properties
+ event.connection.close()
+
+ def on_start(self, event):
+ """Event loop start"""
+ event.container.connect(url=self.url)
+
+ def get_connection_properties(self):
+ """Return the connection properties"""
+ return self.remote_properties
+
+
+def getBrokerProperties(broker_url):
+ """Start client, then return its connection properties"""
+ MSG_HANDLER = Client(broker_url)
+ Container(MSG_HANDLER).run()
+ return MSG_HANDLER.get_connection_properties()
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/interop_test_errors.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/interop_test_errors.py b/src/python/qpid-interop-test/interop_test_errors.py
new file mode 100644
index 0000000..6be8959
--- /dev/null
+++ b/src/python/qpid-interop-test/interop_test_errors.py
@@ -0,0 +1,29 @@
+"""
+Module containing Error classes for interop testing
+"""
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.
+#
+
+class InteropTestError(StandardError):
+ """
+ Generic simple error class for use in interop tests
+ """
+ def __init__(self, error_message):
+ super(InteropTestError, self).__init__(error_message)
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/jms/jms_message_tests.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/jms/jms_message_tests.py b/src/python/qpid-interop-test/jms/jms_message_tests.py
new file mode 100755
index 0000000..432b1fd
--- /dev/null
+++ b/src/python/qpid-interop-test/jms/jms_message_tests.py
@@ -0,0 +1,454 @@
+#!/usr/bin/env python
+
+"""
+Module to test JMS message types across different APIs
+"""
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.
+#
+
+import argparse
+import unittest
+
+from itertools import product
+from json import dumps, loads
+from os import getenv, path
+from subprocess import check_output, CalledProcessError
+from sys import exit
+
+from proton import symbol
+from test_type_map import TestTypeMap
+import broker_properties
+
+
+# TODO - propose a sensible default when installation details are worked out
+QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME')
+
+class JmsMessageTypes(TestTypeMap):
+ """
+ Class which contains all the described JMS message types and the test values to be used in testing.
+ """
+
+ # The TYPE_SUBMAP defines test values for JMS message types that allow typed message content. Note that the
+ # types defined here are understood to be *Java* types and the stringified values are to be interpreted
+ # as the appropriate Java type by the send shim.
+ TYPE_SUBMAP = {
+ 'boolean': ['True',
+ 'False'],
+ 'byte': ['-0x80',
+ '-0x1',
+ '0x0',
+ '0x7f'],
+ 'bytes': [b'',
+ b'12345',
+ b'Hello, world',
+ b'\\x01\\x02\\x03\\x04\\x05abcde\\x80\\x81\\xfe\\xff',
+ b'The quick brown fox jumped over the lazy dog 0123456789.' * 100],
+ 'char': ['a',
+ 'Z',
+ '\x01',
+ '\x7f'],
+ 'double': ['0x0000000000000000', # 0.0
+ '0x8000000000000000', # -0.0
+ '0x400921fb54442eea', # pi (3.14159265359) positive decimal
+ '0xc005bf0a8b145fcf', # -e (-2.71828182846) negative decimal
+ '0x0000000000000001', # Smallest positive denormalized number
+ '0x8000000000000001', # Smallest negative denormalized number
+ '0x000fffffffffffff', # Largest positive denormalized number
+ '0x8010000000000000', # Largest negative denormalized number
+ '0x7fefffffffffffff', # Largest positive normalized number
+ '0xffefffffffffffff', # Largest negative normalized number
+ '0x7ff0000000000000', # +Infinity
+ '0xfff0000000000000', # -Infinity
+ '0x7ff8000000000000'], # +NaN
+ 'float': ['0x00000000', # 0.0
+ '0x80000000', # -0.0
+ '0x40490fdb', # pi (3.14159265359) positive decimal
+ '0xc02df854', # -e (-2.71828182846) negative decimal
+ '0x00000001', # Smallest positive denormalized number
+ '0x80000001', # Smallest negative denormalized number
+ '0x007fffff', # Largest positive denormalized number
+ '0x807fffff', # Largest negative denormalized number
+ '0x00800000', # Smallest positive normalized number
+ '0x80800000', # Smallest negative normalized number
+ '0x7f7fffff', # Largest positive normalized number
+ '0xff7fffff', # Largest negative normalized number
+ #'0x7f800000', # +Infinity # PROTON-1149 - fails on RHEL7
+ #'0xff800000', # -Infinity # PROTON-1149 - fails on RHEL7
+ '0x7fc00000'], # +NaN
+ 'int': ['-0x80000000',
+ '-0x81',
+ '-0x80',
+ '-0x1',
+ '0x0',
+ '0x7f',
+ '0x80',
+ '0x7fffffff'],
+ 'long': ['-0x8000000000000000',
+ '-0x81',
+ '-0x80',
+ '-0x1',
+ '0x0',
+ '0x7f',
+ '0x80',
+ '0x7fffffffffffffff'],
+ 'short': ['-0x8000',
+ '-0x1',
+ '0x0',
+ '0x7fff'],
+ 'string': ['',
+ 'Hello, world',
+ '"Hello, world"',
+ "Charlie's \"peach\"",
+ 'Charlie\'s "peach"',
+ 'The quick brown fox jumped over the lazy dog 0123456789.' * 100]
+ }
+
+ TYPE_MAP = {
+ 'JMS_BYTESMESSAGE_TYPE': TYPE_SUBMAP,
+ 'JMS_MAPMESSAGE_TYPE': TYPE_SUBMAP,
+# 'JMS_OBJECTMESSAGE_TYPE': {
+# 'java.lang.Boolean': ['true',
+# 'false'],
+# 'java.lang.Byte': ['-128',
+# '0',
+# '127'],
+# 'java.lang.Character': [u'a',
+# u'Z'],
+# 'java.lang.Double': ['0.0',
+# '3.141592654',
+# '-2.71828182846'],
+# 'java.lang.Float': ['0.0',
+# '3.14159',
+# '-2.71828'],
+# 'java.lang.Integer': ['-2147483648',
+# '-129',
+# '-128',
+# '-1',
+# '0',
+# '127',
+# '128',
+# '2147483647'],
+# 'java.lang.Long' : ['-9223372036854775808',
+# '-129',
+# '-128',
+# '-1',
+# '0',
+# '127',
+# '128',
+# '9223372036854775807'],
+# 'java.lang.Short': ['-32768',
+# '-129',
+# '-128',
+# '-1',
+# '0',
+# '127',
+# '128',
+# '32767'],
+# 'java.lang.String': [u'',
+# u'Hello, world',
+# u'"Hello, world"',
+# u"Charlie's \"peach\"",
+# u'Charlie\'s "peach"']
+# },
+ 'JMS_STREAMMESSAGE_TYPE': TYPE_SUBMAP,
+ 'JMS_TEXTMESSAGE_TYPE': {'text': ['',
+ 'Hello, world',
+ '"Hello, world"',
+ "Charlie's \"peach\"",
+ 'Charlie\'s "peach"',
+ 'The quick brown fox jumped over the lazy dog 0123456789.' * 100]}
+ }
+
+ BROKER_SKIP = {}
+
+
+class JmsMessageTypeTestCase(unittest.TestCase):
+ """
+ Abstract base class for JMS message type test cases
+ """
+
+ def run_test(self, broker_addr, jms_message_type, test_values, send_shim, receive_shim):
+ """
+ Run this test by invoking the shim send method to send the test values, followed by the shim receive method
+ to receive the values. Finally, compare the sent values with the received values.
+ """
+ if len(test_values) > 0:
+ queue_name = 'jms.queue.qpid-interop.jms_message_type_tests.%s.%s.%s' % (jms_message_type, send_shim.NAME,
+ receive_shim.NAME)
+ send_error_text = send_shim.send(broker_addr, queue_name, jms_message_type, dumps(test_values))
+ if len(send_error_text) > 0:
+ self.fail('Send shim \'%s\':\n%s' % (send_shim.NAME, send_error_text))
+ num_test_values = {}
+ for index in test_values.keys():
+ num_test_values[index] = len(test_values[index])
+ receive_text = receive_shim.receive(broker_addr, queue_name, jms_message_type, dumps(num_test_values))
+ if isinstance(receive_text, str):
+ self.fail(receive_text)
+ else:
+ self.assertEqual(receive_text, test_values, msg='\n sent:%s\n\n received:%s' % \
+ (test_values, receive_text))
+ else:
+ self.fail('Type %s has no test values' % jms_message_type)
+
+
+def create_testcase_class(broker_name, types, broker_addr, jms_message_type, shim_product):
+ """
+ Class factory function which creates new subclasses to JmsMessageTypeTestCase.
+ """
+
+ def __repr__(self):
+ """Print the class name"""
+ return self.__class__.__name__
+
+ def add_test_method(cls, send_shim, receive_shim):
+ """Function which creates a new test method in class cls"""
+
+ @unittest.skipIf(types.skip_test(jms_message_type, broker_name),
+ types.skip_test_message(jms_message_type, broker_name))
+ def inner_test_method(self):
+ self.run_test(self.broker_addr, self.jms_message_type, self.test_values, send_shim, receive_shim)
+
+ inner_test_method.__name__ = 'test_%s_%s->%s' % (jms_message_type[4:-5], send_shim.NAME, receive_shim.NAME)
+ setattr(cls, inner_test_method.__name__, inner_test_method)
+
+ class_name = jms_message_type[4:-5].title() + 'TestCase'
+ class_dict = {'__name__': class_name,
+ '__repr__': __repr__,
+ '__doc__': 'Test case for JMS message type \'%s\'' % jms_message_type,
+ 'jms_message_type': jms_message_type,
+ 'broker_addr': broker_addr,
+ 'test_values': types.get_test_values(jms_message_type)}
+ new_class = type(class_name, (JmsMessageTypeTestCase,), class_dict)
+ for send_shim, receive_shim in shim_product:
+ add_test_method(new_class, send_shim, receive_shim)
+ return new_class
+
+class Shim(object):
+ """
+ Abstract shim class, parent of all shims.
+ """
+ NAME = None
+ USE_SHELL = False
+
+ def __init__(self, args):
+ self.ARGS = args
+ self.SEND = None
+ self.RECEIVE = None
+
+
+ def send(self, broker_addr, queue_name, jms_message_type, json_test_values_str):
+ """
+ Send the values of type jms_message_type in json_test_values_str to queue queue_name.
+ Return output (if any) from stdout.
+ """
+ arg_list = []
+ arg_list.extend(self.SEND)
+ arg_list.extend([broker_addr, queue_name, jms_message_type])
+ arg_list.append(json_test_values_str)
+
+ try:
+ #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
+ return check_output(arg_list, shell=self.USE_SHELL)
+ except CalledProcessError as exc:
+ return str(exc) + '\n\nOutput:\n' + exc.output
+ except Exception as exc:
+ return str(exc)
+
+
+ def receive(self, broker_addr, queue_name, jms_message_type, json_test_num_values_str):
+ """
+ Receive json_test_num_values_str messages containing type jms_message_type from queue queue_name.
+ If the first line returned from stdout is the AMQP type, then the rest is assumed to be the returned
+ test value list. Otherwise error output is assumed.
+ """
+ output = ''
+ try:
+ arg_list = []
+ arg_list.extend(self.RECEIVE)
+ arg_list.extend([broker_addr, queue_name, jms_message_type, json_test_num_values_str])
+ #print '\n>>>', arg_list # DEBUG - useful to see command-line sent to shim
+ output = check_output(arg_list)
+ #print '<<<', output # DEBUG- useful to see text received from shim
+ str_tvl = output.split('\n')[:-1] # remove trailing \n
+ if len(str_tvl) == 1:
+ return output
+ if len(str_tvl) == 2:
+ return loads(str_tvl[1])
+ else:
+ return loads("".join(str_tvl[1:]))
+ except CalledProcessError as exc:
+ return str(exc) + '\n\n' + exc.output
+ except Exception as exc:
+ return str(exc)
+
+
+class ProtonPythonShim(Shim):
+ """
+ Shim for qpid-proton Python client
+ """
+ NAME = 'ProtonPython'
+ SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src')
+
+ def __init__(self, args):
+ super(ProtonPythonShim, self).__init__(args)
+ self.SEND = [path.join(self.SHIM_LOC, 'JmsSenderShim.py')]
+ self.RECEIVE = [path.join(self.SHIM_LOC, 'JmsReceiverShim.py')]
+
+
+class ProtonCppShim(Shim):
+ """
+ Shim for qpid-proton Python client
+ """
+ NAME = 'ProtonCpp'
+ SHIM_LOC = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'src')
+
+ def __init__(self, args):
+ super(ProtonCppShim, self).__init__(args)
+ self.SEND = [path.join(self.SHIM_LOC, 'JmsSender')]
+ self.RECEIVE = [path.join(self.SHIM_LOC, 'JmsReceiver')]
+
+
+class QpidJmsShim(Shim):
+ """
+ Shim for qpid-jms JMS client
+ """
+ NAME = 'QpidJms'
+
+ # Classpath components
+ MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository'))
+ QPID_INTEROP_TEST_SHIM_JAR = path.join(MAVEN_REPO_PATH, 'org', 'apache', 'qpid', 'qpid-interop-test-jms-shim',
+ '0.1.0-SNAPSHOT', 'qpid-interop-test-jms-shim-0.1.0-SNAPSHOT.jar')
+
+ JAVA_HOME = getenv('JAVA_HOME', '/usr/lib/jvm/java') # Default only works in Linux
+ JAVA_EXEC = path.join(JAVA_HOME, 'bin/java')
+
+ def __init__(self, args):
+ super(QpidJmsShim, self).__init__(args)
+ DEP_CLASSPATH_FILE = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'cp.txt')
+ with open(DEP_CLASSPATH_FILE, 'r') as dcpfile:
+ self.CLASSPATH = dcpfile.read().replace('\n', '')
+ if self.jarExists(self.QPID_INTEROP_TEST_SHIM_JAR):
+ self.CLASSPATH += ':' + self.QPID_INTEROP_TEST_SHIM_JAR
+ else:
+ print '*** ERROR: Cannot find jar file "%s"' % QPID_INTEROP_TEST_SHIM_JAR
+
+ self.SEND = [self.JAVA_EXEC, '-cp', self.CLASSPATH, 'org.apache.qpid.interop_test.shim.JmsSenderShim']
+ self.RECEIVE = [self.JAVA_EXEC, '-cp', self.CLASSPATH, 'org.apache.qpid.interop_test.shim.JmsReceiverShim']
+
+ def jarExists(self, jarPath):
+ try:
+ f = open(jarPath, 'rb')
+ f.close()
+ return True
+ except IOError as e:
+ pass
+ return False
+
+
+# TODO: Complete the test options to give fine control over running tests
+class TestOptions(object):
+ """
+ Class controlling command-line arguments used to control the test.
+ """
+ def __init__(self, shims):
+ parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite '
+ 'for JMS message types')
+ parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT',
+ help='Broker against which to run test suite.')
+# test_group = parser.add_mutually_exclusive_group()
+# test_group.add_argument('--include-test', action='append', metavar='TEST-NAME',
+# help='Name of test to include')
+# test_group.add_argument('--exclude-test', action='append', metavar='TEST-NAME',
+# help='Name of test to exclude')
+# type_group = test_group.add_mutually_exclusive_group()
+# type_group.add_argument('--include-type', action='append', metavar='AMQP-TYPE',
+# help='Name of AMQP type to include. Supported types:\n%s' %
+# sorted(JmsMessageTypes.TYPE_MAP.keys()))
+ parser.add_argument('--exclude-type', action='append', metavar='JMS-MESSAGE-TYPE',
+ help='Name of JMS message type to exclude. Supported types:\n%s' %
+ sorted(JmsMessageTypes.TYPE_MAP.keys()))
+# shim_group = test_group.add_mutually_exclusive_group()
+# shim_group.add_argument('--include-shim', action='append', metavar='SHIM-NAME',
+# help='Name of shim to include. Supported shims:\n%s' % SHIM_NAMES)
+ parser.add_argument('--exclude-shim', action='append', metavar='SHIM-NAME',
+ help='Name of shim to exclude. Supported shims:\n%s' % sorted(shims))
+ self.args = parser.parse_args()
+
+
+#--- Main program start ---
+
+if __name__ == '__main__':
+
+ SHIMS = [ProtonCppShim.NAME, QpidJmsShim.NAME, ProtonPythonShim.NAME]
+
+ ARGS = TestOptions(SHIMS).args
+ #print 'ARGS:', ARGS # debug
+
+ # SHIM_MAP contains an instance of each client language shim that is to be tested as a part of this test. For
+ # every shim in this list, a test is dynamically constructed which tests it against itself as well as every
+ # other shim in the list.
+ #
+ # As new shims are added, add them into this map to have them included in the test cases.
+ SHIM_MAP = {ProtonCppShim.NAME: ProtonCppShim(ARGS),
+ QpidJmsShim.NAME: QpidJmsShim(ARGS),
+ ProtonPythonShim.NAME: ProtonPythonShim(ARGS)}
+
+ # Connect to broker to find broker type
+ CONNECTION_PROPS = broker_properties.getBrokerProperties(ARGS.broker)
+ if CONNECTION_PROPS is None:
+ print 'WARNING: Unable to get connection properties - unknown broker'
+ BROKER = 'unknown'
+ else:
+ print 'Test Broker: %s v.%s on %s' % (CONNECTION_PROPS[symbol(u'product')],
+ CONNECTION_PROPS[symbol(u'version')],
+ CONNECTION_PROPS[symbol(u'platform')])
+ print
+ BROKER = CONNECTION_PROPS[symbol(u'product')]
+
+ TYPES = JmsMessageTypes()
+
+ # TEST_CASE_CLASSES is a list that collects all the test classes that are constructed. One class is constructed
+ # per AMQP type used as the key in map JmsMessageTypes.TYPE_MAP.
+ TEST_CASE_CLASSES = []
+
+ # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created
+ # type classes, each of which contains a test for the combinations of client shims
+ TEST_SUITE = unittest.TestSuite()
+
+ # Remove shims excluded from the command-line
+ if ARGS.exclude_shim is not None:
+ for shim in ARGS.exclude_shim:
+ SHIM_MAP.pop(shim)
+ # Create test classes dynamically
+ for jmt in sorted(TYPES.get_type_list()):
+ if ARGS.exclude_type is None or jmt not in ARGS.exclude_type:
+ test_case_class = create_testcase_class(BROKER,
+ TYPES,
+ ARGS.broker,
+ jmt,
+ product(SHIM_MAP.values(), repeat=2))
+ TEST_CASE_CLASSES.append(test_case_class)
+ TEST_SUITE.addTest(unittest.makeSuite(test_case_class))
+
+ # Finally, run all the dynamically created tests
+ res = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE)
+ if not res.wasSuccessful():
+ exit(1)
+
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/f4b87a1e/src/python/qpid-interop-test/test_type_map.py
----------------------------------------------------------------------
diff --git a/src/python/qpid-interop-test/test_type_map.py b/src/python/qpid-interop-test/test_type_map.py
new file mode 100644
index 0000000..0a5b1fb
--- /dev/null
+++ b/src/python/qpid-interop-test/test_type_map.py
@@ -0,0 +1,78 @@
+"""
+Module containing Error classes for interop testing
+"""
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# 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.
+#
+
+class TestTypeMap(object):
+ """
+ Class which contains all the described types and the test values to be used in testing against those types.
+ """
+
+ # TYPE_MAP: Map containing all described types as the indecies, and a list of values to be used in testing
+ # that type as a list of values.
+ #
+ # Format: {'type_1' : [val_1_1, val_1_2, ...],
+ # 'type_2' : [val_2_1, val_2_2, ...],
+ # ...
+ # }
+ TYPE_MAP = {}
+
+ # BROKER_SKIP: For know broker issues where a type would cause a test to fail or hang,
+ # entries in BROKER_SKIP will cause the test to be skipped with a message.
+ # This is a map containing AMQP types as a key, and a list of brokers for which this
+ # type should be skipped.
+ # Format: {'jms_msg_type_1' : {'broker_1' : 'skip msg for broker_1',
+ # 'broker_2' : 'skip msg for broker_2',
+ # ...
+ # },
+ # 'jms_msg_type_2' : {'broker_1' : 'skip msg for broker_1',
+ # 'broker_2' : 'skip msg for broker_2',
+ # ...
+ # },
+ # ...
+ # }
+ # where broker_1, broker_2, ... are broker product names as defined by the
+ # connection property string it returns.
+ BROKER_SKIP = {}
+
+ def __init__(self):
+ pass
+
+ def get_type_list(self):
+ """Return a list of types which this test suite supports"""
+ return self.TYPE_MAP.keys()
+
+ def get_test_values(self, test_type):
+ """Return test values to use when testing the supplied type."""
+ if test_type not in self.TYPE_MAP.keys():
+ return None
+ return self.TYPE_MAP[test_type]
+
+ def skip_test_message(self, test_type, broker_name):
+ """Return the message to use if a test is skipped"""
+ if test_type in self.BROKER_SKIP.keys():
+ if broker_name in self.BROKER_SKIP[test_type]:
+ return str(self.BROKER_SKIP[test_type][broker_name])
+ return None
+
+ def skip_test(self, test_type, broker_name):
+ """Return boolean True if test should be skipped"""
+ return test_type in self.BROKER_SKIP.keys() and \
+ broker_name in self.BROKER_SKIP[test_type]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org