summaryrefslogtreecommitdiff
path: root/qpid/java/systests
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-01-07 17:58:41 +0000
committerKeith Wall <kwall@apache.org>2014-01-07 17:58:41 +0000
commitfc2867bccfeab4126352e2ac5bec0a6e63b46b53 (patch)
treed0774c95aad6ee1a8049d17e80b1839a9b519807 /qpid/java/systests
parentf7386e281f61e6921254f6da2c9aa6850a5bf722 (diff)
downloadqpid-python-fc2867bccfeab4126352e2ac5bec0a6e63b46b53.tar.gz
QPID-5420: Restore ability to consume using BURLs specifying default exchange.
* Java Broker: Changed AbstractVirtualHost so that createExchange throws ExchangeExistException before checking for a reserved exchnage name. The effect will be that the Java Broker will again accept active declaration of the built in exchanges (amq.*, qpid.* and default). * Java Broker: Changed the 0-8..0-9-1 ExchangeBoundHandler so that a null exchnage name is treated to mean the default exchange. This matches the behaviour of ServerSessionDelegate#exchangeBound() on the 0-10 path. This allows the Java client to query bindings on the default exchange. * Client: Changed AbstractAMQMessageDelegate.java so that 0-10 knows the type of the default exchange when populating the JMSDestination on received messages. * Client: Introduced system property qpid.bind_queues system property so that the exchange/queue bind side effect can be suppressed on consumer creation. Like qid.declare_exchanges and declare_queues, this system propery has effect when using BURLs. Might be useful if using a new client with older broker. * Added new system tests. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1556292 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java110
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java23
2 files changed, 72 insertions, 61 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
index 1ee5b997f2..760884e654 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
@@ -20,18 +20,17 @@
*/
package org.apache.qpid.test.client.message;
-import org.apache.qpid.client.AMQAnyDestination;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.CustomJMSXProperty;
import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.management.common.mbeans.ManagedQueue;
import org.apache.qpid.test.utils.JMXTestUtils;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
import javax.jms.Connection;
import javax.jms.Destination;
+import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
@@ -41,7 +40,7 @@ import javax.jms.Session;
import javax.jms.Topic;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.TabularData;
-import java.nio.BufferOverflowException;
+
import java.util.Iterator;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -88,15 +87,15 @@ public class JMSDestinationTest extends QpidBrokerTestCase
_connection.start();
- Message message = consumer.receive(10000);
+ Message receivedMessage = consumer.receive(10000);
- assertNotNull("Message should not be null", message);
+ assertNotNull("Message should not be null", receivedMessage);
- Destination destination = message.getJMSDestination();
+ Destination receivedDestination = receivedMessage.getJMSDestination();
- assertNotNull("JMSDestination should not be null", destination);
+ assertNotNull("JMSDestination should not be null", receivedDestination);
- assertEquals("Incorrect Destination type", queue.getClass(), destination.getClass());
+ assertEquals("Incorrect Destination type", queue.getClass(), receivedDestination.getClass());
}
/**
@@ -115,15 +114,14 @@ public class JMSDestinationTest extends QpidBrokerTestCase
_connection.start();
- Message message = consumer.receive(10000);
-
- assertNotNull("Message should not be null", message);
+ Message receivedMessage = consumer.receive(10000);
- Destination destination = message.getJMSDestination();
+ assertNotNull("Message should not be null", receivedMessage);
- assertNotNull("JMSDestination should not be null", destination);
+ Destination receivedDestination = receivedMessage.getJMSDestination();
- assertEquals("Incorrect Destination type", topic.getClass(), destination.getClass());
+ assertNotNull("JMSDestination should not be null", receivedDestination);
+ assertEquals("Incorrect Destination type", topic.getClass(), receivedDestination.getClass());
}
/**
@@ -191,11 +189,11 @@ public class JMSDestinationTest extends QpidBrokerTestCase
assertNotNull("Message should not be null", message);
- Destination destination = message.getJMSDestination();
+ Destination receivedDestination = message.getJMSDestination();
- assertNotNull("JMSDestination should not be null", destination);
+ assertNotNull("JMSDestination should not be null", receivedDestination);
- assertEquals("Incorrect Destination type", queue.getClass(), destination.getClass());
+ assertEquals("Incorrect Destination type", queue.getClass(), receivedDestination.getClass());
}
finally
@@ -238,11 +236,11 @@ public class JMSDestinationTest extends QpidBrokerTestCase
assertNotNull("Message should not be null", _message);
- Destination destination = _message.getJMSDestination();
+ Destination receivedDestination = _message.getJMSDestination();
- assertNotNull("JMSDestination should not be null", destination);
+ assertNotNull("JMSDestination should not be null", receivedDestination);
- assertEquals("Incorrect Destination type", queue.getClass(), destination.getClass());
+ assertEquals("Incorrect Destination type", queue.getClass(), receivedDestination.getClass());
}
/**
@@ -305,17 +303,7 @@ public class JMSDestinationTest extends QpidBrokerTestCase
// b) we can actually send without a BufferOverFlow.
MessageProducer producer = session08.createProducer(queue);
-
- try
- {
- producer.send(message);
- }
- catch (BufferOverflowException bofe)
- {
- // Print the stack trace so we can validate where the execption occured.
- bofe.printStackTrace();
- fail("BufferOverflowException thrown during send");
- }
+ producer.send(message);
message = consumer.receive(1000);
@@ -327,45 +315,45 @@ public class JMSDestinationTest extends QpidBrokerTestCase
}
- /**
- * Send a message to a custom exchange and then verify
- * the message received has the proper destination set
- *
- * @throws Exception
- */
- public void testGetDestinationWithCustomExchange() throws Exception
+ public void testQueueWithBindingUrlUsingCustomExchange() throws Exception
{
-
- AMQDestination dest = new AMQAnyDestination(new AMQShortString("my-exchange"),
- new AMQShortString("direct"),
- new AMQShortString("test"),
- false,
- false,
- new AMQShortString("test"),
- false,
- new AMQShortString[]{new AMQShortString("test")});
-
- // to force the creation of my-exchange.
- sendMessage(_session, dest, 1);
-
- MessageProducer prod = _session.createProducer(dest);
+ String exchangeName = "exch_" + getTestQueueName();
+ String queueName = "queue_" + getTestQueueName();
+ String address = String.format("direct://%s/%s/%s?routingkey='%s'", exchangeName, queueName, queueName, queueName);
+ sendReceive(address);
+ }
+
+ public void testQueueWithBindingUrlUsingAmqDirectExchange() throws Exception
+ {
+ String queueName = getTestQueueName();
+ String address = String.format("direct://amq.direct/%s/%s?routingkey='%s'", queueName, queueName, queueName);
+ sendReceive(address);
+ }
+
+ public void testQueueWithBindingUrlUsingDefaultExchange() throws Exception
+ {
+ String queueName = getTestQueueName();
+ String address = String.format("direct:///%s/%s?routingkey='%s'", queueName, queueName, queueName);
+ sendReceive(address);
+ }
+
+ private void sendReceive(String address) throws JMSException, Exception
+ {
+ Destination dest = _session.createQueue(address);
MessageConsumer consumer = _session.createConsumer(dest);
-
+
_connection.start();
sendMessage(_session, dest, 1);
-
- Message message = consumer.receive(10000);
- assertNotNull("Message should not be null", message);
+ Message receivedMessage = consumer.receive(10000);
- Destination destination = message.getJMSDestination();
+ assertNotNull("Message should not be null", receivedMessage);
- assertNotNull("JMSDestination should not be null", destination);
+ Destination receivedDestination = receivedMessage.getJMSDestination();
- assertEquals("Incorrect Destination name", "my-exchange", dest.getExchangeName().asString());
- assertEquals("Incorrect Destination type", "direct", dest.getExchangeClass().asString());
- assertEquals("Incorrect Routing Key", "test", dest.getRoutingKey().asString());
+ assertNotNull("JMSDestination should not be null", receivedDestination);
+ assertEquals("JMSDestination should match that sent", address, receivedDestination.toString());
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java
index 734e3f2268..77df6c58d9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java
@@ -31,6 +31,7 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.url.BindingURL;
import javax.jms.Connection;
+import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.Session;
@@ -158,6 +159,28 @@ public class DynamicQueueExchangeCreateTest extends QpidBrokerTestCase
assertFalse("exchange should not exist", _jmxUtils.doesManagedObjectExist(exchangeObjectName2));
}
+ public void testQueueNotBoundDuringConsumerCreation() throws Exception
+ {
+ setSystemProperty(ClientProperties.QPID_BIND_QUEUES_PROP_NAME, "false");
+ setSystemProperty(ClientProperties.VERIFY_QUEUE_ON_SEND, "true");
+
+ Connection connection = getConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(getTestQueueName());
+ session.createConsumer(queue);
+
+ try
+ {
+ session.createProducer(queue).send(session.createMessage());
+ fail("JMSException should be thrown as the queue does not exist");
+ }
+ catch (InvalidDestinationException ide)
+ {
+ //PASS
+ }
+ }
private void checkExceptionErrorCode(JMSException original, AMQConstant code)
{
Exception linked = original.getLinkedException();