qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1657270 - in /qpid/trunk/qpid/java: broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ systests/src/test/java/org/apache/qpid/client/session/ systests/src/test/java/org/apache/qpid/server/logging/ test-pro...
Date Wed, 04 Feb 2015 15:05:37 GMT
Author: kwall
Date: Wed Feb  4 15:05:37 2015
New Revision: 1657270

URL: http://svn.apache.org/r1657270
Log:
QPID-6361: [Java Broker] Change 0-8..0-91 queue declare to no longer consider the durability
when validating an existing queue.

Modified:
    qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
    qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
    qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
    qpid/trunk/qpid/java/test-profiles/Java010Excludes

Modified: qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java?rev=1657270&r1=1657269&r2=1657270&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
Wed Feb  4 15:05:37 2015
@@ -3246,17 +3246,6 @@ public class AMQChannel
                                                          + autoDelete
                                                          + ")");
                 }
-                else if (queue.isDurable() != durable)
-                {
-                    closeChannel(AMQConstant.ALREADY_EXISTS,
-                                                         "Cannot re-declare queue '"
-                                                         + queue.getName()
-                                                         + "' with different durability (was:
"
-                                                         + queue.isDurable()
-                                                         + " requested "
-                                                         + durable
-                                                         + ")");
-                }
                 else
                 {
                     setDefaultQueue(queue);

Modified: qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java?rev=1657270&r1=1657269&r2=1657270&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
Wed Feb  4 15:05:37 2015
@@ -20,48 +20,77 @@
  */
 package org.apache.qpid.client.session;
 
-import java.util.Collections;
-
 import javax.jms.Connection;
+import javax.jms.Destination;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
 
-import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.AMQBindingURL;
 
 public class QueueDeclareTest extends QpidBrokerTestCase
 {
     private Connection _connection;
     private AMQSession<?, ?> _session;
-
     protected void setUp() throws Exception
     {
         super.setUp();
 
         _connection = getConnection();
+        _connection.start();
         _session = (AMQSession<?, ?>) _connection.createSession(true, Session.SESSION_TRANSACTED);
     }
 
     public void testDeclareAndBindWhenQueueIsNotSpecifiedInDestinationUrl() throws Exception
     {
-        AMQQueue destination = new AMQQueue(new AMQBindingURL("topic://amq.topic//?routingkey='testTopic'"));
+        AMQDestination destination = (AMQDestination) _session.createQueue("topic://amq.topic//?routingkey='testTopic'");
 
-        assertEquals("Queue name is generated in parser", AMQShortString.EMPTY_STRING, destination.getAMQQueueName());
+        assertEquals("Non empty queue name unexpectedly generated by parser : " + destination.getAMQQueueName(),
AMQShortString.EMPTY_STRING, destination.getAMQQueueName());
 
-        _session.declareAndBind(destination, FieldTable.convertToFieldTable(Collections.<String,
Object> emptyMap()));
+        _session.declareAndBind(destination);
 
-        assertFalse("Unexpected queue name: [" + destination.getAMQQueueName() + "]", AMQShortString.EMPTY_STRING.equals(destination.getAMQQueueName()));
+        assertFalse("Non empty queue name should have been generated by declareAndBind",
+                    AMQShortString.EMPTY_STRING.equals(destination.getAMQQueueName()));
 
         sendMessage(_session, destination, 1);
+        receiveMessage(destination);
+    }
+
+    public void testDeclareIgnoresNonDurableFlagIfDurableQueueAlreadyExists() throws Exception
+    {
+        String format = "direct://amq.direct//%s?durable='%s'";
+        AMQDestination durable = (AMQDestination) _session.createQueue(String.format(format,
getTestQueueName(), true));
+        AMQDestination nondurable = (AMQDestination) _session.createQueue(String.format(format,
getTestQueueName(), false));
+
+        verifyDurabiltyIgnoreIfQueueExists(durable, nondurable);
+    }
+
+    public void testDeclareIgnoresDurableFlagIfNonDurableQueueAlreadyExists() throws Exception
+    {
+        String format = "direct://amq.direct//%s?durable='%s'";
+        AMQDestination nondurable = (AMQDestination) _session.createQueue(String.format(format,
getTestQueueName(), false));
+        AMQDestination durable = (AMQDestination) _session.createQueue(String.format(format,
getTestQueueName(), true));
 
+        verifyDurabiltyIgnoreIfQueueExists(nondurable, durable);
+    }
+
+    private void verifyDurabiltyIgnoreIfQueueExists(final AMQDestination firstDeclare, final
AMQDestination secondDeclare) throws Exception
+    {
+        _session.declareAndBind(firstDeclare);
+
+        sendMessage(_session, firstDeclare, 1);
+
+        _session.declareAndBind(secondDeclare);
+        receiveMessage(secondDeclare);
+    }
+
+    private void receiveMessage(final Destination destination) throws Exception
+    {
         MessageConsumer consumer = _session.createConsumer(destination);
-        _connection.start();
-        Message message = consumer.receive(1000l);
+        Message message = consumer.receive(RECEIVE_TIMEOUT);
         assertNotNull("Message not received", message);
         _session.commit();
     }

Modified: qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java?rev=1657270&r1=1657269&r2=1657270&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
Wed Feb  4 15:05:37 2015
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.logging;
 
-import org.apache.qpid.AMQChannelClosedException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
@@ -306,54 +305,6 @@ public class ChannelLoggingTest extends
         validateChannelClose(results);
     }
 
-    public void testChannelClosedOnQueueArgumentsMismatch() throws Exception
-    {
-        assertLoggingNotYetOccured(CHANNEL_PREFIX);
-
-        Connection connection = getConnection();
-
-        // Create a session and then close it
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        waitForMessage("CHN-1001");
-
-        String testQueueName = getTestQueueName();
-
-        Queue nonDurableQueue = (Queue) session.createQueue("direct://amq.direct/" + testQueueName
+ "/" + testQueueName
-                + "?durable='false'");
-
-        ((AMQSession<?,?>)session).declareAndBind((AMQDestination)nonDurableQueue);
-
-        Queue durableQueue = (Queue) session.createQueue("direct://amq.direct/" + testQueueName
+ "/" + testQueueName
-                + "?durable='true'");
-        try
-        {
-            ((AMQSession<?,?>)session).declareAndBind((AMQDestination) durableQueue);
-            fail("Exception not thrown");
-        }
-        catch (AMQChannelClosedException acce)
-        {
-            // pass
-        }
-        catch (Exception e)
-        {
-            fail("Wrong exception thrown " + e);
-        }
-        waitForMessage("CHN-1003");
-
-        List<String> results = findMatches(CHANNEL_PREFIX);
-        assertTrue("No CHN messages logged", results.size() > 0);
-
-        String closeLog = results.get(results.size() -1);
-        int closeMessageID = closeLog.indexOf("CHN-1003");
-        assertFalse("CHN-1003 is not found", closeMessageID == -1);
-
-        String closeMessage = closeLog.substring(closeMessageID);
-        assertTrue("Unexpected close channel message :" + closeMessage, Pattern.matches(CHANNEL_CLOSE_FORCED_MESSAGE_PATTERN,
closeMessage));
-
-        session.close();
-        connection.close();
-    }
-
     public void testChannelClosedOnExclusiveQueueDeclaredOnDifferentSession() throws Exception
     {
         assertLoggingNotYetOccured(CHANNEL_PREFIX);

Modified: qpid/trunk/qpid/java/test-profiles/Java010Excludes
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/Java010Excludes?rev=1657270&r1=1657269&r2=1657270&view=diff
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/Java010Excludes (original)
+++ qpid/trunk/qpid/java/test-profiles/Java010Excludes Wed Feb  4 15:05:37 2015
@@ -34,7 +34,6 @@ org.apache.qpid.test.unit.topic.DurableS
 org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartsFlowStopped
 org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartConsumerFlowStarted
 org.apache.qpid.server.logging.ConsumerLoggingTest#testSubscriptionSuspend
-org.apache.qpid.server.logging.ChannelLoggingTest#testChannelClosedOnQueueArgumentsMismatch
 
 // 0-10 is not supported by the MethodRegistry
 org.apache.qpid.test.unit.close.JavaServerCloseRaceConditionTest#*



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message