From d429e749a971b2157b56e07835ac29c885683342 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 25 Nov 2012 15:42:06 +0000 Subject: QPID-4468: restore connection level ssl option to provide compatibility with older client configuration, add ability to override brokerlist ssl option git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1413364 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/BrokerDetails/BrokerDetailsTest.java | 21 +++++++++++++++ .../client/connectionurl/ConnectionURLTest.java | 30 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'qpid/java/client/src/test') diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java index 71aec68d30..1e9e5b00a5 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java @@ -143,4 +143,25 @@ public class BrokerDetailsTest extends TestCase assertEquals("Unexpected toString", expectedToString, actualToString); } + + public void testDefaultSsl() throws URLSyntaxException + { + String brokerURL = "tcp://localhost:5672"; + AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL); + + assertNull("default value should be null", broker.getProperty(BrokerDetails.OPTIONS_SSL)); + } + + public void testOverridingSsl() throws URLSyntaxException + { + String brokerURL = "tcp://localhost:5672?ssl='true'"; + AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL); + + assertTrue("value should be true", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_SSL))); + + brokerURL = "tcp://localhost:5672?ssl='false''&maxprefetch='1'"; + broker = new AMQBrokerDetails(brokerURL); + + assertFalse("value should be false", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_SSL))); + } } diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java index 69f9954892..ac6cad879b 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java @@ -30,7 +30,6 @@ import org.apache.qpid.url.URLSyntaxException; public class ConnectionURLTest extends TestCase { - public void testFailoverURL() throws URLSyntaxException { String url = "amqp://ritchiem:bob@/test?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin?cyclecount='100''"; @@ -563,5 +562,34 @@ public class ConnectionURLTest extends TestCase assertNull("Reject behaviour option was not as expected", connectionurl.getOption(ConnectionURL.OPTIONS_REJECT_BEHAVIOUR)); } + + /** + * Verify that when the ssl option is not specified, asking for the option returns null, + * such that this can later be used to verify it wasnt specified. + */ + public void testDefaultSsl() 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 ssl 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 testOverridingSsl() throws URLSyntaxException + { + String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&ssl='true'"; + ConnectionURL connectionURL = new AMQConnectionURL(url); + + assertTrue("value should be true", Boolean.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_SSL))); + + url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&ssl='false'"; + connectionURL = new AMQConnectionURL(url); + + assertFalse("value should be false", Boolean.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_SSL))); + } } -- cgit v1.2.1