diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2011-03-09 20:45:24 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2011-03-09 20:45:24 +0000 |
commit | ff0631b2fb6d2a0e1d02009c5274f40c8b4c7509 (patch) | |
tree | cba3fd6cba77436a3ac14692db2a337571c542bb /java/systests | |
parent | 47db0fe0c24a909c78070800193cf2d5472cd688 (diff) | |
download | qpid-python-ff0631b2fb6d2a0e1d02009c5274f40c8b4c7509.tar.gz |
QPID-2732
Adding a test case for the reliability options.
It verifies that,
1. The correct accept modes are set for unreliable and at-least-once.
2. Exceptions are thrown for unsupported unreliable modes.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1079986 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests')
-rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java | 91 |
1 files changed, 91 insertions, 0 deletions
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 f24e45ec93..83bb4175a3 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 @@ -44,6 +44,7 @@ import javax.naming.Context; import org.apache.qpid.client.AMQAnyDestination; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQDestination; +import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQSession_0_10; import org.apache.qpid.client.messaging.address.Node.ExchangeNode; import org.apache.qpid.client.messaging.address.Node.QueueNode; @@ -902,4 +903,94 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase } + + /** + * Test Goals : 1. Tests if the client sets the correct accept mode for unreliable + * and at-least-once. + * 2. Tests if an exception is thrown if exactly-once is used. + * 3. Tests if an exception is thrown if at-least-once is used with topics. + * + * Test Strategy: For goal #1 + * For unreliable and at-least-once the test tries to receives messages + * in client_ack mode but does not ack the messages. + * It will then close the session, recreate a new session + * and will then try to verify the queue depth. + * For unreliable the messages should have been taken off the queue. + * For at-least-once the messages should be put back onto the queue. + * + */ + public void testReliabilityOptions() throws Exception + { + Session jmsSession = _connection.createSession(false,Session.CLIENT_ACKNOWLEDGE); + MessageConsumer cons; + MessageProducer prod; + + String addr1 = "ADDR:testQueue1;{create: always, delete : receiver, link : {reliability : unreliable}}"; + AMQDestination dest = new AMQAnyDestination(addr1); + cons = jmsSession.createConsumer(dest); + prod = jmsSession.createProducer(dest); + + prod.send(jmsSession.createTextMessage("A")); + prod.send(jmsSession.createTextMessage("B")); + + // We are only receiving one message, but both messages should be taken off the queue. + Message msg = cons.receive(1000); + assertNotNull(msg); + assertEquals("A",((TextMessage)msg).getText()); + + jmsSession.close(); + jmsSession = _connection.createSession(false,Session.CLIENT_ACKNOWLEDGE); + long queueDepth = ((AMQSession) jmsSession).getQueueDepth(dest); + assertEquals(0,queueDepth); + cons.close(); + prod.close(); + + String addr2 = "ADDR:testQueue2;{create: always, delete : receiver, link : {reliability : at-least-once}}"; + dest = new AMQAnyDestination(addr2); + cons = jmsSession.createConsumer(dest); + prod = jmsSession.createProducer(dest); + + // We are receiving both messages but both should be put back into the queue + // bcos we don't ack them. + prod.send(jmsSession.createTextMessage("A")); + prod.send(jmsSession.createTextMessage("B")); + + msg = cons.receive(1000); + assertNotNull(msg); + assertEquals("A",((TextMessage)msg).getText()); + + msg = cons.receive(1000); + assertNotNull(msg); + assertEquals("B",((TextMessage)msg).getText()); + + jmsSession.close(); + jmsSession = _connection.createSession(false,Session.CLIENT_ACKNOWLEDGE); + queueDepth = ((AMQSession) jmsSession).getQueueDepth(dest); + assertEquals(2,queueDepth); + cons.close(); + prod.close(); + + String addr3 = "ADDR:testQueue2;{create: always, delete : receiver, link : {reliability : exactly-once}}"; + try + { + dest = new AMQAnyDestination(addr3); + fail("An exception should be thrown indicating it's an unsupported type"); + } + catch(Exception e) + { + assertTrue(e.getCause().getMessage().contains("The reliability mode 'exactly-once' is not yet supported")); + } + + String addr4 = "ADDR:amq.topic/test;{link : {reliability : at-least-once}}"; + try + { + dest = new AMQAnyDestination(addr4); + cons = jmsSession.createConsumer(dest); + fail("An exception should be thrown indicating it's an unsupported combination"); + } + catch(Exception e) + { + assertTrue(e.getCause().getMessage().contains("AT-LEAST-ONCE is not yet supported for Topics")); + } + } } |