Beispiel #1
0
    def test_session_nack(self):
        session = StompSession(version=StompSpec.VERSION_1_1, check=False)
        frame_ = lambda h: StompFrame(
            StompSpec.MESSAGE, h, version=StompSpec.VERSION_1_1)
        for headers in [{
                StompSpec.MESSAGE_ID_HEADER: '4711',
                StompSpec.SUBSCRIPTION_HEADER: 'bla'
        }, {
                StompSpec.MESSAGE_ID_HEADER: '4711',
                StompSpec.SUBSCRIPTION_HEADER: 'bla',
                'foo': 'bar'
        }]:
            self.assertEqual(session.nack(frame_(headers)),
                             commands.nack(frame_(headers)))

        headers = {
            StompSpec.MESSAGE_ID_HEADER: '4711',
            StompSpec.SUBSCRIPTION_HEADER: 'bla'
        }
        self.assertEqual(session.nack(frame_(headers), receipt='4711'),
                         commands.nack(frame_(headers), receipt='4711'))

        self.assertRaises(StompProtocolError, session.nack, frame_({}))
        self.assertRaises(StompProtocolError, session.nack,
                          frame_({StompSpec.MESSAGE_ID_HEADER: '4711'}))
        self.assertRaises(StompProtocolError, session.nack,
                          frame_({StompSpec.SUBSCRIPTION_HEADER: 'bla'}))

        session = StompSession(version=StompSpec.VERSION_1_1)
        self.assertRaises(
            StompProtocolError, lambda: session.nack(
                frame_({
                    StompSpec.MESSAGE_ID_HEADER: '4711',
                    StompSpec.SUBSCRIPTION_HEADER: 'bla'
                })))
Beispiel #2
0
 def test_nack(self):
     self.assertEquals(commands.nack(StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1)), StompFrame(command=StompSpec.NACK, headers={StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1))
     self.assertEquals(commands.nack(StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1), receipt='4711'), StompFrame(command=StompSpec.NACK, headers={StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there', StompSpec.RECEIPT_HEADER: '4711'}, version=StompSpec.VERSION_1_1))
     self.assertEquals(commands.nack(StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there', StompSpec.TRANSACTION_HEADER: 'man'}, version=StompSpec.VERSION_1_1)), StompFrame(command=StompSpec.NACK, headers={StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1))
     self.assertEquals(commands.nack(StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there', StompSpec.TRANSACTION_HEADER: 'man'}, version=StompSpec.VERSION_1_1), transactions=['woman']), StompFrame(command=StompSpec.NACK, headers={StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1))
     self.assertEquals(commands.nack(StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there', '4711': '0815'}, version=StompSpec.VERSION_1_1)), StompFrame(command=StompSpec.NACK, headers={StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_1))
     self.assertRaises(StompProtocolError, commands.nack, StompFrame(StompSpec.CONNECTED, {}, version=StompSpec.VERSION_1_1))
     self.assertRaises(StompProtocolError, commands.nack, StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there'}, version=StompSpec.VERSION_1_0))
     self.assertRaises(StompProtocolError, commands.nack, StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi', StompSpec.SUBSCRIPTION_HEADER: 'there', StompSpec.TRANSACTION_HEADER: 'man'}, version=StompSpec.VERSION_1_0))
     self.assertRaises(StompProtocolError, commands.nack, StompFrame(StompSpec.MESSAGE, {StompSpec.SUBSCRIPTION_HEADER: 'hi'}, version=StompSpec.VERSION_1_1))
     self.assertRaises(StompProtocolError, commands.nack, StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi'}, version=StompSpec.VERSION_1_1))
Beispiel #3
0
    def test_session_nack(self):
        session = StompSession(version=StompSpec.VERSION_1_1, check=False)
        frame_ = lambda h: StompFrame(StompSpec.MESSAGE, h, version=StompSpec.VERSION_1_1)
        for headers in [
            {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.SUBSCRIPTION_HEADER: 'bla'},
            {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.SUBSCRIPTION_HEADER: 'bla', 'foo': 'bar'}
        ]:
            self.assertEqual(session.nack(frame_(headers)), commands.nack(frame_(headers)))

        headers = {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.SUBSCRIPTION_HEADER: 'bla'}
        self.assertEqual(session.nack(frame_(headers), receipt='4711'), commands.nack(frame_(headers), receipt='4711'))

        self.assertRaises(StompProtocolError, session.nack, frame_({}))
        self.assertRaises(StompProtocolError, session.nack, frame_({StompSpec.MESSAGE_ID_HEADER: '4711'}))
        self.assertRaises(StompProtocolError, session.nack, frame_({StompSpec.SUBSCRIPTION_HEADER: 'bla'}))

        session = StompSession(version=StompSpec.VERSION_1_1)
        self.assertRaises(StompProtocolError, lambda: session.nack(frame_({StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.SUBSCRIPTION_HEADER: 'bla'})))
 def test_stomp_version_1_1(self):
     destination = '/queue/foo'
     stomp = self._get_transport_mock(config=StompConfig('tcp://%s:%s' % (HOST, PORT), version='1.1', check=False))
     stomp._transport = Mock()
     frame = StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.DESTINATION_HEADER: destination})
     self.assertRaises(StompProtocolError, stomp.nack, frame)
     frame = StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.DESTINATION_HEADER: destination, StompSpec.SUBSCRIPTION_HEADER: '0815'})
     stomp.nack(frame, receipt='123')
     args, _ = stomp._transport.send.call_args
     sentFrame = args[0]
     self.assertEquals(commands.nack(frame, receipt='123', version='1.1'), sentFrame)
Beispiel #5
0
 def test_stomp_version_1_1(self):
     destination = '/queue/foo'
     stomp = self._get_transport_mock(config=StompConfig('tcp://%s:%s' % (HOST, PORT), version=StompSpec.VERSION_1_1, check=False))
     stomp._transport = mock.Mock()
     frame = StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.DESTINATION_HEADER: destination})
     self.assertRaises(StompProtocolError, stomp.nack, frame)
     frame = StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: '4711', StompSpec.DESTINATION_HEADER: destination, StompSpec.SUBSCRIPTION_HEADER: '0815'}, version=StompSpec.VERSION_1_1)
     stomp.nack(frame, receipt='123')
     args, _ = stomp._transport.send.call_args
     sentFrame = args[0]
     self.assertEqual(commands.nack(frame, receipt='123'), sentFrame)
Beispiel #6
0
 def test_nack(self):
     self.assertEqual(
         commands.nack(
             StompFrame(StompSpec.MESSAGE, {
                 StompSpec.MESSAGE_ID_HEADER: 'hi',
                 StompSpec.SUBSCRIPTION_HEADER: 'there'
             },
                        version=StompSpec.VERSION_1_1)),
         StompFrame(command=StompSpec.NACK,
                    headers={
                        StompSpec.MESSAGE_ID_HEADER: 'hi',
                        StompSpec.SUBSCRIPTION_HEADER: 'there'
                    },
                    version=StompSpec.VERSION_1_1))
     self.assertEqual(
         commands.nack(StompFrame(StompSpec.MESSAGE, {
             StompSpec.MESSAGE_ID_HEADER: 'hi',
             StompSpec.SUBSCRIPTION_HEADER: 'there'
         },
                                  version=StompSpec.VERSION_1_1),
                       receipt='4711'),
         StompFrame(command=StompSpec.NACK,
                    headers={
                        StompSpec.MESSAGE_ID_HEADER: 'hi',
                        StompSpec.SUBSCRIPTION_HEADER: 'there',
                        StompSpec.RECEIPT_HEADER: '4711'
                    },
                    version=StompSpec.VERSION_1_1))
     self.assertEqual(
         commands.nack(
             StompFrame(StompSpec.MESSAGE, {
                 StompSpec.MESSAGE_ID_HEADER: 'hi',
                 StompSpec.SUBSCRIPTION_HEADER: 'there',
                 StompSpec.TRANSACTION_HEADER: 'man'
             },
                        version=StompSpec.VERSION_1_1)),
         StompFrame(command=StompSpec.NACK,
                    headers={
                        StompSpec.MESSAGE_ID_HEADER: 'hi',
                        StompSpec.SUBSCRIPTION_HEADER: 'there'
                    },
                    version=StompSpec.VERSION_1_1))
     self.assertEqual(
         commands.nack(StompFrame(StompSpec.MESSAGE, {
             StompSpec.MESSAGE_ID_HEADER: 'hi',
             StompSpec.SUBSCRIPTION_HEADER: 'there',
             StompSpec.TRANSACTION_HEADER: 'man'
         },
                                  version=StompSpec.VERSION_1_1),
                       transactions=['woman']),
         StompFrame(command=StompSpec.NACK,
                    headers={
                        StompSpec.MESSAGE_ID_HEADER: 'hi',
                        StompSpec.SUBSCRIPTION_HEADER: 'there'
                    },
                    version=StompSpec.VERSION_1_1))
     self.assertEqual(
         commands.nack(
             StompFrame(StompSpec.MESSAGE, {
                 StompSpec.MESSAGE_ID_HEADER: 'hi',
                 StompSpec.SUBSCRIPTION_HEADER: 'there',
                 '4711': '0815'
             },
                        version=StompSpec.VERSION_1_1)),
         StompFrame(command=StompSpec.NACK,
                    headers={
                        StompSpec.MESSAGE_ID_HEADER: 'hi',
                        StompSpec.SUBSCRIPTION_HEADER: 'there'
                    },
                    version=StompSpec.VERSION_1_1))
     self.assertRaises(
         StompProtocolError, commands.nack,
         StompFrame(StompSpec.CONNECTED, {}, version=StompSpec.VERSION_1_1))
     self.assertRaises(
         StompProtocolError, commands.nack,
         StompFrame(StompSpec.MESSAGE, {
             StompSpec.MESSAGE_ID_HEADER: 'hi',
             StompSpec.SUBSCRIPTION_HEADER: 'there'
         },
                    version=StompSpec.VERSION_1_0))
     self.assertRaises(
         StompProtocolError, commands.nack,
         StompFrame(StompSpec.MESSAGE, {
             StompSpec.MESSAGE_ID_HEADER: 'hi',
             StompSpec.SUBSCRIPTION_HEADER: 'there',
             StompSpec.TRANSACTION_HEADER: 'man'
         },
                    version=StompSpec.VERSION_1_0))
     self.assertRaises(
         StompProtocolError, commands.nack,
         StompFrame(StompSpec.MESSAGE,
                    {StompSpec.SUBSCRIPTION_HEADER: 'hi'},
                    version=StompSpec.VERSION_1_1))
     self.assertRaises(
         StompProtocolError, commands.nack,
         StompFrame(StompSpec.MESSAGE, {StompSpec.MESSAGE_ID_HEADER: 'hi'},
                    version=StompSpec.VERSION_1_1))