You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2011/03/09 21:45:25 UTC

svn commit: r1079986 - /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java

Author: rajith
Date: Wed Mar  9 20:45:24 2011
New Revision: 1079986

URL: http://svn.apache.org/viewvc?rev=1079986&view=rev
Log:
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.

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java?rev=1079986&r1=1079985&r2=1079986&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java Wed Mar  9 20:45:24 2011
@@ -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
 
         
     }
+    
+    /**
+     * 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"));
+        }
+    }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org