Пример #1
0
    def test_put_rfh2_single(self):
        """Create and put a new rfh2 and use get to get it from the queue.  Compare it against know correct message.
        """
        try:

            put_mqmd = pymqi.md()
            put_mqmd["Format"] = CMQC.MQFMT_RF_HEADER_2
            put_mqmd["Encoding"] = 273
            put_mqmd["CodedCharSetId"] = 1208

            put_opts = pymqi.pmo()

            put_rfh2 = pymqi.RFH2()
            put_rfh2["StrucId"] = CMQC.MQRFH_STRUC_ID
            put_rfh2["Version"] = CMQC.MQRFH_VERSION_2
            put_rfh2["StrucLength"] = 188
            put_rfh2["Encoding"] = 273
            put_rfh2["CodedCharSetId"]= 1208
            put_rfh2["Format"] =  CMQC.MQFMT_STRING
            put_rfh2["Flags"] = 0
            put_rfh2["NameValueCCSID"] = 1208
            put_rfh2.add_folder("<psc><Command>RegSub</Command><Topic>$topictree/topiccat/topic</Topic><QMgrName>DebugQM</QMgrName><QName>PUBOUT</QName><RegOpt>PersAsPub</RegOpt></psc>")
            put_rfh2.add_folder("<testFolder><testVar>testValue</testVar></testFolder>")
            put_rfh2.add_folder("<mcd><Msd>xmlnsc</Msd></mcd>")
            put_msg = "<testData><testVar>testValue</testVar></testData>"
            self.put_queue.put_rfh2(put_msg, put_mqmd, put_opts, [put_rfh2])

            get_mqmd = pymqi.md()
            get_opts = pymqi.gmo()
            get_msg = self.get_queue.get(None, get_mqmd, get_opts)

            self.assertEqual(get_msg, self.single_rfh2_message, "Message got from Queue does not match known correct RFH2 message.")
        except Exception as e:
            self.fail(e)
Пример #2
0
    def test_put_get_rfh2_multiple(self):
        """Create and put a new RFH2 message containing multiple RFH2 headers with put_rfh2 and use get_rfh2 to get it from the queue.  Compare it against know correct message.
        """

        try:
            put_mqmd = pymqi.md()
            put_mqmd["Format"] = CMQC.MQFMT_RF_HEADER_2
            put_mqmd["Encoding"] = 273
            put_mqmd["CodedCharSetId"] = 1208

            put_opts = pymqi.pmo()

            put_rfh2_1 = pymqi.RFH2()
            put_rfh2_1["StrucId"] = CMQC.MQRFH_STRUC_ID
            put_rfh2_1["Version"] = CMQC.MQRFH_VERSION_2
            put_rfh2_1["StrucLength"] = 188
            put_rfh2_1["Encoding"] = 273
            put_rfh2_1["CodedCharSetId"]= 1208
            put_rfh2_1["Format"] =  CMQC.MQFMT_RF_HEADER_2
            put_rfh2_1["Flags"] = 0
            put_rfh2_1["NameValueCCSID"] = 1208
            put_rfh2_1.add_folder("<psc><Command>RegSub</Command><Topic>$topictree/topiccat/topic</Topic><QMgrName>DebugQM</QMgrName><QName>PUBOUT</QName><RegOpt>PersAsPub</RegOpt></psc>")
            put_rfh2_1.add_folder("<testFolder><testVar>testValue</testVar></testFolder>")

            put_rfh2_2 = pymqi.RFH2()
            put_rfh2_2["StrucId"] = CMQC.MQRFH_STRUC_ID
            put_rfh2_2["Version"] = CMQC.MQRFH_VERSION_2
            put_rfh2_2["StrucLength"] = 188
            put_rfh2_2["Encoding"] = 273
            put_rfh2_2["CodedCharSetId"]= 1208
            put_rfh2_2["Format"] =  CMQC.MQFMT_STRING
            put_rfh2_2["Flags"] = 0
            put_rfh2_2["NameValueCCSID"] = 1208
            put_rfh2_2.add_folder("<psc><Command>RegSub</Command><Topic>$topictree/topiccat/topic</Topic><QMgrName>DebugQM</QMgrName><QName>PUBOUT</QName><RegOpt>PersAsPub</RegOpt></psc>")
            put_rfh2_2.add_folder("<testFolder><testVar>testValue</testVar></testFolder>")
            put_rfh2_2.add_folder("<mcd><Msd>xmlnsc</Msd></mcd>")
            put_rfh2_list = [put_rfh2_1, put_rfh2_2]
            put_msg = "<testData><testVar>testValue</testVar></testData>"

            self.put_queue.put_rfh2(put_msg, put_mqmd, put_opts, put_rfh2_list)

            get_mqmd = pymqi.md()
            get_opts = pymqi.gmo()
            get_rfh2_list = []
            get_msg = self.get_queue.get_rfh2(None, get_mqmd, get_opts, get_rfh2_list)

            self.assertEqual(len(get_rfh2_list), len(put_rfh2_list), "Number of RFH2's incorrect.  Should be %i.  But is %i" % (len(get_rfh2_list), len(put_rfh2_list)))
            self.assertEqual(get_rfh2_list[0].get(), put_rfh2_list[0].get()), "Put and Get RFH2 Lists do not match."
            self.assertEqual(get_rfh2_list[1].get(), put_rfh2_list[1].get()), "Put and Get RFH2 Lists do not match."
            self.assertEqual(get_msg, put_msg, "Put and Get messages do not match.")

        except Exception as e:
            self.fail(e)
Пример #3
0
    def test_pubsub_api_managed_non_durable_rfh2(self):
        topic_string = self.topic_string_template.format(type="API_RFH2",
                                                         destination="MANAGED",
                                                         durable="NON DURABLE")
        subname = self.subname_template.format(type="Api_rfh2",
                                               destination="Managed",
                                               durable="Non Durable")
        msg = self.msg_format(topic_string=topic_string)
        sub_desc = self.get_subscription_descriptor(
            subname, topic_string,
            pymqi.CMQC.MQSO_CREATE + pymqi.CMQC.MQSO_MANAGED)
        # register Subscription
        sub = self.create_api_subscription()
        self.sub_desc_list = [(sub, sub_desc, None)]
        sub.sub(sub_desc=sub_desc)

        # publish (put)
        put_mqmd = pymqi.md(Format=pymqi.CMQC.MQFMT_RF_HEADER_2,
                            Encoding=273,
                            CodedCharSetId=1208)

        put_opts = pymqi.pmo()

        put_rfh2 = pymqi.RFH2(StrucId=pymqi.CMQC.MQRFH_STRUC_ID,
                              Version=pymqi.CMQC.MQRFH_VERSION_2,
                              StrucLength=188,
                              Encoding=273,
                              CodedCharSetId=1208,
                              Format=pymqi.CMQC.MQFMT_STRING,
                              Flags=0,
                              NameValueCCSID=1208)
        put_rfh2.add_folder(
            b"<psc><Command>RegSub</Command><Topic>$topictree/topiccat/topic</Topic><QMgrName>DebugQM</QMgrName><QName>PUBOUT</QName><RegOpt>PersAsPub</RegOpt></psc>"
        )
        put_rfh2.add_folder(
            b"<testFolder><testVar>testValue</testVar></testFolder>")
        put_rfh2.add_folder(b"<mcd><Msd>xmlnsc</Msd></mcd>")

        self.pub_rfh2(msg, topic_string, put_mqmd, put_opts, [put_rfh2])
        get_opts = pymqi.GMO(Version=pymqi.CMQC.MQGMO_VERSION_4,
                             WaitInterval=15000,
                             Options=pymqi.CMQC.MQGMO_NO_SYNCPOINT + \
                                    pymqi.CMQC.MQGMO_FAIL_IF_QUIESCING + \
                                    pymqi.CMQC.MQGMO_WAIT)
        get_rfh2_list = []
        data = sub.get_rfh2(None, pymqi.md(Version=pymqi.CMQC.MQMD_VERSION_2),
                            get_opts, get_rfh2_list)
        sub.close(sub_close_options=0, close_sub_queue=True)
        self.assertEqual(data, msg)
Пример #4
0
	def put (self, queue, message, replyTo = '', ApplIdentityData = ''):

		od = pymqi.od()
		od.ObjectName = queue

		q = pymqi.Queue(self.qmgr)
		q.open(od, CMQC.MQOO_OUTPUT | CMQC.MQOO_SET_ALL_CONTEXT)		

		pmo = pymqi.pmo()
		pmo.Options = CMQC.MQPMO_SET_ALL_CONTEXT

		md = pymqi.MD()

		md.ReplyToQ         = replyTo
		md.ReplyToQMgr      = self.queue_manager
		md.ApplIdentityData = ApplIdentityData
		md.Format           = 'MQSTR'

		q.put(message, md, pmo)
		q.close()
        queue_manager = param.WQ_Manager
        channel = param.WQ_Channel
        host = param.Write_Host
        port = param.Write_Port
        queue_name = param.Write_Queue
        conn_info = "%s(%s)" % (host, port)
        #print conn_info

        #header options
        put_mqmd = pymqi.md()
        put_mqmd["Format"] = CMQC.MQFMT_RF_HEADER_2
        put_mqmd["Encoding"] = 273
        put_mqmd["CodedCharSetId"] = 1208

        put_opts = pymqi.pmo()

        put_rfh2 = pymqi.RFH2()
        put_rfh2["StrucId"] = CMQC.MQRFH_STRUC_ID
        put_rfh2["Version"] = CMQC.MQRFH_VERSION_2
        put_rfh2["StrucLength"] = 188
        put_rfh2["Encoding"] = 273
        put_rfh2["CodedCharSetId"] = 1208
        put_rfh2["Format"] = CMQC.MQFMT_STRING
        put_rfh2["Flags"] = 0
        put_rfh2["NameValueCCSID"] = 819

        #header options

        #put folders
        put_rfh2.add_folder("<mcd><Msd>none</Msd></mcd>")
        queue_manager = param.WQ_Manager
        channel = param.WQ_Channel
        host = param.Write_Host
        port = param.Write_Port
        queue_name = param.Write_Queue
        conn_info = "%s(%s)" % (host, port)
        #print conn_info

        #header options
        put_mqmd = pymqi.md()
        put_mqmd["Format"] = CMQC.MQFMT_RF_HEADER_2
        put_mqmd["Encoding"] = 273
        put_mqmd["CodedCharSetId"] = 1208

        put_opts = pymqi.pmo()

        put_rfh2 = pymqi.RFH2()
        put_rfh2["StrucId"] = CMQC.MQRFH_STRUC_ID
        put_rfh2["Version"] = CMQC.MQRFH_VERSION_2
        put_rfh2["StrucLength"] = 188
        put_rfh2["Encoding"] = 273
        put_rfh2["CodedCharSetId"]= 1208
        put_rfh2["Format"] =  CMQC.MQFMT_STRING
        put_rfh2["Flags"] = 0
        put_rfh2["NameValueCCSID"] = 819

        #header options

        #put folders
        put_rfh2.add_folder("<mcd><Msd>none</Msd></mcd>")