Author: rajith
Date: Fri Dec  7 22:52:41 2012
New Revision: 1418539

URL: http://svn.apache.org/viewvc?rev=1418539&view=rev
Log:
QPID-4496 Added error handling to cover the cases mentioned in the JIRA.

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

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1418539&r1=1418538&r2=1418539&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
 Fri Dec  7 22:52:41 2012
@@ -1095,7 +1095,7 @@ public class AMQSession_0_10 extends AMQ
         return AMQMessageDelegateFactory.FACTORY_0_10;
     }
     
-    public boolean isExchangeExist(AMQDestination dest,boolean assertNode)
+    public boolean isExchangeExist(AMQDestination dest,boolean assertNode) 
throws AMQException
     {
         boolean match = true;
         ExchangeQueryResult result = 
getQpidSession().exchangeQuery(dest.getAddressName(), Option.NONE).get();
@@ -1118,6 +1118,12 @@ public class AMQSession_0_10 extends AMQ
                 dest.setExchangeClass(new AMQShortString(result.getType()));
             }
         }
+
+        if (assertNode)
+        {
+            if (!match) throw new AMQException("Aessert failed for address : " 
+ dest  +", Result was : " + result);
+        }
+
         return match;
     }
     
@@ -1137,9 +1143,10 @@ public class AMQSession_0_10 extends AMQ
                          (result.getExclusive() == node.isExclusive()) &&
                          
(matchProps(result.getArguments(),node.getDeclareArgs()));
             }
-            else if (match)
+
+            if (assertNode)
             {
-                // should I use the queried details to update the local data 
structure.
+                if (!match) throw new AMQException("Aessert failed for address 
: " + dest  +", Result was : " + result);
             }
         }
         catch(SessionException e)
@@ -1218,32 +1225,32 @@ public class AMQSession_0_10 extends AMQ
             {
                 case AMQDestination.QUEUE_TYPE: 
                 {
-                    if (isQueueExist(dest,assertNode))
+                    if(createNode)
                     {
                         setLegacyFieldsForQueueType(dest);
+                        handleQueueNodeCreation(dest,noLocal);
                         break;
                     }
-                    else if(createNode)
+                    else if (isQueueExist(dest,assertNode))
                     {
                         setLegacyFieldsForQueueType(dest);
-                        handleQueueNodeCreation(dest,noLocal);
                         break;
-                    }                
+                    }
                 }
                 
                 case AMQDestination.TOPIC_TYPE: 
                 {
-                    if (isExchangeExist(dest,assertNode))
+                    if(createNode)
                     {                    
                         setLegacyFiledsForTopicType(dest);
                         verifySubject(dest);
+                        handleExchangeNodeCreation(dest);
                         break;
                     }
-                    else if(createNode)
+                    else if (isExchangeExist(dest,assertNode))
                     {                    
                         setLegacyFiledsForTopicType(dest);
                         verifySubject(dest);
-                        handleExchangeNodeCreation(dest);
                         break;
                     }
                 }

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=1418539&r1=1418538&r2=1418539&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
 Fri Dec  7 22:52:41 2012
@@ -96,7 +96,7 @@ public class AddressBasedDestinationTest
         }
             
         assertFalse("Queue should not be created",(
-                (AMQSession_0_10)jmsSession).isQueueExist(dest,true));
+                (AMQSession_0_10)jmsSession).isQueueExist(dest,false));
         
         
         // create always -------------------------------------------
@@ -1033,7 +1033,7 @@ public class AddressBasedDestinationTest
         }
         
         assertFalse("Queue not deleted as expected",(
-                (AMQSession_0_10)jmsSession).isQueueExist(dest, true));
+                (AMQSession_0_10)jmsSession).isQueueExist(dest, false));
         
         
         String addr2 = "ADDR:testQueue2;{create: always, delete: receiver}";



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to