diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-09-03 16:22:07 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-09-03 16:22:07 +0000 |
commit | e833204097e0df021fe9bc27785faa4769441d70 (patch) | |
tree | 9a1092a2fb7173ec07fc04d7e289d930803b599b /qpid/java/systests | |
parent | e05d000fea861e01d5a98dac417642f47a8ccbc5 (diff) | |
download | qpid-python-e833204097e0df021fe9bc27785faa4769441d70.tar.gz |
QPID-2845
Adjusted the address string to include arguments inside the arguments map instead of putting them directly in x-declare.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@992352 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/queue/QueuePolicyTest.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java new file mode 100644 index 0000000000..468fd7e994 --- /dev/null +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java @@ -0,0 +1,89 @@ +package org.apache.qpid.test.client.queue; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.qpid.AMQException; +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.test.utils.QpidBrokerTestCase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class QueuePolicyTest extends QpidBrokerTestCase +{ + private static final Logger _logger = LoggerFactory.getLogger(QueuePolicyTest.class); + private Connection _connection; + + @Override + public void setUp() throws Exception + { + super.setUp(); + _connection = getConnection() ; + _connection.start(); + } + + @Override + public void tearDown() throws Exception + { + _connection.close(); + super.tearDown(); + } + + public void testRejectPolicy() throws Exception + { + String addr = "ADDR:queue; {create: always, " + + "node: {x-bindings: [{exchange : 'amq.direct', key : test}], " + + "x-declare:{ arguments : {'qpid.max_count':5} }}}"; + + Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + + Destination dest = ssn.createQueue(addr); + MessageConsumer consumer = ssn.createConsumer(dest); + MessageProducer prod = ssn.createProducer(ssn.createQueue("ADDR:amq.direct/test")); + + for (int i=0; i<50; i++) + { + prod.send(ssn.createMessage()); + } + + try + { + prod.send(ssn.createMessage()); + ((AMQSession)ssn).sync(); + } + catch (AMQException e) + { + assertTrue("The correct error code is not set",e.getErrorCode().toString().contains("506")); + } + } + + public void testRingPolicy() throws Exception + { + Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE); + + String addr = "ADDR:my-ring-queue; {create: always, " + + "node: {x-bindings: [{exchange : 'amq.direct', key : test}], " + + "x-declare:{arguments : {'qpid.policy_type':ring, 'qpid.max_count':2} }}}"; + + Destination dest = ssn.createQueue(addr); + MessageConsumer consumer = ssn.createConsumer(dest); + MessageProducer prod = ssn.createProducer(ssn.createQueue("ADDR:amq.direct/test")); + + prod.send(ssn.createTextMessage("Test1")); + prod.send(ssn.createTextMessage("Test2")); + prod.send(ssn.createTextMessage("Test3")); + + TextMessage msg = (TextMessage)consumer.receive(1000); + assertEquals("The consumer should receive the msg with body='Test2'",msg.getText(),"Test2"); + + msg = (TextMessage)consumer.receive(1000); + assertEquals("The consumer should receive the msg with body='Test3'",msg.getText(),"Test3"); + + prod.send(ssn.createTextMessage("Test4")); + assertEquals("The consumer should receive the msg with body='Test4'",msg.getText(),"Test3"); + } +} |