summaryrefslogtreecommitdiff
path: root/qpid/java/systests
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2011-03-09 20:45:24 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2011-03-09 20:45:24 +0000
commit8ddbd871ceae16f7900e2e623467abbc57dd3a90 (patch)
treebcba0a13e7778cbef00f334c052761e7ac75d96d /qpid/java/systests
parent4b5d41f653587be4083cde86962447c1d2431916 (diff)
downloadqpid-python-8ddbd871ceae16f7900e2e623467abbc57dd3a90.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@1079986 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.java91
1 files changed, 91 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 f24e45ec93..83bb4175a3 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
@@ -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"));
+ }
+ }
}