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/26 19:20:22 UTC

qpid-interop-test git commit: QPIDIT-33: WIP: Added JMS Message type (which has no body) to tests. Updates to QUICKSTART file.

Repository: qpid-interop-test
Updated Branches:
  refs/heads/master b37d02fd4 -> 422f55593


QPIDIT-33: WIP: Added JMS Message type (which has no body) to tests. Updates to QUICKSTART file.


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/422f5559
Tree: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/tree/422f5559
Diff: http://git-wip-us.apache.org/repos/asf/qpid-interop-test/diff/422f5559

Branch: refs/heads/master
Commit: 422f55593a194c887eac6c659cb86d13039b7ee5
Parents: b37d02f
Author: Kim van der Riet <kp...@apache.org>
Authored: Thu May 26 15:20:07 2016 -0400
Committer: Kim van der Riet <kp...@apache.org>
Committed: Thu May 26 15:20:07 2016 -0400

----------------------------------------------------------------------
 QUICKSTART                                      | 10 +++++--
 .../qpid_interop_test/shim/JmsReceiverShim.java | 10 +++++--
 .../qpid_interop_test/shim/JmsSenderShim.java   | 23 +++++++++++++--
 .../src/qpidit/shim/JmsReceiver.cpp             |  2 +-
 .../src/qpidit/shim/JmsSender.cpp               | 16 ++++++++++-
 .../src/qpidit/shim/JmsSender.hpp               |  1 +
 shims/qpid-proton-python/src/JmsReceiverShim.py | 10 +++++++
 shims/qpid-proton-python/src/JmsSenderShim.py   | 16 ++++++++++-
 .../qpid-interop-test/jms/jms_message_tests.py  | 30 ++++++++++----------
 .../types/simple_type_tests.py                  |  2 ++
 10 files changed, 94 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/QUICKSTART
----------------------------------------------------------------------
diff --git a/QUICKSTART b/QUICKSTART
index bfd2402..91a8cf2 100644
--- a/QUICKSTART
+++ b/QUICKSTART
@@ -59,13 +59,19 @@ reflect installation details when complete.
 
 Select one of the following two options:
 
-a. qpid-proton installed:
+a. qpid-proton installed (default install location):
 Assuming proton's "make install" has been run, from top level qpid-interop-test directory:
 export PYTHONPATH=/usr/local/lib64/proton/bindings/python:src/py/qpid-interop-test
 export LD_LIBRARY_PATH=/usr/local/lib64
 export QPID_INTEROP_TEST_HOME=<abs path to top level qpid-interop-test directory>
 
-b. qpid-proton built but not installed:
+b. qpid-proton installed to local directory <abs-path-to-local-proton-install-dir>:
+Assuming proton's "make install" has been run, from top level qpid-interop-test directory:
+export PYTHONPATH=<abs-path-to-local-proton-install-dir>/lib64/proton/bindings/python:src/py/qpid-interop-test
+export LD_LIBRARY_PATH=<abs-path-to-local-proton-install-dir>/lib64
+export QPID_INTEROP_TEST_HOME=<abs path to top level qpid-interop-test directory>
+
+c. 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/python/qpid-interop-test
 export LD_LIBRARY_PATH=<abs path to top level qpid-proton directory>/build/proton-c

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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 6cdb886..1c257de 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
@@ -49,7 +49,8 @@ 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",
+    private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_MESSAGE_TYPE",
+                                                                 "JMS_BYTESMESSAGE_TYPE",
                                                                  "JMS_MAPMESSAGE_TYPE",
                                                                  "JMS_OBJECTMESSAGE_TYPE",
                                                                  "JMS_STREAMMESSAGE_TYPE",
@@ -69,7 +70,7 @@ public class JmsReceiverShim {
         String queueName = args[1];
         String jmsMessageType = args[2];
         if (!isSupportedJmsMessageType(jmsMessageType)) {
-            System.out.println("ERROR: JmsReceiverShim: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+            System.out.println("ERROR: JmsReceiverShim: Unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
             System.exit(1);
         }
 
@@ -103,6 +104,9 @@ public class JmsReceiverShim {
                     message = messageConsumer.receive(TIMEOUT);
                     if (message == null) break;
                     switch (jmsMessageType) {
+                    case "JMS_MESSAGE_TYPE":
+                        jab.addNull();
+                        break;
                     case "JMS_BYTESMESSAGE_TYPE":
                         switch (key) {
                         case "boolean":
@@ -264,7 +268,7 @@ public class JmsReceiverShim {
                         break;
                     default:
                         connection.close();
-                        throw new Exception("JmsReceiverShim: Internal error: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+                        throw new Exception("JmsReceiverShim: Internal error: Unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
                     }
                 }
                 job.add(key, jab);

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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 b68583c..2c6281e 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
@@ -46,7 +46,8 @@ 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",
+    private static final String[] SUPPORTED_JMS_MESSAGE_TYPES = {"JMS_MESSAGE_TYPE",
+                                                                 "JMS_BYTESMESSAGE_TYPE",
                                                                  "JMS_MAPMESSAGE_TYPE",
                                                                  "JMS_OBJECTMESSAGE_TYPE",
                                                                  "JMS_STREAMMESSAGE_TYPE",
@@ -66,7 +67,7 @@ public class JmsSenderShim {
         String queueName = args[1];
         String jmsMessageType = args[2];
         if (!isSupportedJmsMessageType(jmsMessageType)) {
-            System.out.println("ERROR: JmsReceiver: unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
+            System.out.println("ERROR: JmsSender: Unknown or unsupported JMS message type \"" + jmsMessageType + "\"");
             System.exit(1);
         }
 
@@ -93,8 +94,14 @@ public class JmsSenderShim {
             for (String key: keyList) {
                 JsonArray testValues = testValuesMap.getJsonArray(key);
                 for (int i=0; i<testValues.size(); ++i) {
-                    String testValue = testValues.getJsonString(i).getString();
+                    String testValue = "";
+                    if (!testValues.isNull(i)) {
+                        testValue = testValues.getJsonString(i).getString();
+                    }
                     switch (jmsMessageType) {
+                    case "JMS_MESSAGE_TYPE":
+                        message = createMessage(session, key, testValue);
+                        break;
                     case "JMS_BYTESMESSAGE_TYPE":
                         message = createBytesMessage(session, key, testValue);
                         break;
@@ -124,6 +131,16 @@ public class JmsSenderShim {
         }
     }
 
+    protected static Message createMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
+        if (testValueType.compareTo("none") != 0) {
+            throw new Exception("Internal exception: Unexpected JMS message sub-type \"" + testValueType + "\"");
+        }
+        if (testValue.length() > 0) {
+            throw new Exception("Internal exception: Unexpected JMS message value \"" + testValue + "\" for sub-type \"" + testValueType + "\"");
+        }
+        return session.createMessage();
+    }
+
     protected static BytesMessage createBytesMessage(Session session, String testValueType, String testValue) throws Exception, JMSException {
         BytesMessage message = session.createBytesMessage();
         switch (testValueType) {

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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 845c39d..5026f80 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsReceiver.cpp
@@ -115,7 +115,7 @@ namespace qpidit
         // protected
 
         void JmsReceiver::receiveJmsMessage(const proton::message& msg) {
-            // TODO: use this format for testing message JMS properties
+            _receivedSubTypeList.append(Json::Value());
         }
 
         void JmsReceiver::receiveJmsObjectMessage(const proton::message& msg) {

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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 66bedb9..2d26f30 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.cpp
@@ -90,7 +90,9 @@ namespace qpidit
             for (Json::Value::const_iterator i=testValues.begin(); i!=testValues.end(); ++i) {
                 if (s.credit()) {
                     proton::message msg;
-                    if (_jmsMessageType.compare("JMS_BYTESMESSAGE_TYPE") == 0) {
+                    if (_jmsMessageType.compare("JMS_MESSAGE_TYPE") == 0) {
+                        setMessage(msg, subType, (*i).asString());
+                    } else if (_jmsMessageType.compare("JMS_BYTESMESSAGE_TYPE") == 0) {
                         setBytesMessage(msg, subType, (*i).asString());
                     } else if (_jmsMessageType.compare("JMS_MAPMESSAGE_TYPE") == 0) {
                         setMapMessage(msg, subType, (*i).asString(), valueNumber);
@@ -111,6 +113,18 @@ namespace qpidit
 
         }
 
+        proton::message& JmsSender::setMessage(proton::message& msg, const std::string& subType, const std::string& testValueStr) {
+            if (subType.compare("none") != 0) {
+                throw qpidit::UnknownJmsMessageSubTypeError(subType);
+            }
+            if (testValueStr.size() != 0) {
+                throw InvalidTestValueError(subType, testValueStr);
+            }
+            msg.content_type(proton::symbol("application/octet-stream"));
+            msg.message_annotations()[proton::symbol("x-opt-jms-msg-type")] = s_jmsMessageTypeAnnotationValues["JMS_MESSAGE_TYPE"];
+            return msg;
+        }
+
         proton::message& JmsSender::setBytesMessage(proton::message& msg, const std::string& subType, const std::string& testValueStr) {
             proton::binary bin;
             if (subType.compare("boolean") == 0) {

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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 ef43dcb..800a720 100644
--- a/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
+++ b/shims/qpid-proton-cpp/src/qpidit/shim/JmsSender.hpp
@@ -57,6 +57,7 @@ namespace qpidit
             void on_transport_close(proton::transport &t);
         protected:
             void  sendMessages(proton::sender &s, const std::string& subType, const Json::Value& testValueMap);
+            proton::message& setMessage(proton::message& msg, const std::string& subType, const std::string& testValueStr);
             proton::message& setBytesMessage(proton::message& msg, const std::string& subType, const std::string& testValueStr);
             proton::message& setMapMessage(proton::message& msg, const std::string& subType, const std::string& testValueStr, uint32_t valueNumber);
             proton::message& setObjectMessage(proton::message& msg, const std::string& subType, const Json::Value& testValue);

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/shims/qpid-proton-python/src/JmsReceiverShim.py
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-python/src/JmsReceiverShim.py b/shims/qpid-proton-python/src/JmsReceiverShim.py
index 0ad4425..3a785a7 100755
--- a/shims/qpid-proton-python/src/JmsReceiverShim.py
+++ b/shims/qpid-proton-python/src/JmsReceiverShim.py
@@ -69,6 +69,8 @@ class JmsReceiverShim(MessagingHandler):
                 event.connection.close()
 
     def _handle_message(self, message):
+        if self.jms_msg_type == 'JMS_MESSAGE_TYPE':
+            return self._receive_jms_message(message)
         if self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
             return self._receive_jms_bytesmessage(message)
         if self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
@@ -88,6 +90,14 @@ class JmsReceiverShim(MessagingHandler):
             total += int(self.expteced_msg_map[key])
         return total
 
+    def _receive_jms_message(self, message):
+        assert self.jms_msg_type == 'JMS_MESSAGE_TYPE'
+        assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(0)
+        if message.body is not None:
+            raise InteropTestError('_receive_jms_message: Invalid body for type JMS_MESSAGE_TYPE: %s' %
+                                   str(message.body))
+        return None
+
     def _receive_jms_bytesmessage(self, message):
         assert self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE'
         assert message.annotations[QPID_JMS_TYPE_ANNOTATION_NAME] == byte(3)

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/shims/qpid-proton-python/src/JmsSenderShim.py
----------------------------------------------------------------------
diff --git a/shims/qpid-proton-python/src/JmsSenderShim.py b/shims/qpid-proton-python/src/JmsSenderShim.py
index 7a4cf1d..8eff079 100755
--- a/shims/qpid-proton-python/src/JmsSenderShim.py
+++ b/shims/qpid-proton-python/src/JmsSenderShim.py
@@ -32,6 +32,7 @@ from traceback import format_exc
 # org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport
 QPID_JMS_TYPE_ANNOTATION_NAME = symbol(u'x-opt-jms-msg-type')
 QPID_JMS_TYPE_ANNOTATIONS = {
+    'JMS_MESSAGE_TYPE': byte(0),
     'JMS_BYTESMESSAGE_TYPE': byte(3),
     'JMS_MAPMESSAGE_TYPE': byte(2),
     'JMS_OBJECTMESSAGE_TYPE': byte(1),
@@ -91,7 +92,9 @@ class JmsSenderShim(MessagingHandler):
 
     # TODO: Change this to return a list of messages. That way each test can return more than one message
     def _create_message(self, test_value_type, test_value, value_num):
-        if self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
+        if self.jms_msg_type == 'JMS_MESSAGE_TYPE':
+            return self._create_jms_message(test_value_type, test_value)
+        elif self.jms_msg_type == 'JMS_BYTESMESSAGE_TYPE':
             return self._create_jms_bytesmessage(test_value_type, test_value)
         elif self.jms_msg_type == 'JMS_MAPMESSAGE_TYPE':
             return self._create_jms_mapmessage(test_value_type, test_value, "%s%03d" % (test_value_type, value_num))
@@ -105,6 +108,17 @@ class JmsSenderShim(MessagingHandler):
             print 'jms-send: Unsupported JMS message type "%s"' % self.jms_msg_type
             return None
 
+    def _create_jms_message(self, test_value_type, test_value):
+        if test_value_type != 'none':
+            raise InteropTestError('JmsSenderShim._create_jms_message: Unknown or unsupported subtype "%s"' %
+                                   test_value_type)
+        if test_value is not None:
+            raise InteropTestError('JmsSenderShim._create_jms_message: Invalid value "%s" for subtype "%s"' %
+                                   (test_value, test_value_type))
+        return Message(id=(self.sent+1),
+                       content_type='application/octet-stream',
+                       annotations=create_annotation('JMS_MESSAGE_TYPE'))
+
     def _create_jms_bytesmessage(self, test_value_type, test_value):
         # NOTE: test_value contains all unicode strings u'...' as returned by json
         body_bytes = None

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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
index 432b1fd..e487617 100755
--- a/src/python/qpid-interop-test/jms/jms_message_tests.py
+++ b/src/python/qpid-interop-test/jms/jms_message_tests.py
@@ -121,6 +121,7 @@ class JmsMessageTypes(TestTypeMap):
         }
 
     TYPE_MAP = {
+        'JMS_MESSAGE_TYPE': {'none': [None]},
         'JMS_BYTESMESSAGE_TYPE': TYPE_SUBMAP,
         'JMS_MAPMESSAGE_TYPE': TYPE_SUBMAP,
 #        'JMS_OBJECTMESSAGE_TYPE': {
@@ -189,23 +190,21 @@ class JmsMessageTypeTestCase(unittest.TestCase):
         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 = {}
+        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 = {}
+        if (len(test_values) > 0):
             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))
+        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.fail('Type %s has no test values' % jms_message_type)
+            self.assertEqual(receive_text, test_values, msg='\n    sent:%s\n\n    received:%s' % \
+                             (test_values, receive_text))
 
 
 def create_testcase_class(broker_name, types, broker_addr, jms_message_type, shim_product):
@@ -408,7 +407,8 @@ if __name__ == '__main__':
     # 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)}
+                ProtonPythonShim.NAME: ProtonPythonShim(ARGS)
+                }
 
     # Connect to broker to find broker type
     CONNECTION_PROPS = broker_properties.getBrokerProperties(ARGS.broker)

http://git-wip-us.apache.org/repos/asf/qpid-interop-test/blob/422f5559/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
index 914cf8b..17adaaf 100755
--- a/src/python/qpid-interop-test/types/simple_type_tests.py
+++ b/src/python/qpid-interop-test/types/simple_type_tests.py
@@ -203,6 +203,8 @@ class AmqpPrimitiveTypes(TestTypeMap):
 #                  ]
         }
 
+# TODO: Type 'unknown' corresponds to the Artemis broker at present because it does not return connection
+# properties that can identify it.  When this is fixed in Artemis, this will no longer work.
     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',


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