예제 #1
0
 def test_dont_unescape_bad_characters(self):
     parser = StompParser(StompSpec.VERSION_1_2)
     frame = commands.send('*queue')
     parser.add(binaryType(frame))
     self.assertEqual(parser.get(), frame)
     for badCharacter in (b'\r', b'\n', b'\c', b'\\', b':', b'\\h'):
         self.assertRaises(StompFrameError, parser.add, binaryType(frame).replace(b'*', badCharacter))
     self.assertRaises(StompFrameError, parser.add, binaryType(commands.send('queue\\')))
     self.assertIsNone(parser.get())
예제 #2
0
 def test_dont_unescape_bad_characters(self):
     parser = StompParser(StompSpec.VERSION_1_2)
     frame = commands.send('*queue')
     parser.add(binaryType(frame))
     self.assertEqual(parser.get(), frame)
     for badCharacter in (b'\r', b'\n', b'\c', b'\\', b':', b'\\h'):
         self.assertRaises(StompFrameError, parser.add,
                           binaryType(frame).replace(b'*', badCharacter))
     self.assertRaises(StompFrameError, parser.add,
                       binaryType(commands.send('queue\\')))
     self.assertIsNone(parser.get())
예제 #3
0
    def test_strip_line_delimiter(self):
        queue = '/queue/test'
        frame = commands.send(queue)
        frameWithStripLineDelimiter = commands.send(queue + '\r')
        for (version, stripLineDelimiter) in [
            (StompSpec.VERSION_1_0, False),
            (StompSpec.VERSION_1_1, False),
            (StompSpec.VERSION_1_2, True)
        ]:
            parser = StompParser(version)
            parser.add(binaryType(frameWithStripLineDelimiter))
            self.assertEqual(parser.get(), frame if stripLineDelimiter else frameWithStripLineDelimiter)

        frameWithCarriageReturn = commands.send(queue + '\r', version=StompSpec.VERSION_1_2)
        parser = StompParser(StompSpec.VERSION_1_2)
        parser.add(binaryType(frameWithCarriageReturn))
        self.assertEqual(parser.get().headers[StompSpec.DESTINATION_HEADER], queue + '\r')
예제 #4
0
    def test_strip_line_delimiter(self):
        queue = '/queue/test'
        frame = commands.send(queue)
        frameWithStripLineDelimiter = commands.send(queue + '\r')
        for (version, stripLineDelimiter) in [(StompSpec.VERSION_1_0, False),
                                              (StompSpec.VERSION_1_1, False),
                                              (StompSpec.VERSION_1_2, True)]:
            parser = StompParser(version)
            parser.add(binaryType(frameWithStripLineDelimiter))
            self.assertEqual(
                parser.get(),
                frame if stripLineDelimiter else frameWithStripLineDelimiter)

        frameWithCarriageReturn = commands.send(queue + '\r',
                                                version=StompSpec.VERSION_1_2)
        parser = StompParser(StompSpec.VERSION_1_2)
        parser.add(binaryType(frameWithCarriageReturn))
        self.assertEqual(parser.get().headers[StompSpec.DESTINATION_HEADER],
                         queue + '\r')
예제 #5
0
 def test_strip_line_delimiter(self):
     queue = '/queue/test'
     frame = commands.send(queue)
     rawFrameReplaced = str(commands.send(queue)).replace('\n', '\r\n')
     for (version, replace) in [(StompSpec.VERSION_1_0, False),
                                (StompSpec.VERSION_1_1, False),
                                (StompSpec.VERSION_1_2, True)]:
         if replace:
             parser = StompParser(version)
             parser.add(rawFrameReplaced)
             self.assertEquals(parser.get(), frame)
         else:
             self.assertRaises(StompFrameError,
                               StompParser(version).add, rawFrameReplaced)
     textWithCarriageReturn = 'there\rfolks'
     frame = commands.send(queue, headers={'hi': textWithCarriageReturn})
     parser = StompParser(StompSpec.VERSION_1_2)
     parser.add(str(frame))
     self.assertEquals(parser.get().headers['hi'], textWithCarriageReturn)
예제 #6
0
 def test_strip_line_delimiter(self):
     queue = '/queue/test'
     frame = commands.send(queue)
     rawFrameReplaced = str(commands.send(queue)).replace('\n', '\r\n')
     for (version, replace) in [
         (StompSpec.VERSION_1_0, False),
         (StompSpec.VERSION_1_1, False),
         (StompSpec.VERSION_1_2, True)
     ]:
         if replace:
             parser = StompParser(version)
             parser.add(rawFrameReplaced)
             self.assertEquals(parser.get(), frame)
         else:
             self.assertRaises(StompFrameError, StompParser(version).add, rawFrameReplaced)
     textWithCarriageReturn = 'there\rfolks'
     frame = commands.send(queue, headers={'hi': textWithCarriageReturn})
     parser = StompParser(StompSpec.VERSION_1_2)
     parser.add(str(frame))
     self.assertEquals(parser.get().headers['hi'], textWithCarriageReturn)
예제 #7
0
 def send(self, destination, body='', headers=None, receipt=None):
     """send(destination, body='', headers=None, receipt=None)
     
     Send a **SEND** frame.
     """
     self.sendFrame(commands.send(destination, body, headers, receipt))