Back to index

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

List of all members.

Public Member Functions

def test_unsubscribe_exchange_destination
def test_unsubscribe_exchange_destination_with_receipt
def test_unsubscribe_queue_destination
def test_unsubscribe_queue_destination_with_receipt
def test_unsubscribe_exchange_id
def test_unsubscribe_exchange_id_with_receipt
def test_unsubscribe_queue_id
def test_unsubscribe_queue_id_with_receipt
def test_connect_version_1_1
def test_heartbeat_disconnects_client
def test_unsupported_version
def test_bad_username
def test_bad_password
def test_bad_vhost
def bad_connect
def test_bad_header_on_send
def test_disconnect
def test_disconnect_with_receipt
def unsub_test
def sub_and_send
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 6 of file lifecycle.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 lifecycle.TestLifecycle.bad_connect (   self,
  new_conn,
  expected 
)

Definition at line 98 of file lifecycle.py.

00098 
00099     def bad_connect(self, new_conn, expected):
00100         self.conn.disconnect()
00101         listener = base.WaitableListener()
00102         new_conn.set_listener('', listener)
00103         try:
00104             new_conn.start()
00105             new_conn.connect()
00106             self.assertTrue(listener.await())
00107             self.assertEquals(expected, listener.errors[0]['message'])
00108         finally:
00109             if new_conn.is_connected():
00110                 new_conn.disconnect()

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 lifecycle.TestLifecycle.sub_and_send (   self,
  dest,
  subid = "",
  receipt = "" 
)

Definition at line 148 of file lifecycle.py.

00148 
00149     def sub_and_send(self, dest, subid="", receipt=""):
00150         def subfun():
00151             if subid=="":
00152                 self.conn.subscribe(destination=dest)
00153             else:
00154                 self.conn.subscribe(destination=dest, id=subid)
00155             self.conn.send("test", destination=dest)
00156         def unsubfun():
00157             if subid=="" and receipt=="":
00158                 self.conn.unsubscribe(destination=dest)
00159             elif receipt=="":
00160                 self.conn.unsubscribe(id=subid)
00161             elif subid=="":
00162                 self.conn.unsubscribe(destination=dest, receipt=receipt)
00163             else:
00164                 self.conn.unsubscribe(id=subid, receipt=receipt)
00165         return subfun, unsubfun

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 disallowed header on SEND 

Definition at line 111 of file lifecycle.py.

00111 
00112     def test_bad_header_on_send(self):
00113         ''' Test disallowed header on SEND '''
00114         self.listener.reset(1)
00115         self.conn.send_frame("SEND", {"destination":"a", "message-id":"1"})
00116         self.assertTrue(self.listener.await())
00117         self.assertEquals(1, len(self.listener.errors))
00118         errorReceived = self.listener.errors[0]
00119         self.assertEquals("Invalid header", errorReceived['headers']['message'])
00120         self.assertEquals("'message-id' is not allowed on 'SEND'.\n", errorReceived['message'])

Test bad password

Definition at line 85 of file lifecycle.py.

00085 
00086     def test_bad_password(self):
00087         ''' Test bad password'''
00088         self.bad_connect(stomp.Connection(user="guest",
00089                                           passcode="gust"),
00090                          "Authentication failure\n")

Here is the call graph for this function:

Test bad username

Definition at line 79 of file lifecycle.py.

00079 
00080     def test_bad_username(self):
00081         ''' Test bad username'''
00082         self.bad_connect(stomp.Connection(user="gust",
00083                                           passcode="guest"),
00084                          "Authentication failure\n")

Here is the call graph for this function:

Test bad virtual host

Definition at line 91 of file lifecycle.py.

00091 
00092     def test_bad_vhost(self):
00093         ''' Test bad virtual host'''
00094         self.bad_connect(stomp.Connection(user="guest",
00095                                           passcode="guest",
00096                                           virtual_host="//"),
00097                          "Authentication failure\n")

Here is the call graph for this function:

Test CONNECT with version 1.1

Definition at line 48 of file lifecycle.py.

00048 
00049     def test_connect_version_1_1(self):
00050         ''' Test CONNECT with version 1.1'''
00051         self.conn.disconnect()
00052         new_conn = self.create_connection(version="1.1")
00053         try:
00054             self.assertTrue(new_conn.is_connected())
00055         finally:
00056             new_conn.disconnect()
00057             self.assertFalse(new_conn.is_connected())

Here is the call graph for this function:

Test DISCONNECT command

Definition at line 121 of file lifecycle.py.

00121 
00122     def test_disconnect(self):
00123         ''' Test DISCONNECT command'''
00124         self.conn.disconnect()
00125         self.assertFalse(self.conn.is_connected())

Test the DISCONNECT command with receipts 

Definition at line 126 of file lifecycle.py.

00126 
00127     def test_disconnect_with_receipt(self):
00128         ''' Test the DISCONNECT command with receipts '''
00129         time.sleep(3)
00130         self.listener.reset(1)
00131         self.conn.send_frame("DISCONNECT", {"receipt": "test"})
00132         self.assertTrue(self.listener.await())
00133         self.assertEquals(1, len(self.listener.receipts))
00134         receiptReceived = self.listener.receipts[0]['headers']['receipt-id']
00135         self.assertEquals("test", receiptReceived
00136                          , "Wrong receipt received: '" + receiptReceived + "'")

Test heart-beat disconnection

Definition at line 58 of file lifecycle.py.

00058 
00059     def test_heartbeat_disconnects_client(self):
00060         ''' Test heart-beat disconnection'''
00061         self.conn.disconnect()
00062         new_conn = self.create_connection(heartbeat="1500,0")
00063         try:
00064             self.assertTrue(new_conn.is_connected())
00065             time.sleep(1)
00066             self.assertTrue(new_conn.is_connected())
00067             time.sleep(3)
00068             self.assertFalse(new_conn.is_connected())
00069         finally:
00070             if new_conn.is_connected():
00071                 new_conn.disconnect()

Here is the call graph for this function:

Test UNSUBSCRIBE command with exchange

Definition at line 8 of file lifecycle.py.

00008 
00009     def test_unsubscribe_exchange_destination(self):
00010         ''' Test UNSUBSCRIBE command with exchange'''
00011         d = "/exchange/amq.fanout"
00012         self.unsub_test(d, self.sub_and_send(d))

Here is the call graph for this function:

Test receipted UNSUBSCRIBE command with exchange

Definition at line 13 of file lifecycle.py.

00013 
00014     def test_unsubscribe_exchange_destination_with_receipt(self):
00015         ''' Test receipted UNSUBSCRIBE command with exchange'''
00016         d = "/exchange/amq.fanout"
00017         self.unsub_test(d, self.sub_and_send(d, receipt="unsub.rct"), numRcts=1)

Here is the call graph for this function:

Test UNSUBSCRIBE command with exchange by id

Definition at line 28 of file lifecycle.py.

00028 
00029     def test_unsubscribe_exchange_id(self):
00030         ''' Test UNSUBSCRIBE command with exchange by id'''
00031         d = "/exchange/amq.fanout"
00032         self.unsub_test(d, self.sub_and_send(d, subid="exchid"))

Here is the call graph for this function:

Test receipted UNSUBSCRIBE command with exchange by id

Definition at line 33 of file lifecycle.py.

00033 
00034     def test_unsubscribe_exchange_id_with_receipt(self):
00035         ''' Test receipted UNSUBSCRIBE command with exchange by id'''
00036         d = "/exchange/amq.fanout"
00037         self.unsub_test(d, self.sub_and_send(d, subid="exchid", receipt="unsub.rct"), numRcts=1)

Here is the call graph for this function:

Test UNSUBSCRIBE command with queue

Definition at line 18 of file lifecycle.py.

00018 
00019     def test_unsubscribe_queue_destination(self):
00020         ''' Test UNSUBSCRIBE command with queue'''
00021         d = "/queue/unsub01"
00022         self.unsub_test(d, self.sub_and_send(d))

Here is the call graph for this function:

Test receipted UNSUBSCRIBE command with queue

Definition at line 23 of file lifecycle.py.

00023 
00024     def test_unsubscribe_queue_destination_with_receipt(self):
00025         ''' Test receipted UNSUBSCRIBE command with queue'''
00026         d = "/queue/unsub02"
00027         self.unsub_test(d, self.sub_and_send(d, receipt="unsub.rct"), numRcts=1)

Here is the call graph for this function:

Test UNSUBSCRIBE command with queue by id

Definition at line 38 of file lifecycle.py.

00038 
00039     def test_unsubscribe_queue_id(self):
00040         ''' Test UNSUBSCRIBE command with queue by id'''
00041         d = "/queue/unsub03"
00042         self.unsub_test(d, self.sub_and_send(d, subid="queid"))

Here is the call graph for this function:

Test receipted UNSUBSCRIBE command with queue by id

Definition at line 43 of file lifecycle.py.

00043 
00044     def test_unsubscribe_queue_id_with_receipt(self):
00045         ''' Test receipted UNSUBSCRIBE command with queue by id'''
00046         d = "/queue/unsub04"
00047         self.unsub_test(d, self.sub_and_send(d, subid="queid", receipt="unsub.rct"), numRcts=1)

Here is the call graph for this function:

Test unsupported version on CONNECT command

Definition at line 72 of file lifecycle.py.

00072 
00073     def test_unsupported_version(self):
00074         ''' Test unsupported version on CONNECT command'''
00075         self.bad_connect(stomp.Connection(user="guest",
00076                                           passcode="guest",
00077                                           version="100.1"),
00078                          "Supported versions are 1.0,1.1\n")

Here is the call graph for this function:

def lifecycle.TestLifecycle.unsub_test (   self,
  dest,
  verbs,
  numRcts = 0 
)

Definition at line 137 of file lifecycle.py.

00137 
00138     def unsub_test(self, dest, verbs, numRcts=0):
00139         def afterfun():
00140             self.conn.send("after-test", destination=dest)
00141         subverb, unsubverb = verbs
00142         self.assertListenerAfter(subverb, numMsgs=1,
00143                            errMsg="FAILED to subscribe and send")
00144         self.assertListenerAfter(unsubverb, numRcts=numRcts,
00145                            errMsg="Incorrect responses from UNSUBSCRIBE")
00146         self.assertListenerAfter(afterfun,
00147                            errMsg="Still receiving messages")

Here is the call graph for this function:

Here is the caller 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: