From 7bed64eb2467485a5e05e79342076b011dc36930 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Fri, 5 Nov 2010 00:09:54 +0000 Subject: Added a test case for QPID-2737, QPID-2774, QPID-2928 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1031364 13f79535-47bb-0310-9956-ffa450edef68 --- .../destination/AddressBasedDestinationTest.java | 50 ++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java b/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java index af7c08ca65..1d1f4a53d5 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java @@ -280,6 +280,10 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase assertTrue("Queue not bound as expected",( (AMQSession_0_10)jmsSession).isQueueBound("my-exchange", dest.getQueueName(),"hello", Collections.emptyMap())); + + // The client should be able to query and verify the existence of my-exchange (QPID-2774) + dest = new AMQAnyDestination("ADDR:my-exchange; {create: never}"); + cons = jmsSession.createConsumer(dest); } public void testBindQueueWithArgs() throws Exception @@ -684,9 +688,11 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase } /** - * Test Goal : Verify that unique subscription queues are created when consumers are - * created using the same destination except when the subscription queue - * has a name. + * Test Goal : When the same destination is used when creating two consumers, + * If the type == topic, verify that unique subscription queues are created, + * unless subscription queue has a name. + * + * If the type == queue, same queue should be shared. */ public void testSubscriptionForSameDestination() throws Exception { @@ -715,6 +721,28 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase catch(Exception e) { } + _connection.close(); + + _connection = getConnection() ; + _connection.start(); + ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + dest = ssn.createTopic("ADDR:my_queue; {create: always}"); + consumer1 = ssn.createConsumer(dest); + consumer2 = ssn.createConsumer(dest); + prod = ssn.createProducer(dest); + + prod.send(ssn.createTextMessage("A")); + Message m1 = consumer1.receive(1000); + Message m2 = consumer2.receive(1000); + + if (m1 != null) + { + assertNull("Only one consumer should receive the message",m2); + } + else + { + assertNotNull("Only one consumer should receive the message",m2); + } } public void testXBindingsWithoutExchangeName() throws Exception @@ -752,4 +780,20 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase assertNotNull("consumer should receive a message",cons.receive(1000)); cons.close(); } + + public void testXSubscribeOverrides() throws Exception + { + Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + String str = "ADDR:my_queue; {create:always,link: {x-subscribes:{exclusive: true, arguments: {a:b,x:y}}}}"; + Destination dest = ssn.createTopic(str); + MessageConsumer consumer1 = ssn.createConsumer(dest); + try + { + MessageConsumer consumer2 = ssn.createConsumer(dest); + fail("An exception should be thrown as 'my-queue' already have an exclusive subscriber"); + } + catch(Exception e) + { + } + } } -- cgit v1.2.1