From ffb25827f64be630818220eb267f95d38af75ca7 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 3 Mar 2011 01:41:18 +0000 Subject: NO-JIRA: Update version and broker constants for tests Setup more version constants in QpidBrokerTestCase and update test-profiles to explicitly set versions. Creates 0-8 and 0-10 version profiles, and sets the default protocol version to be 0-9-1 for the others. Protocol version negotiation is accomplished under the Java profiles by disabling versions on the ports the broker is listening on. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/grkvlt-network-20110301@1076486 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQBrokerDetails.java | 44 +++++++++---------- .../org/apache/qpid/client/url/URLParser_0_10.java | 49 +++++++++++----------- .../java/org/apache/qpid/jms/BrokerDetails.java | 21 +++------- .../client/connectionurl/ConnectionURLTest.java | 6 +-- .../apache/qpid/transport/network/Transport.java | 25 ++++++++--- .../qpid/server/logging/ChannelLoggingTest.java | 4 +- .../qpid/test/unit/client/AMQConnectionTest.java | 2 +- .../qpid/test/unit/ct/DurableSubscriberTest.java | 4 +- .../org/apache/qpid/test/unit/xa/FaultTest.java | 4 +- .../org/apache/qpid/test/unit/xa/QueueTest.java | 10 ++--- .../org/apache/qpid/test/unit/xa/TopicTest.java | 18 ++++---- .../apache/qpid/test/utils/QpidBrokerTestCase.java | 6 +++ .../java/test-profiles/java-derby.0.10.testprofile | 8 +++- qpid/java/test-profiles/java-derby.0.8.testprofile | 33 +++++++++++++++ qpid/java/test-profiles/java-derby.testprofile | 10 ++--- qpid/java/test-profiles/java.0.10.testprofile | 5 ++- qpid/java/test-profiles/java.0.8.testprofile | 29 +++++++++++++ qpid/java/test-profiles/java.testprofile | 9 ++-- 18 files changed, 182 insertions(+), 105 deletions(-) create mode 100644 qpid/java/test-profiles/java-derby.0.8.testprofile create mode 100644 qpid/java/test-profiles/java.0.8.testprofile diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java index ee52cd50af..f1563b1f18 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.qpid.jms.BrokerDetails; -import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.transport.network.Transport; import org.apache.qpid.url.URLHelper; import org.apache.qpid.url.URLSyntaxException; @@ -42,23 +42,26 @@ public class AMQBrokerDetails implements BrokerDetails public AMQBrokerDetails(){} + /** + * URL in format {@link BrokerDetails#URL_FORMAT_EXAMPLE}. + * + * @throws URLSyntaxException + */ public AMQBrokerDetails(String url) throws URLSyntaxException { - - // URL should be of format tcp://host:port?option='value',option='value' try { URI connection = new URI(url); + // FIXME transport and scheme are not necessarily the same thing String transport = connection.getScheme(); // Handles some defaults to minimise changes to existing broker URLS e.g. localhost if (transport != null) { - //todo this list of valid transports should be enumerated somewhere - if ((!(transport.equalsIgnoreCase(BrokerDetails.VM) || - transport.equalsIgnoreCase(BrokerDetails.TCP) || - transport.equalsIgnoreCase(BrokerDetails.SOCKET)))) + if ((!(transport.equalsIgnoreCase(Transport.VM) || + transport.equalsIgnoreCase(Transport.TCP) || + transport.equalsIgnoreCase(Transport.SOCKET)))) { if (transport.equalsIgnoreCase("localhost")) { @@ -69,7 +72,7 @@ public class AMQBrokerDetails implements BrokerDetails { if (url.charAt(transport.length()) == ':' && url.charAt(transport.length() + 1) != '/') { - //Then most likely we have a host:port value + // Then most likely we have a host:port value connection = new URI(DEFAULT_TRANSPORT + "://" + url); transport = connection.getScheme(); } @@ -81,20 +84,19 @@ public class AMQBrokerDetails implements BrokerDetails } else if (url.indexOf("//") == -1) { - throw new URLSyntaxException(url, "Missing '//' after the transport In broker URL",transport.length()+1,1); + throw new URLSyntaxException(url, "Missing '//' after the transport In broker URI", transport.length() + 1, 1); } } else { - //Default the transport + // Default the transport connection = new URI(DEFAULT_TRANSPORT + "://" + url); transport = connection.getScheme(); } if (transport == null) { - throw URLHelper.parseError(-1, "Unknown transport in broker URL:'" - + url + "' Format: " + URL_FORMAT_EXAMPLE, ""); + throw URLHelper.parseError(-1, "Unknown transport in broker URI:'" + url + "' Format: " + URL_FORMAT_EXAMPLE, ""); } setTransport(transport); @@ -122,7 +124,7 @@ public class AMQBrokerDetails implements BrokerDetails int end = start; boolean looking = true; boolean found = false; - // Throw an URL exception if the port number is not specified + // Throw a URL exception if the port number is not specified if (start == auth.length()) { throw URLHelper.parseError(connection.toString().indexOf(auth) + end - 1, @@ -167,7 +169,7 @@ public class AMQBrokerDetails implements BrokerDetails } else { - if (!_transport.equalsIgnoreCase(SOCKET)) + if (!_transport.equalsIgnoreCase(Transport.SOCKET)) { setPort(port); } @@ -287,12 +289,12 @@ public class AMQBrokerDetails implements BrokerDetails sb.append(_transport); sb.append("://"); - if (!(_transport.equalsIgnoreCase(VM))) + if (!(_transport.equalsIgnoreCase(Transport.VM))) { sb.append(_host); } - if (!(_transport.equalsIgnoreCase(SOCKET))) + if (!(_transport.equalsIgnoreCase(Transport.SOCKET))) { sb.append(':'); sb.append(_port); @@ -303,6 +305,7 @@ public class AMQBrokerDetails implements BrokerDetails return sb.toString(); } + @Override public boolean equals(Object o) { if (!(o instanceof BrokerDetails)) @@ -336,16 +339,9 @@ public class AMQBrokerDetails implements BrokerDetails if (!(_options.isEmpty())) { - for (String key : _options.keySet()) { - optionsURL.append(key); - - optionsURL.append("='"); - - optionsURL.append(_options.get(key)); - - optionsURL.append("'"); + optionsURL.append(key).append("='").append(_options.get(key)).append("'"); optionsURL.append(URLHelper.DEFAULT_OPTION_SEPERATOR); } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java index 605e9ee154..11be1c095c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java @@ -23,30 +23,32 @@ import java.util.List; import org.apache.qpid.client.AMQBrokerDetails; import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.transport.network.Transport; /** * The format Qpid URL is based on the AMQP one. * The grammar is as follows: - *

qpid_url = "qpid:" [client_props "@"] port_addr_list ["/" future-parameters] - *

port_addr_list = [port_addr ","]* port_addr - *

port_addr = tcp_port_addr | tls_prot_addr | future_prot_addr - *

tcp_port_addr = tcp_id tcp_addr - *

tcp_id = "tcp:" | "" - *

tcp_addr = host [":" port] - *

host = - *

port = number - *

tls_prot_addr = tls_id tls_addr - *

tls_id = "tls:" | "" - *

tls_addr = host [":" port] - *

future_prot_addr = future_prot_id future_prot_addr - *

future_prot_id = - *

future_prot_addr = - *

future_parameters = - *

client_props = [client_prop ";"]* client_prop - *

client_prop = prop "=" val - *

prop = chars as per - *

val = valid as per - *

+ *

* Ex: qpid:virtualhost=tcp:host-foo,test,client_id=foo@tcp:myhost.com:5672,virtualhost=prod; * keystore=/opt/keystore@client_id2@tls:mysecurehost.com:5672 */ @@ -280,14 +282,13 @@ public class URLParser_0_10 private URLParserState extractTransport() { - String transport = buildUntil(TRANSPORT_HOST_SEPARATOR_CHAR); - if (transport.trim().equals("")) + String transport = buildUntil(TRANSPORT_HOST_SEPARATOR_CHAR).trim(); + if (transport.equals("")) { _error = "Transport cannot be empty"; return URLParserState.ERROR; } - else if (!(transport.trim().equals(BrokerDetails.PROTOCOL_TCP) || transport.trim() - .equals(BrokerDetails.PROTOCOL_TLS))) + else if (!(transport.equalsIgnoreCase(Transport.TCP) || transport.equalsIgnoreCase(Transport.TLS))) { _error = "Transport cannot be " + transport + " value must be tcp or tls"; return URLParserState.ERROR; diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java index 6d81f728c9..624ed99f1c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java @@ -23,6 +23,7 @@ package org.apache.qpid.jms; import java.util.Map; import org.apache.qpid.client.SSLConfiguration; +import org.apache.qpid.transport.network.Transport; public interface BrokerDetails { @@ -52,11 +53,7 @@ public interface BrokerDetails public static final int DEFAULT_PORT = 5672; - public static final String SOCKET = "socket"; - public static final String TCP = "tcp"; - public static final String VM = "vm"; - - public static final String DEFAULT_TRANSPORT = TCP; + public static final String DEFAULT_TRANSPORT = Transport.TCP; public static final String URL_FORMAT_EXAMPLE = "://[:][?