You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2011/08/04 14:31:25 UTC

svn commit: r1153864 - in /qpid/trunk/qpid/java: broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java test-profiles/Java010Excludes

Author: robbie
Date: Thu Aug  4 12:31:24 2011
New Revision: 1153864

URL: http://svn.apache.org/viewvc?rev=1153864&view=rev
Log:
QPID-2903, QPID-3390, QPID-3392: split tests into those with and without exchange creation arguments, add verification of exchange declare arguments, add new test to validate behaviour when supplying nonsense/unsupported arguments, exclude failign tests until functionality is implemented

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
    qpid/trunk/qpid/java/test-profiles/Java010Excludes

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java?rev=1153864&r1=1153863&r2=1153864&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java Thu Aug  4 12:31:24 2011
@@ -457,6 +457,19 @@ public class ServerSessionDelegate exten
         VirtualHost virtualHost = getVirtualHost(session);
         Exchange exchange = getExchange(session, exchangeName);
 
+        //we must check for any unsupported arguments present and throw not-implemented
+        if(method.hasArguments())
+        {
+            Map<String,Object> args = method.getArguments();
+
+            //QPID-3392: currently we don't support any!
+            if(!args.isEmpty())
+            {
+                exception(session, method, ExecutionErrorCode.NOT_IMPLEMENTED, "Unsupported exchange argument(s) found " + args.keySet().toString());
+                return;
+            }
+        }
+
         if(method.getPassive())
         {
             if(exchange == null)
@@ -466,7 +479,6 @@ public class ServerSessionDelegate exten
             }
             else
             {
-                // TODO - check exchange has same properties
                 if(!exchange.getTypeShortString().toString().equals(method.getType()))
                 {
                     exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Cannot redeclare with a different exchange type");

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=1153864&r1=1153863&r2=1153864&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 Thu Aug  4 12:31:24 2011
@@ -55,6 +55,7 @@ import org.apache.qpid.client.messaging.
 import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
 import org.apache.qpid.messaging.Address;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.transport.ExecutionErrorCode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -269,8 +270,33 @@ public class AddressBasedDestinationTest
     
     public void testCreateExchange() throws Exception
     {
+        createExchangeImpl(false, false);
+    }
+
+    /**
+     * Verify creating an exchange via an Address, with supported
+     * exchange-declare arguments.
+     */
+    public void testCreateExchangeWithArgs() throws Exception
+    {
+        createExchangeImpl(true, false);
+    }
+
+    /**
+     * Verify that when creating an exchange via an Address, if a
+     * nonsense argument is specified the broker throws an execution
+     * exception back on the session with NOT_IMPLEMENTED status.
+     */
+    public void testCreateExchangeWithNonsenseArgs() throws Exception
+    {
+        createExchangeImpl(true, true);
+    }
+
+    private void createExchangeImpl(final boolean withExchangeArgs,
+            final boolean useNonsenseArguments) throws Exception
+    {
         Session jmsSession = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
-        
+
         String addr = "ADDR:my-exchange/hello; " + 
                       "{ " + 
                         "create: always, " +                        
@@ -280,17 +306,36 @@ public class AddressBasedDestinationTest
                              "x-declare: " +
                              "{ " + 
                                  "type:direct, " + 
-                                 "auto-delete: true, " +
-                                 "arguments: {" +  
-                                   "'qpid.msg_sequence': 1, " +
-                                   "'qpid.ive': 1" +
-                                 "}" +
+                                 "auto-delete: true" +
+                                 createExchangeArgsString(withExchangeArgs, useNonsenseArguments) +
                              "}" +
                         "}" +
                       "}";
         
         AMQDestination dest = new AMQAnyDestination(addr);
-        MessageConsumer cons = jmsSession.createConsumer(dest); 
+
+        MessageConsumer cons;
+        try
+        {
+            cons = jmsSession.createConsumer(dest);
+            if(useNonsenseArguments)
+            {
+                fail("Expected execution exception during exchange declare did not occur");
+            }
+        }
+        catch(JMSException e)
+        {
+            if(useNonsenseArguments && e.getCause().getMessage().contains(ExecutionErrorCode.NOT_IMPLEMENTED.toString()))
+            {
+                //expected because we used an argument which the broker doesn't have functionality
+                //for. We can't do the rest of the test as a result of the exception, just stop.
+                return;
+            }
+            else
+            {
+                fail("Unexpected exception whilst creating consumer: " + e);
+            }
+        }
         
         assertTrue("Exchange not created as expected",(
                 (AMQSession_0_10)jmsSession).isExchangeExist(dest, (ExchangeNode)dest.getTargetNode() , true));
@@ -305,6 +350,32 @@ public class AddressBasedDestinationTest
         cons = jmsSession.createConsumer(dest); 
     }
     
+    private String createExchangeArgsString(final boolean withExchangeArgs,
+                                            final boolean useNonsenseArguments)
+    {
+        String argsString;
+
+        if(withExchangeArgs && useNonsenseArguments)
+        {
+            argsString = ", arguments: {" +
+            "'abcd.1234.wxyz': 1, " +
+            "}";
+        }
+        else if(withExchangeArgs)
+        {
+            argsString = ", arguments: {" +
+            "'qpid.msg_sequence': 1, " +
+            "'qpid.ive': 1" +
+            "}";
+        }
+        else
+        {
+            argsString = "";
+        }
+
+        return argsString;
+    }
+
     public void checkQueueForBindings(Session jmsSession, AMQDestination dest,String headersBinding) throws Exception
     {
     	assertTrue("Queue not created as expected",(
@@ -558,11 +629,25 @@ public class AddressBasedDestinationTest
     }
     
     /**
-     * Test goal: Verifies that session.creatTopic method
-     *            works as expected both with the new and old addressing scheme.
+     * Test goal: Verifies that session.creatTopic method works as expected
+     * both with the new and old addressing scheme.
      */
     public void testSessionCreateTopic() throws Exception
     {
+        sessionCreateTopicImpl(false);
+    }
+
+    /**
+     * Test goal: Verifies that session.creatTopic method works as expected
+     * both with the new and old addressing scheme when adding exchange arguments.
+     */
+    public void testSessionCreateTopicWithExchangeArgs() throws Exception
+    {
+        sessionCreateTopicImpl(true);
+    }
+
+    private void sessionCreateTopicImpl(boolean withExchangeArgs) throws Exception
+    {
         Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
         
         // Using the BURL method
@@ -582,7 +667,7 @@ public class AddressBasedDestinationTest
         prod.send(ssn.createTextMessage("test"));
         assertNotNull("consumer should receive a message",cons.receive(1000));
         cons.close();
-        
+
         String addr = "ADDR:vehicles/bus; " + 
         "{ " + 
           "create: always, " +                        
@@ -592,11 +677,8 @@ public class AddressBasedDestinationTest
                "x-declare: " +
                "{ " + 
                    "type:direct, " + 
-                   "auto-delete: true, " +
-                   "arguments: {" +  
-                       "'qpid.msg_sequence': 1, " +
-                       "'qpid.ive': 1" + 
-                   "}" +
+                   "auto-delete: true" +
+                   createExchangeArgsString(withExchangeArgs, false) +
                "}" +
           "}, " +
           "link: {name : my-topic, " +

Modified: qpid/trunk/qpid/java/test-profiles/Java010Excludes
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/Java010Excludes?rev=1153864&r1=1153863&r2=1153864&view=diff
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/Java010Excludes (original)
+++ qpid/trunk/qpid/java/test-profiles/Java010Excludes Thu Aug  4 12:31:24 2011
@@ -77,8 +77,11 @@ org.apache.qpid.test.unit.client.channel
 
 //Temporarily adding the following until the issues are sorted out.
 //Should probably raise JIRAs for them.
-org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testCreateExchange
 org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testBrowseMode
 
 // QPID-3133: On 0-10, the exception listener is currently not invoked when reconnection fails to occurs. 
 org.apache.qpid.server.failover.FailoverMethodTest#*
+
+// QPID-3092: the Java broker does not yet implement exchange creation arguments
+org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testCreateExchangeWithArgs
+org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testSessionCreateTopicWithExchangeArgs



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