コード例 #1
0
    def setUp(self):
        self.timeout = 5
        self.log = logging.getLogger("sender")
        self.mqm = messagequeue.MessageQueueManager()
        self.mqs = mqsecurity.MQPortal(self.mqm, None)
        self.mqm.set_queue_rights(queue_rights)

        self.factory = StompFactory(mqm=self.mqm)
        self.factory.mq_portal = self.mqs
        self.serverProtocol = self.factory.buildProtocol(None)
        self.serverProtocol.log = self.log
        self.client = StompClientProtocol('users', 'users')
        self.client.log = self.log
        self.loopbackBody = loopback.loopbackAsync(self.serverProtocol,
                                                   self.client)
コード例 #2
0
class MorbidTestCase(unittest.TestCase):
    def setUp(self):
        self.timeout = 5
        self.log = logging.getLogger("sender")
        self.mqm = messagequeue.MessageQueueManager()
        self.mqs = mqsecurity.MQPortal(self.mqm, None)
        self.mqm.set_queue_rights(queue_rights)

        self.factory = StompFactory(mqm=self.mqm)
        self.factory.mq_portal = self.mqs
        self.serverProtocol = self.factory.buildProtocol(None)
        self.serverProtocol.log = self.log
        self.client = StompClientProtocol('users', 'users')
        self.client.log = self.log
        self.loopbackBody = loopback.loopbackAsync(self.serverProtocol,
                                                   self.client)

    def waitForResponse(self, client, msg):
        d1 = self.listenForResponse(client, msg)
        client.send(msg, self.dest)
        return d1

    def listenForResponse(self, client, msg):
        d1 = defer.Deferred()
        d1.addCallback(self.gotResponse)
        d1.addErrback(self.msgError)
        client.expects.add_emsg(msg, d1)
        return d1

    def gotResponse(self, msg):
        if 'done' in msg['body']:
            self.client.transport.loseConnection()
        #return er == msg['body']

    def msgError(self, *args):
        return args[0]

    def waitForErrorMsg(self, client, msg, err):
        d1 = self.listenForErrorMsg(client, err)
        client.send(msg, self.dest)
        return d1

    def listenForErrorMsg(self, client, err):
        d1 = defer.Deferred()
        d1.addCallback(self.gotError)
        d1.addErrback(self.msgError)
        client.expects.add_emsg(err, d1)
        return d1

    def gotError(self, msg):
        self.assertEquals(msg['cmd'], 'ERROR')
コード例 #3
0
ファイル: test_morbid.py プロジェクト: NicolaeNMV/Tsunami
    def setUp(self):
        self.timeout = 5
        self.log = logging.getLogger("sender")
        self.mqm = messagequeue.MessageQueueManager()
        self.mqs = mqsecurity.MQPortal(self.mqm, None)
        self.mqm.set_queue_rights(queue_rights)
 
        self.factory = StompFactory(mqm=self.mqm)
        self.factory.mq_portal = self.mqs
        self.serverProtocol = self.factory.buildProtocol(None)
        self.serverProtocol.log = self.log
        self.client = StompClientProtocol('users','users')
        self.client.log = self.log
        self.loopbackBody = loopback.loopbackAsync(self.serverProtocol, self.client)
コード例 #4
0
ファイル: test_morbid.py プロジェクト: NicolaeNMV/Tsunami
class MorbidTestCase(unittest.TestCase):
    def setUp(self):
        self.timeout = 5
        self.log = logging.getLogger("sender")
        self.mqm = messagequeue.MessageQueueManager()
        self.mqs = mqsecurity.MQPortal(self.mqm, None)
        self.mqm.set_queue_rights(queue_rights)
 
        self.factory = StompFactory(mqm=self.mqm)
        self.factory.mq_portal = self.mqs
        self.serverProtocol = self.factory.buildProtocol(None)
        self.serverProtocol.log = self.log
        self.client = StompClientProtocol('users','users')
        self.client.log = self.log
        self.loopbackBody = loopback.loopbackAsync(self.serverProtocol, self.client)

    def waitForResponse(self, client, msg):
        d1 = self.listenForResponse(client, msg)
        client.send(msg, self.dest)
        return d1

    def listenForResponse(self, client, msg):
        d1 = defer.Deferred()
        d1.addCallback(self.gotResponse)
        d1.addErrback(self.msgError)
        client.expects.add_emsg(msg, d1)
        return d1
    
    def gotResponse(self, msg):
        if 'done' in msg['body']:
            self.client.transport.loseConnection()
        #return er == msg['body']
            
    def msgError(self, *args):
        return args[0]

    def waitForErrorMsg(self, client, msg, err):
        d1 = self.listenForErrorMsg(client, err)
        client.send(msg, self.dest)
        return d1
    
    def listenForErrorMsg(self, client, err):
        d1 = defer.Deferred()
        d1.addCallback(self.gotError)
        d1.addErrback(self.msgError)
        client.expects.add_emsg(err, d1)
        return d1
        
    def gotError(self, msg):
        self.assertEquals(msg['cmd'], 'ERROR')