Back to index

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

List of all members.

Public Member Functions

def test_send_receive
def test_send_receive_in_other_conn
def test_send_receive_in_other_conn_with_disconnect
def test_multi_subscribers
def test_send_with_receipt
def test_send_with_receipt_tx
def test_interleaved_receipt_no_receipt
def test_interleaved_receipt_no_receipt_tx
def test_interleaved_receipt_no_receipt_inverse
def create_connection
def create_subscriber_connection
def setUp
def tearDown
def simple_test_send_rec
def assertListener
def assertListenerAfter

Public Attributes

 conn
 listener

Private Member Functions

def __test_send_receipt
def __gather_receipts

Detailed Description

Definition at line 49 of file destinations.py.


Member Function Documentation

def destinations.TestQueue.__gather_receipts (   self) [private]

Definition at line 218 of file destinations.py.

00218 
00219     def __gather_receipts(self):
00220         result = set()
00221         for r in self.listener.receipts:
00222             result.add(r['headers']['receipt-id'])
00223         return result

Here is the caller graph for this function:

def destinations.TestQueue.__test_send_receipt (   self,
  destination,
  before,
  after,
  headers = {} 
) [private]

Definition at line 196 of file destinations.py.

00196 
00197     def __test_send_receipt(self, destination, before, after, headers = {}):
00198         count = 50
00199         self.listener.reset(count)
00200 
00201         before()
00202         expected_receipts = set()
00203 
00204         for x in range(0, count):
00205             receipt = "test" + str(x)
00206             expected_receipts.add(receipt)
00207             self.conn.send("test receipt", destination=destination,
00208                            receipt=receipt, headers=headers)
00209         after()
00210 
00211         self.assertTrue(self.listener.await(5))
00212 
00213         missing_receipts = expected_receipts.difference(
00214                     self.__gather_receipts())
00215 
00216         self.assertEquals(set(), missing_receipts,
00217                           "missing receipts: " + str(missing_receipts))

Here is the call graph for this function:

Here is the caller graph for this function:

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 i-leaved receipt/no receipt, no-r bracketed by rs 

Definition at line 137 of file destinations.py.

00137 
00138     def test_interleaved_receipt_no_receipt(self):
00139         ''' Test i-leaved receipt/no receipt, no-r bracketed by rs '''
00140 
00141         d = '/queue/ir'
00142 
00143         self.listener.reset(5)
00144 
00145         self.conn.subscribe(destination=d)
00146         self.conn.send('first', destination=d, receipt='a')
00147         self.conn.send('second', destination=d)
00148         self.conn.send('third', destination=d, receipt='b')
00149 
00150         self.assertTrue(self.listener.await(3))
00151 
00152         self.assertEquals(set(['a','b']), self.__gather_receipts())
00153         self.assertEquals(3, len(self.listener.messages))

Here is the call graph for this function:

Test i-leaved receipt/no receipt, r bracketed by no-rs 

Definition at line 179 of file destinations.py.

00179 
00180     def test_interleaved_receipt_no_receipt_inverse(self):
00181         ''' Test i-leaved receipt/no receipt, r bracketed by no-rs '''
00182 
00183         d = '/queue/ir'
00184 
00185         self.listener.reset(4)
00186 
00187         self.conn.subscribe(destination=d)
00188         self.conn.send('first', destination=d)
00189         self.conn.send('second', destination=d, receipt='a')
00190         self.conn.send('third', destination=d)
00191 
00192         self.assertTrue(self.listener.await(3))
00193 
00194         self.assertEquals(set(['a']), self.__gather_receipts())
00195         self.assertEquals(3, len(self.listener.messages))

Here is the call graph for this function:

Test i-leaved receipt/no receipt, no-r bracketed by r+xactions 

Definition at line 154 of file destinations.py.

00154 
00155     def test_interleaved_receipt_no_receipt_tx(self):
00156         ''' Test i-leaved receipt/no receipt, no-r bracketed by r+xactions '''
00157 
00158         d = '/queue/ir'
00159         tx = 'tx.ir'
00160 
00161         # three messages and two receipts
00162         self.listener.reset(5)
00163 
00164         self.conn.subscribe(destination=d)
00165         self.conn.begin(transaction=tx)
00166 
00167         self.conn.send('first', destination=d, receipt='a', transaction=tx)
00168         self.conn.send('second', destination=d, transaction=tx)
00169         self.conn.send('third', destination=d, receipt='b', transaction=tx)
00170         self.conn.commit(transaction=tx)
00171 
00172         self.assertTrue(self.listener.await(40), "Missing messages/confirms")
00173 
00174         expected = set(['a', 'b'])
00175         missing = expected.difference(self.__gather_receipts())
00176 
00177         self.assertEquals(set(), missing, "Missing receipts: " + str(missing))
00178         self.assertEquals(3, len(self.listener.messages))

Here is the call graph for this function:

Test multiple subscribers against a single /queue destination 

Definition at line 95 of file destinations.py.

00095 
00096     def test_multi_subscribers(self):
00097         ''' Test multiple subscribers against a single /queue destination '''
00098         d = '/queue/test-multi'
00099 
00100         ## set up two subscribers
00101         conn1, listener1 = self.create_subscriber_connection(d)
00102         conn2, listener2 = self.create_subscriber_connection(d)
00103 
00104         try:
00105             ## now send
00106             self.conn.send("test1", destination=d)
00107             self.conn.send("test2", destination=d)
00108 
00109             ## expect both consumers to get a message?
00110             self.assertTrue(listener1.await(2))
00111             self.assertEquals(1, len(listener1.messages),
00112                               "unexpected message count")
00113             self.assertTrue(listener2.await(2))
00114             self.assertEquals(1, len(listener2.messages),
00115                               "unexpected message count")
00116         finally:
00117             conn1.stop()
00118             conn2.stop()

Here is the call graph for this function:

Test basic send/receive for /queue 

Definition at line 51 of file destinations.py.

00051 
00052     def test_send_receive(self):
00053         ''' Test basic send/receive for /queue '''
00054         d = '/queue/test'
00055         self.simple_test_send_rec(d)

Here is the call graph for this function:

Test send in one connection, receive in another 

Definition at line 56 of file destinations.py.

00056 
00057     def test_send_receive_in_other_conn(self):
00058         ''' Test send in one connection, receive in another '''
00059         d = '/queue/test2'
00060 
00061         # send
00062         self.conn.send("hello", destination=d)
00063 
00064         # now receive
00065         conn2 = self.create_connection()
00066         try:
00067             listener2 = base.WaitableListener()
00068             conn2.set_listener('', listener2)
00069 
00070             conn2.subscribe(destination=d)
00071             self.assertTrue(listener2.await(10), "no receive")
00072         finally:
00073             conn2.stop()

Here is the call graph for this function:

Test send, disconnect, receive 

Definition at line 74 of file destinations.py.

00074 
00075     def test_send_receive_in_other_conn_with_disconnect(self):
00076         ''' Test send, disconnect, receive '''
00077         d = '/queue/test3'
00078 
00079         # send
00080         self.conn.send("hello thar", destination=d, receipt="foo")
00081         self.listener.await(3)
00082         self.conn.stop()
00083 
00084         # now receive
00085         conn2 = self.create_connection()
00086         try:
00087             listener2 = base.WaitableListener()
00088             conn2.set_listener('', listener2)
00089 
00090             conn2.subscribe(destination=d)
00091             self.assertTrue(listener2.await(10), "no receive")
00092         finally:
00093             conn2.stop()
00094 

Here is the call graph for this function:

Definition at line 119 of file destinations.py.

00119 
00120     def test_send_with_receipt(self):
00121         d = '/queue/test-receipt'
00122         def noop(): pass
00123         self.__test_send_receipt(d, noop, noop)

Here is the call graph for this function:

Definition at line 124 of file destinations.py.

00124 
00125     def test_send_with_receipt_tx(self):
00126         d = '/queue/test-receipt-tx'
00127         tx = 'receipt.tx'
00128 
00129         def before():
00130             self.conn.begin(transaction=tx)
00131 
00132         def after():
00133             self.assertFalse(self.listener.await(1))
00134             self.conn.commit(transaction=tx)
00135 
00136         self.__test_send_receipt(d, before, after, {'transaction': tx})

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: