summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2015-02-04 15:05:37 +0000
committerKeith Wall <kwall@apache.org>2015-02-04 15:05:37 +0000
commit4a190dc734d13de94649f3fca4230cbe1926fc5c (patch)
tree53df9fa07a9bf0681458b6644fb0e19a18d2fbc1 /qpid/java
parentb01427061008ed26afd5a08e18fe1d0ce81dbf25 (diff)
downloadqpid-python-4a190dc734d13de94649f3fca4230cbe1926fc5c.tar.gz
QPID-6361: [Java Broker] Change 0-8..0-91 queue declare to no longer consider the durability when validating an existing queue.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1657270 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java11
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java53
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java49
-rwxr-xr-xqpid/java/test-profiles/Java010Excludes1
4 files changed, 41 insertions, 73 deletions
diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
index d52fb735a2..6108de2fda 100644
--- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
+++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
@@ -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);
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
index fefed5b4ab..f0013a82d7 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/client/session/QueueDeclareTest.java
@@ -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();
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
index 047151684f..7a18bb5ed2 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
@@ -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 AbstractTestLogging
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);
diff --git a/qpid/java/test-profiles/Java010Excludes b/qpid/java/test-profiles/Java010Excludes
index 136bc7918f..7294275684 100755
--- a/qpid/java/test-profiles/Java010Excludes
+++ b/qpid/java/test-profiles/Java010Excludes
@@ -34,7 +34,6 @@ org.apache.qpid.test.unit.topic.DurableSubscriptionTest#testUnsubscribeWhenUsing
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#*