Back to index

rabbitmq-server  2.8.4
Public Member Functions | Public Attributes
destinations.TestReplyQueue Class Reference
Inheritance diagram for destinations.TestReplyQueue:
Inheritance graph
[legend]
Collaboration diagram for destinations.TestReplyQueue:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_reply_queue
def test_reuse_reply_queue
def create_connection
def create_subscriber_connection
def setUp
def tearDown
def simple_test_send_rec
def assertListener
def assertListenerAfter

Public Attributes

 conn
 listener

Detailed Description

Definition at line 259 of file destinations.py.


Member Function Documentation

def base.BaseTest.assertListener (   self,
  errMsg,
  numMsgs = 0,
  numErrs = 0,
  numRcts = 0,
  timeout = 1 
) [inherited]

Definition at line 52 of file base.py.

00052 
00053    def assertListener(self, errMsg, numMsgs=0, numErrs=0, numRcts=0, timeout=1):
00054         if numMsgs + numErrs + numRcts > 0:
00055             self.assertTrue(self.listener.await(timeout), errMsg + " (#awaiting)")
00056         else:
00057             self.assertFalse(self.listener.await(timeout), errMsg + " (#awaiting)")
00058         self.assertEquals(numMsgs, len(self.listener.messages), errMsg + " (#messages)")
00059         self.assertEquals(numErrs, len(self.listener.errors), errMsg + " (#errors)")
00060         self.assertEquals(numRcts, len(self.listener.receipts), errMsg + " (#receipts)")

Here is the caller graph for this function:

def base.BaseTest.assertListenerAfter (   self,
  verb,
  errMsg = "",
  numMsgs = 0,
  numErrs = 0,
  numRcts = 0,
  timeout = 1 
) [inherited]

Definition at line 61 of file base.py.

00061 
00062    def assertListenerAfter(self, verb, errMsg="", numMsgs=0, numErrs=0, numRcts=0, timeout=1):
00063         num = numMsgs + numErrs + numRcts
00064         self.listener.reset(num if num>0 else 1)
00065         verb()
00066         self.assertListener(errMsg=errMsg, numMsgs=numMsgs, numErrs=numErrs, numRcts=numRcts, timeout=timeout)

Here is the call graph for this function:

Here is the caller graph for this function:

def base.BaseTest.create_connection (   self,
  version = None,
  heartbeat = None 
) [inherited]

Definition at line 9 of file base.py.

00009 
00010    def create_connection(self, version=None, heartbeat=None):
00011        conn = stomp.Connection(user="guest", passcode="guest",
00012                                version=version, heartbeat=heartbeat)
00013        conn.start()
00014        conn.connect()
00015        return conn

Here is the caller graph for this function:

def base.BaseTest.create_subscriber_connection (   self,
  dest 
) [inherited]

Definition at line 16 of file base.py.

00016 
00017    def create_subscriber_connection(self, dest):
00018        conn = self.create_connection()
00019        listener = WaitableListener()
00020        conn.set_listener('', listener)
00021        conn.subscribe(destination=dest, receipt="sub.receipt")
00022        listener.await()
00023        self.assertEquals(1, len(listener.receipts))
00024        listener.reset()
00025        return conn, listener

Here is the call graph for this function:

Here is the caller graph for this function:

def base.BaseTest.setUp (   self) [inherited]

Definition at line 26 of file base.py.

00026 
00027    def setUp(self):
00028         self.conn = self.create_connection()
00029         self.listener = WaitableListener()
00030         self.conn.set_listener('', self.listener)

def base.BaseTest.simple_test_send_rec (   self,
  dest,
  route = None 
) [inherited]

Definition at line 35 of file base.py.

00035 
00036    def simple_test_send_rec(self, dest, route = None):
00037         self.listener.reset()
00038 
00039         self.conn.subscribe(destination=dest)
00040         self.conn.send("foo", destination=dest)
00041 
00042         self.assertTrue(self.listener.await(), "Timeout, no message received")
00043 
00044         # assert no errors
00045         if len(self.listener.errors) > 0:
00046             self.fail(self.listener.errors[0]['message'])
00047 
00048         # check header content
00049         msg = self.listener.messages[0]
00050         self.assertEquals("foo", msg['message'])
00051         self.assertEquals(dest, msg['headers']['destination'])

Here is the caller graph for this function:

def base.BaseTest.tearDown (   self) [inherited]

Definition at line 31 of file base.py.

00031 
00032    def tearDown(self):
00033         if self.conn.is_connected():
00034             self.conn.stop()

Test with two separate clients. Client 1 sends
message to a known destination with a defined reply
queue. Client 2 receives on known destination and replies
on the reply destination. Client 1 gets the reply message

Definition at line 261 of file destinations.py.

00261 
00262     def test_reply_queue(self):
00263         ''' Test with two separate clients. Client 1 sends
00264         message to a known destination with a defined reply
00265         queue. Client 2 receives on known destination and replies
00266         on the reply destination. Client 1 gets the reply message'''
00267 
00268         known = '/queue/known'
00269         reply = '/temp-queue/0'
00270 
00271         ## Client 1 uses pre-supplied connection and listener
00272         ## Set up client 2
00273         conn2, listener2 = self.create_subscriber_connection(known)
00274 
00275         try:
00276             self.conn.send("test", destination=known,
00277                            headers = {"reply-to": reply})
00278 
00279             self.assertTrue(listener2.await(5))
00280             self.assertEquals(1, len(listener2.messages))
00281 
00282             reply_to = listener2.messages[0]['headers']['reply-to']
00283             self.assertTrue(reply_to.startswith('/reply-queue/'))
00284 
00285             conn2.send("reply", destination=reply_to)
00286             self.assertTrue(self.listener.await(5))
00287             self.assertEquals("reply", self.listener.messages[0]['message'])
00288         finally:
00289             conn2.stop()

Here is the call graph for this function:

Test re-use of reply-to queue 

Definition at line 290 of file destinations.py.

00290 
00291     def test_reuse_reply_queue(self):
00292         ''' Test re-use of reply-to queue '''
00293 
00294         known2 = '/queue/known2'
00295         known3 = '/queue/known3'
00296         reply = '/temp-queue/foo'
00297 
00298         def respond(cntn, listna):
00299             self.assertTrue(listna.await(5))
00300             self.assertEquals(1, len(listna.messages))
00301             reply_to = listna.messages[0]['headers']['reply-to']
00302             self.assertTrue(reply_to.startswith('/reply-queue/'))
00303             cntn.send("reply", destination=reply_to)
00304 
00305         ## Client 1 uses pre-supplied connection and listener
00306         ## Set up clients 2 and 3
00307         conn2, listener2 = self.create_subscriber_connection(known2)
00308         conn3, listener3 = self.create_subscriber_connection(known3)
00309         try:
00310             self.listener.reset(2)
00311             self.conn.send("test2", destination=known2,
00312                            headers = {"reply-to": reply})
00313             self.conn.send("test3", destination=known3,
00314                            headers = {"reply-to": reply})
00315             respond(conn2, listener2)
00316             respond(conn3, listener3)
00317 
00318             self.assertTrue(self.listener.await(5))
00319             self.assertEquals(2, len(self.listener.messages))
00320             self.assertEquals("reply", self.listener.messages[0]['message'])
00321             self.assertEquals("reply", self.listener.messages[1]['message'])
00322         finally:
00323             conn2.stop()
00324             conn3.stop()

Here is the call graph for this function:


Member Data Documentation

base.BaseTest.conn [inherited]

Definition at line 27 of file base.py.

Definition at line 28 of file base.py.


The documentation for this class was generated from the following file: