diff options
author | Gordon Sim <gsim@apache.org> | 2008-03-07 16:19:30 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-03-07 16:19:30 +0000 |
commit | e385ba8c6612ac396a4d9ecbd5c8ffa18977e25a (patch) | |
tree | 9e746fd6cb0c04a21abac6630f849fb61202badd /python/tests_0-10/example.py | |
parent | 0d8cccff4671959e0c668af906ce9ba95c975bde (diff) | |
download | qpid-python-e385ba8c6612ac396a4d9ecbd5c8ffa18977e25a.tar.gz |
Converted some more tests to use new client
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@634729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/tests_0-10/example.py')
-rw-r--r-- | python/tests_0-10/example.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/python/tests_0-10/example.py b/python/tests_0-10/example.py index da5ee2441f..fd10a8df4f 100644 --- a/python/tests_0-10/example.py +++ b/python/tests_0-10/example.py @@ -17,10 +17,10 @@ # under the License. # -from qpid.content import Content -from qpid.testlib import testrunner, TestBase +from qpid.datatypes import Message, RangedSet +from qpid.testlib import TestBase010 -class ExampleTest (TestBase): +class ExampleTest (TestBase010): """ An example Qpid test, illustrating the unittest framework and the python Qpid client. The test class must inherit TestBase. The @@ -35,9 +35,9 @@ class ExampleTest (TestBase): """ # By inheriting TestBase, self.client is automatically connected - # and self.channel is automatically opened as channel(1) - # Other channel methods mimic the protocol. - channel = self.channel + # and self.session is automatically opened as session(1) + # Other session methods mimic the protocol. + session = self.session # Now we can send regular commands. If you want to see what the method # arguments mean or what other commands are available, you can use the @@ -57,30 +57,30 @@ class ExampleTest (TestBase): # interact with the server. # Here we use ordinal arguments. - self.exchange_declare(channel, 0, "test", "direct") + session.exchange_declare("test", "direct") # Here we use keyword arguments. - self.queue_declare(channel, queue="test-queue") - channel.queue_bind(queue="test-queue", exchange="test", routing_key="key") + session.queue_declare(session, queue="test-queue", exclusive=True, auto_delete=True) + session.exchange_bind(queue="test-queue", exchange="test", binding_key="key") - # Call Channel.basic_consume to register as a consumer. + # Call Session.subscribe to register as a consumer. # All the protocol methods return a message object. The message object # has fields corresponding to the reply method fields, plus a content # field that is filled if the reply includes content. In this case the # interesting field is the consumer_tag. - channel.message_subscribe(queue="test-queue", destination="consumer_tag") - channel.message_flow(destination="consumer_tag", unit=0, value=0xFFFFFFFF) - channel.message_flow(destination="consumer_tag", unit=1, value=0xFFFFFFFF) + session.message_subscribe(queue="test-queue", destination="consumer_tag") + session.message_flow(destination="consumer_tag", unit=0, value=0xFFFFFFFF) + session.message_flow(destination="consumer_tag", unit=1, value=0xFFFFFFFF) - # We can use the Client.queue(...) method to access the queue - # corresponding to our consumer_tag. - queue = self.client.queue("consumer_tag") + # We can use the session.incoming(...) method to access the messages + # delivered for our consumer_tag. + queue = session.incoming("consumer_tag") # Now lets publish a message and see if our consumer gets it. To do - # this we need to import the Content class. - sent = Content("Hello World!") - sent["routing_key"] = "key" - channel.message_transfer(destination="test", content=sent) + # this we need to import the Message class. + delivery_properties = session.delivery_properties(routing_key="key") + sent = Message(delivery_properties, "Hello World!") + session.message_transfer(destination="test", message=sent) # Now we'll wait for the message to arrive. We can use the timeout # argument in case the server hangs. By default queue.get() will wait @@ -88,8 +88,8 @@ class ExampleTest (TestBase): msg = queue.get(timeout=10) # And check that we got the right response with assertEqual - self.assertEqual(sent.body, msg.content.body) + self.assertEqual(sent.body, msg.body) # Now acknowledge the message. - msg.complete() + session.message_accept(RangedSet(msg.id)) |