Back to index

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

List of all members.

Public Member Functions

def test_tx_commit
def test_tx_abort
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 transactions.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 TX with an ABORT and ensure messages are discarded 

Definition at line 32 of file transactions.py.

00032 
00033     def test_tx_abort(self):
00034         ''' Test TX with an ABORT and ensure messages are discarded '''
00035         d = "/exchange/amq.fanout"
00036         tx = "test.tx"
00037 
00038         self.listener.reset()
00039         self.conn.subscribe(destination=d)
00040         self.conn.begin(transaction=tx)
00041         self.conn.send("hello!", destination=d, transaction=tx)
00042         self.conn.send("again!", destination=d)
00043 
00044         ## should see the second message
00045         self.assertTrue(self.listener.await(3))
00046         self.assertEquals(1, len(self.listener.messages))
00047         self.assertEquals("again!", self.listener.messages[0]['message'])
00048 
00049         ## now look for the first message to be discarded
00050         self.listener.reset()
00051         self.conn.abort(transaction=tx)
00052         self.assertFalse(self.listener.await(3))
00053         self.assertEquals(0, len(self.listener.messages),
00054                           "Unexpected committed message")
00055 
Test TX with a COMMIT and ensure messages are delivered 

Definition at line 8 of file transactions.py.

00008 
00009     def test_tx_commit(self):
00010         ''' Test TX with a COMMIT and ensure messages are delivered '''
00011         d = "/exchange/amq.fanout"
00012         tx = "test.tx"
00013 
00014         self.listener.reset()
00015         self.conn.subscribe(destination=d)
00016         self.conn.begin(transaction=tx)
00017         self.conn.send("hello!", destination=d, transaction=tx)
00018         self.conn.send("again!", destination=d)
00019 
00020         ## should see the second message
00021         self.assertTrue(self.listener.await(3))
00022         self.assertEquals(1, len(self.listener.messages))
00023         self.assertEquals("again!", self.listener.messages[0]['message'])
00024 
00025         ## now look for the first message
00026         self.listener.reset()
00027         self.conn.commit(transaction=tx)
00028         self.assertTrue(self.listener.await(3))
00029         self.assertEquals(1, len(self.listener.messages),
00030                           "Missing committed message")
00031         self.assertEquals("hello!", self.listener.messages[0]['message'])


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: