diff options
| author | Robert Gemmell <robbie@apache.org> | 2013-02-05 14:22:56 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2013-02-05 14:22:56 +0000 |
| commit | ef99cf5da8833eb4a8a456741566b7a55f7ef64b (patch) | |
| tree | 9a45cac5dd6ebae99c2919fe08b3e7ff88aed43e /java/client | |
| parent | cffa3637701472511da91eeee1e9c989bfc02f7a (diff) | |
| download | qpid-python-ef99cf5da8833eb4a8a456741566b7a55f7ef64b.tar.gz | |
QPID-4312: reduce visibility and narrow argument type for new check methods, add some unit testing of config and cleanup IDT systest a little
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1442602 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
3 files changed, 78 insertions, 10 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java index 20eaca44ae..308c63923e 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java @@ -590,20 +590,21 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac } - void checkValidQueue() throws JMSException + private void checkValidQueue() throws JMSException { if(_destination instanceof AMQQueue) { - checkValidQueue(_destination); + checkValidQueue((AMQQueue) _destination); } } - void checkValidQueue(AMQDestination destination) throws JMSException + + private void checkValidQueue(AMQQueue destination) throws JMSException { if (!destination.isCheckedForQueueBinding() && validateQueueOnSend()) { if (getSession().isStrictAMQP()) { - getLogger().warn("AMQP does not support destination validation before publish, "); + getLogger().warn("AMQP does not support destination validation before publish"); destination.setCheckedForQueueBinding(true); } else @@ -615,7 +616,7 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac else { throw new InvalidDestinationException("Queue: " + destination.getName() - + " is not a valid destination (no bindings on server"); + + " is not a valid destination (no binding on server)"); } } } diff --git a/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java b/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java index 891cb9581c..d309251b44 100644 --- a/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java +++ b/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java @@ -20,18 +20,53 @@ */ package org.apache.qpid.client; -import junit.framework.TestCase; - -import org.apache.qpid.AMQInvalidArgumentException; +import java.util.concurrent.atomic.AtomicReference; import javax.jms.ExceptionListener; import javax.jms.JMSException; -import java.util.concurrent.atomic.AtomicReference; -public class AMQConnectionUnitTest extends TestCase +import org.apache.qpid.AMQInvalidArgumentException; +import org.apache.qpid.configuration.ClientProperties; +import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.test.utils.QpidTestCase; + +public class AMQConnectionUnitTest extends QpidTestCase { String _url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'"; + public void testVerifyQueueOnSendDefault() throws Exception + { + MockAMQConnection connection = new MockAMQConnection(_url); + assertFalse(connection.validateQueueOnSend()); + } + + public void testVerifyQueueOnSendViaSystemProperty() throws Exception + { + setTestSystemProperty(ClientProperties.VERIFY_QUEUE_ON_SEND, "true"); + MockAMQConnection connection = new MockAMQConnection(_url); + assertTrue(connection.validateQueueOnSend()); + + setTestSystemProperty(ClientProperties.VERIFY_QUEUE_ON_SEND, "false"); + connection = new MockAMQConnection(_url); + assertFalse(connection.validateQueueOnSend()); + } + + public void testVerifyQueueOnSendViaURL() throws Exception + { + MockAMQConnection connection = new MockAMQConnection(_url + "&" + ConnectionURL.OPTIONS_VERIFY_QUEUE_ON_SEND + "='true'"); + assertTrue(connection.validateQueueOnSend()); + + connection = new MockAMQConnection(_url + "&" + ConnectionURL.OPTIONS_VERIFY_QUEUE_ON_SEND + "='false'"); + assertFalse(connection.validateQueueOnSend()); + } + + public void testVerifyQueueOnSendViaURLoverridesSystemProperty() throws Exception + { + setTestSystemProperty(ClientProperties.VERIFY_QUEUE_ON_SEND, "false"); + MockAMQConnection connection = new MockAMQConnection(_url + "&" + ConnectionURL.OPTIONS_VERIFY_QUEUE_ON_SEND + "='true'"); + assertTrue(connection.validateQueueOnSend()); + } + public void testExceptionReceived() { AMQInvalidArgumentException expectedException = new AMQInvalidArgumentException("Test", null); @@ -79,4 +114,5 @@ public class AMQConnectionUnitTest extends TestCase MockAMQConnection connection = new MockAMQConnection(_url + "&use_legacy_stream_msg_format='false'"); assertFalse("Stream message encoding should be amqp/list",connection.isUseLegacyStreamMessageFormat()); } + } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java index ac6cad879b..8c193622e3 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java @@ -591,5 +591,36 @@ public class ConnectionURLTest extends TestCase assertFalse("value should be false", Boolean.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_SSL))); } + + /** + * Verify that when the {@value ConnectionURL#OPTIONS_VERIFY_QUEUE_ON_SEND} option is not + * specified, asking for the option returns null, such that this can later be used to + * verify it wasn't specified. + */ + public void testDefaultVerifyQueueOnSend() throws URLSyntaxException + { + String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&foo='bar'"; + ConnectionURL connectionURL = new AMQConnectionURL(url); + + assertNull("default ssl value should be null", connectionURL.getOption(ConnectionURL.OPTIONS_SSL)); + } + + /** + * Verify that when the {@value ConnectionURL#OPTIONS_VERIFY_QUEUE_ON_SEND} option is + * specified, asking for the option returns the value, such that this can later be used + * to verify what value it was specified as. + */ + public void testOverridingVerifyQueueOnSend() throws URLSyntaxException + { + String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&verifyQueueOnSend='true'"; + ConnectionURL connectionURL = new AMQConnectionURL(url); + + assertTrue("value should be true", Boolean.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_VERIFY_QUEUE_ON_SEND))); + + url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&verifyQueueOnSend='false'"; + connectionURL = new AMQConnectionURL(url); + + assertFalse("value should be false", Boolean.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_VERIFY_QUEUE_ON_SEND))); + } } |
