http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-cpp/src/not_yet_impl/jms_dtx_test/Sender.hpp ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-cpp/src/not_yet_impl/jms_dtx_test/Sender.hpp b/shims/qpid-proton-cpp/src/not_yet_impl/jms_dtx_test/Sender.hpp deleted file mode 100644 index 524ad63..0000000 --- a/shims/qpid-proton-cpp/src/not_yet_impl/jms_dtx_test/Sender.hpp +++ /dev/null @@ -1,39 +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. - * - */ - -#ifndef SRC_QPIDIT_JMS_DTX_TEST_SENDER_HPP_ -#define SRC_QPIDIT_JMS_DTX_TEST_SENDER_HPP_ - -#include <qpidit/JmsTestBase.hpp> - -namespace qpidit -{ - namespace jms_dtx_test - { - - class Sender : public qpidit::JmsTestBase - { - }; - - } /* namespace jms_dtx_test */ -} /* namespace qpidit */ - -#endif /* SRC_QPIDIT_JMS_DTX_TEST_SENDER_HPP_ */
http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.cpp ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.cpp b/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.cpp deleted file mode 100644 index 2234564..0000000 --- a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.cpp +++ /dev/null @@ -1,43 +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. - * - */ - -#include "qpidit/jms_large_content_test/Receiver.hpp" - -#include <stdlib.h> // exit() - -namespace qpidit -{ - namespace jms_large_content_test - { - } /* namespace jms_large_content_test */ -} /* namespace qpidit */ - - -/* - * --- main --- - * Args: 1: Broker address (ip-addr:port) - * 2: Queue name - * ... - */ - -int main(int argc, char** argv) { - exit(0); -} http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.hpp ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.hpp b/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.hpp deleted file mode 100644 index 2b891f3..0000000 --- a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Receiver.hpp +++ /dev/null @@ -1,39 +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. - * - */ - -#ifndef SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_RECEIVER_HPP_ -#define SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_RECEIVER_HPP_ - -#include <qpidit/JmsTestBase.hpp> - -namespace qpidit -{ - namespace jms_large_content_test - { - - class Receiver : public qpidit::JmsTestBase - { - }; - - } /* namespace jms_large_content_test */ -} /* namespace qpidit */ - -#endif /* SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_RECEIVER_HPP_ */ http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.cpp ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.cpp b/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.cpp deleted file mode 100644 index c151006..0000000 --- a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.cpp +++ /dev/null @@ -1,43 +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. - * - */ - -#include "qpidit/jms_large_content_test/Sender.hpp" - -#include <stdlib.h> // exit() - -namespace qpidit -{ - namespace jms_large_content_test - { - } /* namespace jms_large_content_test */ -} /* namespace qpidit */ - - -/* - * --- main --- - * Args: 1: Broker address (ip-addr:port) - * 2: Queue name - * ... - */ - -int main(int argc, char** argv) { - exit(0); -} http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.hpp ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.hpp b/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.hpp deleted file mode 100644 index e45926b..0000000 --- a/shims/qpid-proton-cpp/src/not_yet_impl/jms_large_content_test/Sender.hpp +++ /dev/null @@ -1,39 +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. - * - */ - -#ifndef SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_SENDER_HPP_ -#define SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_SENDER_HPP_ - -#include <qpidit/JmsTestBase.hpp> - -namespace qpidit -{ - namespace jms_large_content_test - { - - class Sender : public qpidit::JmsTestBase - { - }; - - } /* namespace jms_large_content_test */ -} /* namespace qpidit */ - -#endif /* SRC_QPIDIT_JMS_LARGE_CONTENT_TEST_SENDER_HPP_ */ http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Receiver.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Receiver.py b/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Receiver.py deleted file mode 100755 index 76be21c..0000000 --- a/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Receiver.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python - -""" -AMQP distributed transactions (DTX) test receiver shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class AmqpDtxTestReceiver(MessagingHandler): - """ - Receiver shim for AMQP dtx test - ... - """ - def __init__(self, broker_url, queue_name): - super(AmqpDtxTestReceiver, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.received_value_list = [] - self.expected = int('0') - self.received = 0 - - def get_received_value_list(self): - """Return the received list of AMQP values""" - return self.received_value_list - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_receiver(connection, source=self.queue_name) - - def on_message(self, event): - """Event callback when a message is received by the client""" - if event.message.id and event.message.id < self.received: - return # ignore duplicate message - if self.received < self.expected: - pass # do something here - if self.received >= self.expected: - event.receiver.close() - event.connection.close() - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - RECEIVER = AmqpDtxTestReceiver(sys.argv[1], sys.argv[2]) - Container(RECEIVER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Sender.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Sender.py b/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Sender.py deleted file mode 100755 index 24419b8..0000000 --- a/shims/qpid-proton-python/not_yet_impl/amqp_dtx_test/Sender.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python - -""" -AMQP distributed transactions (DTX) test sender shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class AmqpDtxTestSender(MessagingHandler): - """ - Sender shim for AMQP dtx test - ... - """ - def __init__(self, broker_url, queue_name): - super(AmqpDtxTestSender, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.test_value_list = [] - self.sent = 0 - self.confirmed = 0 - self.total = len(self.test_value_list) - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_sender(connection, target=self.queue_name) - - def on_sendable(self, event): - """Event callback for when send credit is received, allowing the sending of messages""" - if self.sent == 0: - for test_value in self.test_value_list: - if event.sender.credit: - message = self.create_message(test_value) - if message is not None: - event.sender.send(message) - self.sent += 1 - else: - event.connection.close() - return - - def create_message(self, test_value): - """ - Creates a single message with the test value translated from its string representation to the appropriate - AMQP value (set in self.amqp_type). - """ - return None - - def on_accepted(self, event): - """Event callback for when a sent message is accepted by the broker""" - self.confirmed += 1 - if self.confirmed == self.total: - event.connection.close() - - def on_disconnected(self, event): - """Event callback for when the broker disconnects with the client""" - self.sent = self.confirmed - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - SENDER = AmqpDtxTestSender(sys.argv[1], sys.argv[2]) - Container(SENDER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc - print format_exc() - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Receiver.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Receiver.py b/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Receiver.py deleted file mode 100755 index 4ee96ba..0000000 --- a/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Receiver.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python - -""" -AMQP features test receiver shim for qpid-interop-test -""" - -# -# 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 json import dumps -import os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class AmqpFeaturesTestReceiver(MessagingHandler): - """ - Reciver shim for AMQP dtx test - ... - """ - def __init__(self, broker_url, queue_name, test_type, num_expected_messages_str): - super(AmqpFeaturesTestReceiver, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.test_type = test_type - self.received_value_list = [] - self.expected = int(num_expected_messages_str) - self.received = 0 - self.remote_properties = None - - def get_received_value_list(self): - """Return the received list of AMQP values""" - return self.received_value_list - - def get_remote_properties(self): - """Return the remote (broker) properties""" - return self.remote_properties - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_receiver(connection, source=self.queue_name) - - def on_connection_remote_open(self, event): - """Callback for remote connection open""" - self.remote_properties = event.connection.remote_properties - if self.test_type == 'connection_property': - event.connection.close() - - def on_message(self, event): - """Event callback when a message is received by the client""" - if event.message.id and event.message.id < self.received: - return # ignore duplicate message - if self.received < self.expected: - pass # do something here - if self.received >= self.expected: - event.receiver.close() - event.connection.close() - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# 3: Test type -# 4: Number of expected messages -try: - RECEIVER = AmqpFeaturesTestReceiver(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) - Container(RECEIVER).run() - print sys.argv[3] - if (sys.argv[3] == 'connection_property'): - print dumps(RECEIVER.get_remote_properties()) - else: - print dumps(RECEIVER.get_received_value_list()) - -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Sender.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Sender.py b/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Sender.py deleted file mode 100755 index 7ac0114..0000000 --- a/shims/qpid-proton-python/not_yet_impl/amqp_features_test/Sender.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python - -""" -AMQP features test sender shim for qpid-interop-test -""" - -# -# 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 json import dumps, loads -import os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class AmqpFeaturesTestSender(MessagingHandler): - """ - Sender shim for AMQP dtx test - ... - """ - def __init__(self, broker_url, queue_name, test_type, test_args): - super(AmqpFeaturesTestSender, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.test_type = test_type - self.test_args = test_args - self.test_value_list = [] - self.sent = 0 - self.confirmed = 0 - self.total = len(self.test_value_list) - self.remote_properties = None - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_sender(connection, target=self.queue_name) - - def on_connection_remote_open(self, event): - """Callback for remote connection open""" - self.remote_properties = event.connection.remote_properties - if self.test_type == 'connection_property': - event.connection.close() - - def on_sendable(self, event): - """Event callback for when send credit is received, allowing the sending of messages""" - if self.sent == 0: - for test_value in self.test_value_list: - if event.sender.credit: - message = self.create_message(test_value) - if message is not None: - event.sender.send(message) - self.sent += 1 - else: - event.connection.close() - return - - def create_message(self, test_value): - """ - Creates a single message with the test value translated from its string representation to the appropriate - AMQP value (set in self.amqp_type). - """ - return None - - def on_accepted(self, event): - """Event callback for when a sent message is accepted by the broker""" - self.confirmed += 1 - if self.confirmed == self.total: - event.connection.close() - - def on_disconnected(self, event): - """Event callback for when the broker disconnects with the client""" - self.sent = self.confirmed - - def get_remote_properties(self): - """Return the remote (broker) properties""" - return self.remote_properties - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# 3: Test type -# 4: Test args -try: - SENDER = AmqpFeaturesTestSender(sys.argv[1], sys.argv[2], sys.argv[3], loads(sys.argv[4])) - Container(SENDER).run() - print sys.argv[3] - if sys.argv[3] == 'connection_property': - print dumps(SENDER.get_remote_properties()) -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc - print format_exc() - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Receiver.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Receiver.py b/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Receiver.py deleted file mode 100755 index e700106..0000000 --- a/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Receiver.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python - -""" -JMS distributed transactions (DTX) test receiver shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class JmsDtxTestReceiver(MessagingHandler): - """ - Receiver shim for JMS dtx test - ... - """ - def __init__(self, broker_url, queue_name): - super(JmsDtxTestReceiver, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.expected = int('0') - self.received = 0 - self.received_value_list = [] - - def get_received_value_list(self): - """"Return the received list of values""" - return self.received_value_list - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_receiver(connection, source=self.queue_name) - - def on_message(self, event): - """Event callback when a message is received by the client""" - if event.message.id and event.message.id < self.received: - return # ignore duplicate message - if self.received < self.expected: - pass # do something here - if self.received >= self.expected: - event.receiver.close() - event.connection.close() - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - RECEIVER = JmsDtxTestReceiver(sys.argv[1], sys.argv[2]) - Container(RECEIVER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Sender.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Sender.py b/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Sender.py deleted file mode 100755 index 9e7aa0f..0000000 --- a/shims/qpid-proton-python/not_yet_impl/jms_dtx_test/Sender.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python - -""" -JMS distributed transactions (DTX) test sender shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class JmsDtxTestSender(MessagingHandler): - """ - Sender shim for JMS dtx test - ... - """ - def __init__(self, broker_url, queue_name): - super(JmsDtxTestSender, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.test_value_list = [] - self.sent = 0 - self.confirmed = 0 - self.total = 0 - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_sender(connection, target=self.queue_name) - - def on_sendable(self, event): - """Event callback for when send credit is received, allowing the sending of messages""" - if self.sent == 0: - for test_value in self.test_value_list: - if event.sender.credit: - message = self.create_message(test_value) - if message is not None: - event.sender.send(message) - self.sent += 1 - else: - event.connection.close() - return - - def create_message(self, test_value): - """ - Creates a single JMS message with the test value translated from its string representation to the appropriate - value (set in self.amqp_type). - """ - return None - - def on_accepted(self, event): - """Event callback for when a sent message is accepted by the broker""" - self.confirmed += 1 - if self.confirmed == self.total: - event.connection.close() - - def on_disconnected(self, event): - """Event callback for when the broker disconnects with the client""" - self.sent = self.confirmed - - - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - SENDER = JmsDtxTestSender(sys.argv[1], sys.argv[2]) - Container(SENDER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Receiver.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Receiver.py b/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Receiver.py deleted file mode 100755 index e4942de..0000000 --- a/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Receiver.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python - -""" -JMS large content test receiver shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class JmsLargeContentTestReceiver(MessagingHandler): - """ - Receiver shim for JMS large content test - ... - """ - def __init__(self, broker_url, queue_name): - super(JmsLargeContentTestReceiver, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.expected = int('0') - self.received = 0 - self.received_value_list = [] - - def get_received_value_list(self): - """"Return the received list of values""" - return self.received_value_list - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_receiver(connection, source=self.queue_name) - - def on_message(self, event): - """Event callback when a message is received by the client""" - if event.message.id and event.message.id < self.received: - return # ignore duplicate message - if self.received < self.expected: - pass # do something here - if self.received >= self.expected: - event.receiver.close() - event.connection.close() - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - RECEIVER = JmsLargeContentTestReceiver(sys.argv[1], sys.argv[2]) - Container(RECEIVER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Sender.py ---------------------------------------------------------------------- diff --git a/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Sender.py b/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Sender.py deleted file mode 100755 index 076c55c..0000000 --- a/shims/qpid-proton-python/not_yet_impl/jms_large_content_test/Sender.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python - -""" -JMS large content test sender shim for qpid-interop-test -""" - -# -# 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 os.path -import sys -from traceback import format_exc - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -class JmsLargeContentTestSender(MessagingHandler): - """ - Sender shim for JMS dtx test - ... - """ - def __init__(self, broker_url, queue_name): - super(JmsLargeContentTestSender, self).__init__() - self.broker_url = broker_url - self.queue_name = queue_name - self.test_value_list = [] - self.sent = 0 - self.confirmed = 0 - self.total = 0 - - def on_start(self, event): - """Event callback for when the client starts""" - connection = event.container.connect(url=self.broker_url, sasl_enabled=False) - event.container.create_sender(connection, target=self.queue_name) - - def on_sendable(self, event): - """Event callback for when send credit is received, allowing the sending of messages""" - if self.sent == 0: - for test_value in self.test_value_list: - if event.sender.credit: - message = self.create_message(test_value) - if message is not None: - event.sender.send(message) - self.sent += 1 - else: - event.connection.close() - return - - def create_message(self, test_value): - """ - Creates a single JMS message with the test value translated from its string representation to the appropriate - value (set in self.amqp_type). - """ - return None - - def on_accepted(self, event): - """Event callback for when a sent message is accepted by the broker""" - self.confirmed += 1 - if self.confirmed == self.total: - event.connection.close() - - def on_disconnected(self, event): - """Event callback for when the broker disconnects with the client""" - self.sent = self.confirmed - - - - -# --- main --- -# Args: 1: Broker address (ip-addr:port) -# 2: Queue name -# ... -try: - SENDER = JmsLargeContentTestSender(sys.argv[1], sys.argv[2]) - Container(SENDER).run() -except KeyboardInterrupt: - pass -except Exception as exc: - print os.path.basename(sys.argv[0]), 'EXCEPTION:', exc - print format_exc() http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/not_yet_impl/amqp_dtx_test.py ---------------------------------------------------------------------- diff --git a/src/python/not_yet_impl/amqp_dtx_test.py b/src/python/not_yet_impl/amqp_dtx_test.py deleted file mode 100644 index 7e4a644..0000000 --- a/src/python/not_yet_impl/amqp_dtx_test.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python - -""" -Module to test AMQP distributed transactions across different clients -""" - -# -# 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 sys -import unittest - -#from itertools import product -#from json import dumps -from os import getenv, path -#from time import mktime, time -#from uuid import UUID, uuid4 - -from proton import symbol -#import qpid_interop_test.broker_properties -import qpid_interop_test.shims -#from qpid_interop_test.test_type_map import TestTypeMap - -# TODO: propose a sensible default when installation details are worked out -QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') -if QPID_INTEROP_TEST_HOME is None: - print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' - sys.exit(1) - - -class AmqpDtxTestCase(unittest.TestCase): - """ - Abstract base class for AMQP distributed transactions (DTX) test cases - """ - - def run_test(self): - """ - 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. - """ - pass - - -# 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. -PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_dtx_test', - 'Receiver') -PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_dtx_test', - 'Sender') -PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', 'amqp_dtx_test', - 'Receiver.py') -PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', 'amqp_dtx_test', - 'Sender.py') - -SHIM_MAP = {qpid_interop_test.shims.ProtonCppShim.NAME: \ - qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), - qpid_interop_test.shims.ProtonPythonShim.NAME: \ - qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), - } - - -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 distrubuted (dtx) transactions') - parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', - help='Broker against which to run test suite.') - 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 = qpid_interop_test.broker_properties.get_broker_properties(ARGS.sender) - if CONNECTION_PROPS is None: - print 'WARNING: Unable to get connection properties - unknown broker' - BROKER = 'unknown' - else: - BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ - else '<product not found>' - BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ - else '<version not found>' - BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ - else '<platform not found>' - print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) - print - sys.stdout.flush() - - # 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 - - # Finally, run all the dynamically created tests - RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) - if not RES.wasSuccessful(): - sys.exit(1) # Errors or failures present http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/not_yet_impl/amqp_features_test.py ---------------------------------------------------------------------- diff --git a/src/python/not_yet_impl/amqp_features_test.py b/src/python/not_yet_impl/amqp_features_test.py deleted file mode 100644 index 83f140f..0000000 --- a/src/python/not_yet_impl/amqp_features_test.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env python - -""" -Module to test AMQP features across different clients -""" - -# -# 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 sys -import unittest - -from json import dumps -from os import getenv, path - -from proton import symbol -import qpid_interop_test.shims - -# TODO: propose a sensible default when installation details are worked out -QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') -if QPID_INTEROP_TEST_HOME is None: - print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' - sys.exit(1) - - -class AmqpFeaturesTestCase(unittest.TestCase): - """ - Abstract base class for AMQP message features test cases - """ - - def run_test(self, sender_addr, receiver_addr, test_type, 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. - """ - send_queue_name = 'jms.queue.qpid-interop.amqp_features_test.%s' % send_shim.NAME - receive_queue_name = 'jms.queue.qpid-interop.amqp_features_test.%s' % receive_shim.NAME - - # Start the receive shim first (for queueless brokers/dispatch) - receiver = receive_shim.create_receiver(receiver_addr, receive_queue_name, test_type, '0') - receiver.start() - - # Start the send shim - sender = send_shim.create_sender(sender_addr, send_queue_name, test_type, dumps([None])) - sender.start() - - # Wait for both shims to finish - sender.join_or_kill(qpid_interop_test.shims.THREAD_TIMEOUT) - receiver.join_or_kill(qpid_interop_test.shims.THREAD_TIMEOUT) - - if test_type == 'connection_property': - self.check_connection_property_test_results(sender.get_return_object(), receiver.get_return_object()) - - def check_connection_property_test_results(self, sender_return_obj, receiver_return_obj): - """Check received connection property for pass/fail of test""" - self.check_connection_properties(sender_return_obj[1], 'sender') - self.check_connection_properties(receiver_return_obj[1], 'receiver') - - def check_connection_properties(self, connection_properties, source): - """Check an individual connection property for pass/fail""" - keys = connection_properties.keys() - if 'product' not in keys: - self.fail('Broker connection properties (from %s) missing "product" key' % source) - if 'version' not in keys: - self.fail('Broker connection properties (from %s) missing "version" key' % source) - for key in keys: - self.assertTrue(len(connection_properties[key]) > 0, msg='Property "%s" (from %s) is empty' % (key, source)) - - -def create_connection_property_test_class(send_shim, receive_shim): - """ - Class factory function which creates new subclasses to AmqpFeaturesTestCase. - """ - - 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""" - - def inner_test_method(self): - self.run_test(self.sender_addr, self.receiver_addr, 'connection_property', send_shim, receive_shim) - - inner_test_method.__name__ = 'test_connection_properties_%s->%s' % (send_shim.NAME, receive_shim.NAME) - setattr(cls, inner_test_method.__name__, inner_test_method) - - class_name = 'ConnectionPropertyTestCase' - class_dict = {'__name__': class_name, - '__repr__': __repr__, - '__doc__': 'Test case for AMQP connection properties', - 'sender_addr': ARGS.sender, - 'receiver_addr': ARGS.receiver} - new_class = type(class_name, (AmqpFeaturesTestCase,), class_dict) - add_test_method(new_class, send_shim, receive_shim) - return new_class - -# 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. -PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_features_test', - 'Receiver') -PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', 'amqp_features_test', - 'Sender') -PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'amqp_features_test', 'Receiver.py') -PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'amqp_features_test', 'Sender.py') - -SHIM_MAP = {#qpid_interop_test.shims.ProtonCppShim.NAME: \ - # qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), - qpid_interop_test.shims.ProtonPythonShim.NAME: \ - qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), - } - - -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 messaging features') - parser.add_argument('--sender', action='store', default='localhost:5672', metavar='IP-ADDR:PORT', - help='Node to which test suite will send messages.') - parser.add_argument('--receiver', action='store', default='localhost:5672', metavar='IP-ADDR:PORT', - help='Node from which test suite will receive messages.') - 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 = qpid_interop_test.broker_properties.get_broker_properties(ARGS.sender) - if CONNECTION_PROPS is None: - print 'WARNING: Unable to get connection properties - unknown broker' - BROKER = 'unknown' - else: - BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ - else '<product not found>' - BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ - else '<version not found>' - BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ - else '<platform not found>' - print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) - print - sys.stdout.flush() - - # 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 shim_name in SHIM_MAP.keys(): - test_case_class = create_connection_property_test_class(SHIM_MAP[shim_name], SHIM_MAP[shim_name]) - 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(): - sys.exit(1) # Errors or failures present http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/not_yet_impl/jms_dtx_test.py ---------------------------------------------------------------------- diff --git a/src/python/not_yet_impl/jms_dtx_test.py b/src/python/not_yet_impl/jms_dtx_test.py deleted file mode 100644 index fd998a7..0000000 --- a/src/python/not_yet_impl/jms_dtx_test.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env python - -""" -Module to test JMS distributed transactions (DTX) across different JMS clients -""" - -# -# 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 sys -import unittest - -#from itertools import product -#from json import dumps -from os import getenv, path - -from proton import symbol -#import qpid_interop_test.broker_properties -import qpid_interop_test.shims -#from qpid_interop_test.test_type_map import TestTypeMap - - -# TODO: propose a sensible default when installation details are worked out -QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') -if QPID_INTEROP_TEST_HOME is None: - print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' - sys.exit(1) -MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository')) - - - -class JmsDtxTypeTestCase(unittest.TestCase): - """ - Abstract base class for JMS DTX 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. - """ - pass - - -PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', - 'jms_dtx_test', 'Receiver') -PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', - 'jms_dtx_test', 'Sender') -PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'jms_dtx_test', 'Receiver.py') -PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'jms_dtx_test', 'Sender.py') -QIT_JMS_CLASSPATH_FILE = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'cp.txt') -with open(QIT_JMS_CLASSPATH_FILE, 'r') as classpath_file: - QIT_JMS_CLASSPATH = classpath_file.read() -QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_dtx_test.Receiver' -QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_dtx_test.Sender' - -# 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 = {qpid_interop_test.shims.ProtonCppShim.NAME: \ - qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), - qpid_interop_test.shims.ProtonPythonShim.NAME: \ - qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), - qpid_interop_test.shims.QpidJmsShim.NAME: \ - qpid_interop_test.shims.QpidJmsShim(QIT_JMS_CLASSPATH, QPID_JMS_SENDER_SHIM, QPID_JMS_RECEIVER_SHIM), - } - -# 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,): - parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' - 'for JMS distrubuted (dtx) transactions') - parser.add_argument('--sender', action='store', default='localhost:5672', metavar='IP-ADDR:PORT', - help='Node to which test suite will send messages.') - parser.add_argument('--receiver', action='store', default='localhost:5672', metavar='IP-ADDR:PORT', - help='Node from which test suite will receive messages.') - 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 = qpid_interop_test.broker_properties.get_broker_properties(ARGS.sender) - if CONNECTION_PROPS is None: - print 'WARNING: Unable to get connection properties - unknown broker' - BROKER = 'unknown' - else: - BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ - else '<product not found>' - BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ - else '<version not found>' - BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ - else '<platform not found>' - print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) - print - sys.stdout.flush() - - # 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 - - # Finally, run all the dynamically created tests - RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) - if not RES.wasSuccessful(): - sys.exit(1) http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/not_yet_impl/jms_large_content_test.py ---------------------------------------------------------------------- diff --git a/src/python/not_yet_impl/jms_large_content_test.py b/src/python/not_yet_impl/jms_large_content_test.py deleted file mode 100644 index 6387060..0000000 --- a/src/python/not_yet_impl/jms_large_content_test.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python - -""" -Module to test JMS messages containing large content (either message bodies or properties) across different JMS clients -""" - -# -# 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 sys -import unittest - -#from itertools import product -#from json import dumps -from os import getenv, path - -from proton import symbol -#import qpid_interop_test.broker_properties -import qpid_interop_test.shims -#from qpid_interop_test.test_type_map import TestTypeMap - - -# TODO: propose a sensible default when installation details are worked out -QPID_INTEROP_TEST_HOME = getenv('QPID_INTEROP_TEST_HOME') -if QPID_INTEROP_TEST_HOME is None: - print 'ERROR: Environment variable QPID_INTEROP_TEST_HOME is not set' - sys.exit(1) -MAVEN_REPO_PATH = getenv('MAVEN_REPO_PATH', path.join(getenv('HOME'), '.m2', 'repository')) - - - -class JmsLargeContentTypeTestCase(unittest.TestCase): - """ - Abstract base class for JMS large content 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. - """ - pass - - -PROTON_CPP_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', - 'jms_large_content_test', 'Receiver') -PROTON_CPP_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-cpp', 'build', - 'jms_large_content_test', 'Sender') -PROTON_PYTHON_RECEIVER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'jms_large_content_test', 'Receiver.py') -PROTON_PYTHON_SENDER_SHIM = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-proton-python', 'src', - 'jms_large_content_test', 'Sender.py') -QIT_JMS_CLASSPATH_FILE = path.join(QPID_INTEROP_TEST_HOME, 'shims', 'qpid-jms', 'cp.txt') -with open(QIT_JMS_CLASSPATH_FILE, 'r') as classpath_file: - QIT_JMS_CLASSPATH = classpath_file.read() -QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_large_content_test.Receiver' -QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_large_content_test.Sender' - -# 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 = {qpid_interop_test.shims.ProtonCppShim.NAME: \ - qpid_interop_test.shims.ProtonCppShim(PROTON_CPP_SENDER_SHIM, PROTON_CPP_RECEIVER_SHIM), - qpid_interop_test.shims.ProtonPythonShim.NAME: \ - qpid_interop_test.shims.ProtonPythonShim(PROTON_PYTHON_SENDER_SHIM, PROTON_PYTHON_RECEIVER_SHIM), - qpid_interop_test.shims.QpidJmsShim.NAME: \ - qpid_interop_test.shims.QpidJmsShim(QIT_JMS_CLASSPATH, QPID_JMS_SENDER_SHIM, QPID_JMS_RECEIVER_SHIM), - } - -# 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,): - parser = argparse.ArgumentParser(description='Qpid-interop AMQP client interoparability test suite ' - 'for JMS messages containing large content') - parser.add_argument('--broker', action='store', default='localhost:5672', metavar='BROKER:PORT', - help='Broker against which to run test suite.') - 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 = qpid_interop_test.broker_properties.get_broker_properties(ARGS.broker) - if CONNECTION_PROPS is None: - print 'WARNING: Unable to get connection properties - unknown broker' - BROKER = 'unknown' - else: - BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ - else '<product not found>' - BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ - else '<version not found>' - BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ - else '<platform not found>' - print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) - print - sys.stdout.flush() - - # 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 - - # Finally, run all the dynamically created tests - RES = unittest.TextTestRunner(verbosity=2).run(TEST_SUITE) - if not RES.wasSuccessful(): - sys.exit(1) http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/qpid_interop_test/amqp_types_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/amqp_types_test.py b/src/python/qpid_interop_test/amqp_types_test.py index c54c977..9971c2c 100755 --- a/src/python/qpid_interop_test/amqp_types_test.py +++ b/src/python/qpid_interop_test/amqp_types_test.py @@ -259,9 +259,6 @@ class AmqpPrimitiveTypes(TestTypeMap): # This section contains tests that should be skipped because of know issues that would cause the test to fail. # As the issues are resolved, these should be removed. 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', - 'qpid-dispatch-router': 'router with qpid or activemq broker',}, 'decimal32': {'ActiveMQ': 'decimal32 and decimal64 sent byte reversed: PROTON-1160', 'qpid-cpp': 'decimal32 not supported on qpid-cpp broker: QPIDIT-5, QPID-6328', 'apache-activemq-artemis': 'decimal32 and decimal64 sent byte reversed: PROTON-1160', http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/qpid_interop_test/jms_hdrs_props_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_hdrs_props_test.py b/src/python/qpid_interop_test/jms_hdrs_props_test.py index b436162..0f3b16d 100755 --- a/src/python/qpid_interop_test/jms_hdrs_props_test.py +++ b/src/python/qpid_interop_test/jms_hdrs_props_test.py @@ -637,8 +637,8 @@ if __name__ == '__main__': else: QIT_JMS_CLASSPATH = path.join(QIT_TEST_SHIM_HOME, 'qpid-jms', 'qpid-interop-test-jms-shim-%s-jar-with-dependencies.jar' % QPID_JMS_SHIM_VER) - QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.qpid_interop_test.jms_hdrs_props_test.Receiver' - QPID_JMS_SENDER_SHIM = 'org.apache.qpid.qpid_interop_test.jms_hdrs_props_test.Sender' + QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_hdrs_props_test.Receiver' + QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_hdrs_props_test.Sender' # 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 http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/src/python/qpid_interop_test/jms_messages_test.py ---------------------------------------------------------------------- diff --git a/src/python/qpid_interop_test/jms_messages_test.py b/src/python/qpid_interop_test/jms_messages_test.py index 6a6f630..8fd6b48 100755 --- a/src/python/qpid_interop_test/jms_messages_test.py +++ b/src/python/qpid_interop_test/jms_messages_test.py @@ -344,8 +344,8 @@ if __name__ == '__main__': else: QIT_JMS_CLASSPATH = path.join(QIT_TEST_SHIM_HOME, 'qpid-jms', 'qpid-interop-test-jms-shim-%s-jar-with-dependencies.jar' % QPID_JMS_SHIM_VER) - QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.qpid_interop_test.jms_messages_test.Receiver' - QPID_JMS_SENDER_SHIM = 'org.apache.qpid.qpid_interop_test.jms_messages_test.Sender' + QPID_JMS_RECEIVER_SHIM = 'org.apache.qpid.interop_test.jms_messages_test.Receiver' + QPID_JMS_SENDER_SHIM = 'org.apache.qpid.interop_test.jms_messages_test.Sender' # 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 http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/utils/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java ---------------------------------------------------------------------- diff --git a/utils/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java b/utils/src/main/java/org/apache/qpid/interop_test/obj_util/BytesToJavaObj.java new file mode 100644 index 0000000..0d97333 --- /dev/null +++ b/utils/src/main/java/org/apache/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/4153bf17/utils/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java ---------------------------------------------------------------------- diff --git a/utils/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java b/utils/src/main/java/org/apache/qpid/interop_test/obj_util/JavaObjToBytes.java new file mode 100644 index 0000000..a16f0b1 --- /dev/null +++ b/utils/src/main/java/org/apache/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(); + } +} + http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/4153bf17/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 deleted file mode 100644 index 0d97333..0000000 --- a/utils/src/main/java/org/apache/qpid/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()); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org