diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-21 15:43:59 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-21 15:43:59 +0000 |
commit | 70e05e877e45596650d7e1f43e1eef21c53d50f5 (patch) | |
tree | c735c35a26db905da1f606333f39981ea1a38f4d /qpid/java/systests | |
parent | be8ed248c6fdb360e259b1b25c9456703955ea96 (diff) | |
download | qpid-python-70e05e877e45596650d7e1f43e1eef21c53d50f5.tar.gz |
QPID-2738
You could now susbcribe to any queue using browse mode and use a regular MessageConsumer (even with a MessageListener) instead of having to use a Queue Browser.
Ex. 'my-ring-queue; {mode: browse}'
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@966284 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
-rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java index 5bf2de836d..bd7f146a94 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java @@ -608,6 +608,7 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase } /** + * Test Goal : Verify the default subjects used for each exchange type. * The default for amq.topic is "#" and for the rest it's "" */ public void testDefaultSubjects() throws Exception @@ -635,4 +636,43 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase "with '#' binding key should have received the message ", ((TextMessage)topicCons.receive(1000)).getText(),"1000"); } + + /** + * Test Goal : Verify that 'mode : browse' works as expected using a regular consumer. + * This indirectly tests ring queues as well. + */ + public void testBrowseMode() throws Exception + { + + Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + + String addr = "ADDR:my-ring-queue; {create: always, mode: browse, " + + "node: {x-bindings: [{exchange : 'amq.direct', key : test}], " + + "x-declare:{'qpid.policy_type':ring, 'qpid.max_count':2}}}"; + + Destination dest = ssn.createQueue(addr); + MessageConsumer browseCons = ssn.createConsumer(dest); + MessageProducer prod = ssn.createProducer(ssn.createQueue("ADDR:amq.direct/test")); + + prod.send(ssn.createTextMessage("Test1")); + prod.send(ssn.createTextMessage("Test2")); + + TextMessage msg = (TextMessage)browseCons.receive(1000); + assertEquals("Didn't receive the first message",msg.getText(),"Test1"); + + msg = (TextMessage)browseCons.receive(1000); + assertEquals("Didn't receive the first message",msg.getText(),"Test2"); + + browseCons.close(); + prod.send(ssn.createTextMessage("Test3")); + browseCons = ssn.createConsumer(dest); + + msg = (TextMessage)browseCons.receive(1000); + assertEquals("Should receive the second message again",msg.getText(),"Test2"); + + msg = (TextMessage)browseCons.receive(1000); + assertEquals("Should receive the third message since it's a ring queue",msg.getText(),"Test3"); + + assertNull("Should not receive anymore messages",browseCons.receive(500)); + } } |