From 509d48d3a12c3477c893456549e0d052d9e5e9f9 Mon Sep 17 00:00:00 2001 From: Robert Greig Date: Mon, 29 Jan 2007 11:05:20 +0000 Subject: (Patch supplied by Tomas Restrepo) QPID-312.diff applied. This converts Javadoc copied accross from the orignal Java code to .Net format. Renames some files/classes/methods to use .Net conventions. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@501006 13f79535-47bb-0310-9956-ffa450edef68 --- dotnet/Qpid.Buffer/BaseByteBuffer.cs | 35 ++- dotnet/Qpid.Buffer/BufferDataException.cs | 8 +- dotnet/Qpid.Buffer/ByteBuffer.cs | 14 +- dotnet/Qpid.Buffer/ByteBufferAllocator.cs | 50 ----- dotnet/Qpid.Buffer/IByteBufferAllocator.cs | 29 +++ dotnet/Qpid.Buffer/Qpid.Buffer.csproj | 4 +- dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs | 16 +- .../Common/BaseMessagingTestFixture.cs | 4 +- .../Qpid.Client.Tests/connection/ConnectionTest.cs | 8 +- dotnet/Qpid.Client.Tests/failover/FailoverTest.cs | 4 +- .../Qpid.Client.Tests/failover/FailoverTxTest.cs | 6 +- dotnet/Qpid.Client.Tests/url/ConnectionUrlTest.cs | 238 ++++++++++----------- dotnet/Qpid.Client/Client/AMQConnection.cs | 30 +-- dotnet/Qpid.Client/Client/AmqBrokerInfo.cs | 118 +++++----- dotnet/Qpid.Client/Client/QpidConnectionInfo.cs | 92 ++++---- dotnet/Qpid.Client/qms/BrokerInfo.cs | 31 +-- dotnet/Qpid.Client/qms/ConnectionInfo.cs | 48 ++--- dotnet/Qpid.Client/qms/FailoverPolicy.cs | 50 ++--- dotnet/Qpid.Client/qms/UrlSyntaxException.cs | 2 +- dotnet/Qpid.Client/qms/failover/FailoverMethod.cs | 81 ++++--- .../Qpid.Client/qms/failover/FailoverRoundRobin.cs | 46 ++-- .../qms/failover/FailoverSingleServer.cs | 40 ++-- 22 files changed, 439 insertions(+), 515 deletions(-) delete mode 100644 dotnet/Qpid.Buffer/ByteBufferAllocator.cs create mode 100644 dotnet/Qpid.Buffer/IByteBufferAllocator.cs (limited to 'dotnet') diff --git a/dotnet/Qpid.Buffer/BaseByteBuffer.cs b/dotnet/Qpid.Buffer/BaseByteBuffer.cs index 099c84d6fa..3a6beabae8 100644 --- a/dotnet/Qpid.Buffer/BaseByteBuffer.cs +++ b/dotnet/Qpid.Buffer/BaseByteBuffer.cs @@ -33,23 +33,21 @@ namespace Qpid.Buffer { - /** - * A base implementation of {@link ByteBuffer}. This implementation - * assumes that {@link ByteBuffer#buf()} always returns a correct NIO - * {@link FixedByteBuffer} instance. Most implementations could - * extend this class and implement their own buffer management mechanism. - * - * @noinspection StaticNonFinalField - * @see ByteBufferAllocator - */ + /// + /// A base implementation of . This implementation + /// assumes that always returns a correct NIO + /// instance. Most implementations could + /// extend this class and implement their own buffer management mechanism. + /// + /// public abstract class BaseByteBuffer : ByteBuffer { private bool _autoExpand; - /** - * We don't have any access to Buffer.markValue(), so we need to track it down, - * which will cause small extra overhead. - */ + /// + /// We don't have any access to Buffer.markValue(), + /// so we need to track it down, which will cause small extra overhead. + /// private int _mark = -1; protected BaseByteBuffer() @@ -94,10 +92,11 @@ namespace Qpid.Buffer return this; } - /** - * Implement this method to increase the capacity of this buffer. - * newCapacity is always greater than the current capacity. - */ + + /// + /// Implement this method to increase the capacity of this buffer. + /// + /// is always greater than the current capacity. protected abstract void capacity0( int newCapacity ); public override bool isAutoExpand() @@ -458,4 +457,4 @@ namespace Qpid.Buffer // return buf().asDoubleBuffer(); // } } -} \ No newline at end of file +} diff --git a/dotnet/Qpid.Buffer/BufferDataException.cs b/dotnet/Qpid.Buffer/BufferDataException.cs index bce2d7ef5a..c76441dde0 100644 --- a/dotnet/Qpid.Buffer/BufferDataException.cs +++ b/dotnet/Qpid.Buffer/BufferDataException.cs @@ -23,10 +23,10 @@ using System.Runtime.Serialization; namespace Qpid.Buffer { - /** - * A {@link RuntimeException} which is thrown when the data the {@link ByteBuffer} - * contains is corrupt. - */ + /// + /// An exception thrown when the data the + /// contains is corrupt + /// [Serializable] public class BufferDataException : Exception { diff --git a/dotnet/Qpid.Buffer/ByteBuffer.cs b/dotnet/Qpid.Buffer/ByteBuffer.cs index d2941e8346..1a4f0072d6 100644 --- a/dotnet/Qpid.Buffer/ByteBuffer.cs +++ b/dotnet/Qpid.Buffer/ByteBuffer.cs @@ -604,7 +604,7 @@ namespace Qpid.Buffer public abstract class ByteBuffer : IComparable { //private static ByteBufferAllocator allocator = new PooledByteBufferAllocator(); - private static ByteBufferAllocator allocator = new SimpleByteBufferAllocator(); + private static IByteBufferAllocator allocator = new SimpleByteBufferAllocator(); private static bool _useDirectBuffers = false; @@ -619,7 +619,7 @@ namespace Qpid.Buffer /** * Returns the current allocator which manages the allocated buffers. */ - public static ByteBufferAllocator getAllocator() + public static IByteBufferAllocator getAllocator() { return allocator; } @@ -628,20 +628,20 @@ namespace Qpid.Buffer * Changes the current allocator with the specified one to manage * the allocated buffers from now. */ - public static void setAllocator( ByteBufferAllocator newAllocator ) + public static void setAllocator( IByteBufferAllocator newAllocator ) { if( newAllocator == null ) { throw new NullReferenceException("allocator cannot be null"); } - ByteBufferAllocator oldAllocator = allocator; + IByteBufferAllocator oldAllocator = allocator; allocator = newAllocator; if( null != oldAllocator ) { - oldAllocator.dispose(); + oldAllocator.Dispose(); } } @@ -690,7 +690,7 @@ namespace Qpid.Buffer */ public static ByteBuffer allocate( int capacity, bool direct ) { - return allocator.allocate( capacity, direct ); + return allocator.Allocate( capacity, direct ); } /** @@ -698,7 +698,7 @@ namespace Qpid.Buffer */ public static ByteBuffer wrap( FixedByteBuffer nioBuffer ) { - return allocator.wrap( nioBuffer ); + return allocator.Wrap( nioBuffer ); } /** diff --git a/dotnet/Qpid.Buffer/ByteBufferAllocator.cs b/dotnet/Qpid.Buffer/ByteBufferAllocator.cs deleted file mode 100644 index 2dabd0ef50..0000000000 --- a/dotnet/Qpid.Buffer/ByteBufferAllocator.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -using Qpid.Buffer; - -namespace Qpid.Buffer -{ - /** - * Allocates {@link ByteBuffer}s and manages them. Please implement this - * interface if you need more advanced memory management scheme. - */ - public interface ByteBufferAllocator - { - /** - * Returns the buffer which is capable of the specified size. - * - * @param capacity the capacity of the buffer - * @param direct true to get a direct buffer, - * false to get a heap buffer. - */ - ByteBuffer allocate(int capacity, bool direct); - - /** - * Wraps the specified NIO {@link FixedByteBuffer} into MINA buffer. - */ - ByteBuffer wrap(FixedByteBuffer nioBuffer); - - /** - * Dispose of this allocator. - */ - void dispose(); - } -} \ No newline at end of file diff --git a/dotnet/Qpid.Buffer/IByteBufferAllocator.cs b/dotnet/Qpid.Buffer/IByteBufferAllocator.cs new file mode 100644 index 0000000000..215a9873fa --- /dev/null +++ b/dotnet/Qpid.Buffer/IByteBufferAllocator.cs @@ -0,0 +1,29 @@ +namespace Qpid.Buffer +{ + /// + /// Allocates 's and manages them. Please + /// implement this interface if you need more advanced memory management scheme + /// + public interface IByteBufferAllocator + { + /// + /// Returns the buffer which is capable of the specified size. + /// + /// The capacity of the buffer + /// true to get a direct buffer, false to get a heap buffer + ByteBuffer Allocate(int capacity, bool direct); + + /// + /// Wraps the specified buffer + /// + /// fixed byte buffer + /// The wrapped buffer + ByteBuffer Wrap(FixedByteBuffer nioBuffer); + + + /// + /// Dispose of this allocator. + /// + void Dispose(); + } +} \ No newline at end of file diff --git a/dotnet/Qpid.Buffer/Qpid.Buffer.csproj b/dotnet/Qpid.Buffer/Qpid.Buffer.csproj index 7bca166fbc..3e4b302a3a 100644 --- a/dotnet/Qpid.Buffer/Qpid.Buffer.csproj +++ b/dotnet/Qpid.Buffer/Qpid.Buffer.csproj @@ -41,11 +41,11 @@ - + @@ -57,4 +57,4 @@ --> - \ No newline at end of file + diff --git a/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs b/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs index b11d6b6b14..2de3a13560 100644 --- a/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs +++ b/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs @@ -23,11 +23,11 @@ using System.Runtime.CompilerServices; namespace Qpid.Buffer { - /** - * A simplistic {@link ByteBufferAllocator} which simply allocates a new - * buffer every time. - */ - public class SimpleByteBufferAllocator : ByteBufferAllocator + /// + /// A simplistic which simply allocates a new + /// buffer every time + /// + public class SimpleByteBufferAllocator : IByteBufferAllocator { private const int MINIMUM_CAPACITY = 1; @@ -35,7 +35,7 @@ namespace Qpid.Buffer { } - public ByteBuffer allocate( int capacity, bool direct ) + public ByteBuffer Allocate( int capacity, bool direct ) { FixedByteBuffer nioBuffer; if( direct ) @@ -49,12 +49,12 @@ namespace Qpid.Buffer return new SimpleByteBuffer( nioBuffer ); } - public ByteBuffer wrap( FixedByteBuffer nioBuffer ) + public ByteBuffer Wrap( FixedByteBuffer nioBuffer ) { return new SimpleByteBuffer( nioBuffer ); } - public void dispose() + public void Dispose() { } diff --git a/dotnet/Qpid.Client.Tests/Common/BaseMessagingTestFixture.cs b/dotnet/Qpid.Client.Tests/Common/BaseMessagingTestFixture.cs index fae610eb85..69f8cc1406 100644 --- a/dotnet/Qpid.Client.Tests/Common/BaseMessagingTestFixture.cs +++ b/dotnet/Qpid.Client.Tests/Common/BaseMessagingTestFixture.cs @@ -22,7 +22,7 @@ using System; using log4net; using NUnit.Framework; using Qpid.Messaging; -using Qpid.Client.qms; +using Qpid.Client.Qms; namespace Qpid.Client.Tests { @@ -54,7 +54,7 @@ namespace Qpid.Client.Tests try { - ConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri); + IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri); _connection = new AMQConnection(connectionInfo); _channel = _connection.CreateChannel(false, AcknowledgeMode.NoAcknowledge, 1); } diff --git a/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs b/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs index d5330898a0..f03df903b2 100644 --- a/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs +++ b/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs @@ -20,7 +20,7 @@ */ using System; using NUnit.Framework; -using Qpid.Client.qms; +using Qpid.Client.Qms; using Qpid.Messaging; namespace Qpid.Client.Tests.Connection @@ -31,7 +31,7 @@ namespace Qpid.Client.Tests.Connection [Test] public void SimpleConnection() { - ConnectionInfo connectionInfo = new QpidConnectionInfo(); + IConnectionInfo connectionInfo = new QpidConnectionInfo(); connectionInfo.AddBrokerInfo(new AmqBrokerInfo("amqp", "localhost", 5672, false)); using (IConnection connection = new AMQConnection(connectionInfo)) { @@ -42,8 +42,8 @@ namespace Qpid.Client.Tests.Connection [Test] public void PasswordFailureConnection() { - ConnectionInfo connectionInfo = new QpidConnectionInfo(); - connectionInfo.SetPassword("rubbish"); + IConnectionInfo connectionInfo = new QpidConnectionInfo(); + connectionInfo.Password = "rubbish"; connectionInfo.AddBrokerInfo(new AmqBrokerInfo()); try { diff --git a/dotnet/Qpid.Client.Tests/failover/FailoverTest.cs b/dotnet/Qpid.Client.Tests/failover/FailoverTest.cs index 52ef76c559..478d66b9da 100644 --- a/dotnet/Qpid.Client.Tests/failover/FailoverTest.cs +++ b/dotnet/Qpid.Client.Tests/failover/FailoverTest.cs @@ -22,7 +22,7 @@ using System; using System.Threading; using log4net; using NUnit.Framework; -using Qpid.Client.qms; +using Qpid.Client.Qms; using Qpid.Messaging; namespace Qpid.Client.Tests.failover @@ -39,7 +39,7 @@ namespace Qpid.Client.Tests.failover private IMessageConsumer _consumerOfResponse; - void DoFailoverTest(ConnectionInfo info) + void DoFailoverTest(IConnectionInfo info) { DoFailoverTest(new AMQConnection(info)); } diff --git a/dotnet/Qpid.Client.Tests/failover/FailoverTxTest.cs b/dotnet/Qpid.Client.Tests/failover/FailoverTxTest.cs index b2eecfc423..602f72762a 100644 --- a/dotnet/Qpid.Client.Tests/failover/FailoverTxTest.cs +++ b/dotnet/Qpid.Client.Tests/failover/FailoverTxTest.cs @@ -23,7 +23,7 @@ using System.Runtime.InteropServices; using System.Threading; using log4net; using NUnit.Framework; -using Qpid.Client.qms; +using Qpid.Client.Qms; using Qpid.Messaging; namespace Qpid.Client.Tests.failover @@ -97,7 +97,7 @@ namespace Qpid.Client.Tests.failover } } - void DoFailoverTxTest(ConnectionInfo connectionInfo) + void DoFailoverTxTest(IConnectionInfo connectionInfo) { _connection = new AMQConnection(connectionInfo); _connection.ConnectionListener = this; @@ -237,7 +237,7 @@ namespace Qpid.Client.Tests.failover _log.Info("url = [" + defaultUrl + "]"); - ConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(defaultUrl); + IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(defaultUrl); _log.Info("connection url = [" + connectionInfo + "]"); diff --git a/dotnet/Qpid.Client.Tests/url/ConnectionUrlTest.cs b/dotnet/Qpid.Client.Tests/url/ConnectionUrlTest.cs index 3e99c6f444..4ab6dd5736 100644 --- a/dotnet/Qpid.Client.Tests/url/ConnectionUrlTest.cs +++ b/dotnet/Qpid.Client.Tests/url/ConnectionUrlTest.cs @@ -21,7 +21,7 @@ using System; using System.Net; using NUnit.Framework; -using Qpid.Client.qms; +using Qpid.Client.Qms; namespace Qpid.Client.Tests.url { @@ -34,26 +34,26 @@ namespace Qpid.Client.Tests.url //String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'"; String url = "amqp://ritchiem:bob@default/temp?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.AreEqual("roundrobin", connectionurl.GetFailoverMethod()); - Assert.IsTrue(connectionurl.GetUsername().Equals("ritchiem")); - Assert.IsTrue(connectionurl.GetPassword().Equals("bob")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.AreEqual("roundrobin", connectionurl.FailoverMethod); + Assert.IsTrue(connectionurl.Username.Equals("ritchiem")); + Assert.IsTrue(connectionurl.Password.Equals("bob")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 2); + Assert.IsTrue(connectionurl.BrokerCount == 2); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); service = connectionurl.GetBrokerInfo(1); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("fancyserver")); - Assert.IsTrue(service.getPort() == 3000); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("fancyserver")); + Assert.IsTrue(service.Port == 3000); } @@ -62,20 +62,20 @@ namespace Qpid.Client.Tests.url { String url = "amqp://ritchiem:bob@default/temp?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("ritchiem")); - Assert.IsTrue(connectionurl.GetPassword().Equals("bob")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("ritchiem")); + Assert.IsTrue(connectionurl.Password.Equals("bob")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); } [Test] @@ -83,20 +83,20 @@ namespace Qpid.Client.Tests.url { String url = "amqp://ritchiem:@default/temp?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("ritchiem")); - Assert.IsTrue(connectionurl.GetPassword().Equals("")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("ritchiem")); + Assert.IsTrue(connectionurl.Password.Equals("")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); } [Test] @@ -121,23 +121,23 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/test")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/test")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); } [Test] @@ -145,24 +145,24 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@clientname/temp?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); - Assert.IsTrue(connectionurl.GetClientName().Equals("clientname")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); + Assert.IsTrue(connectionurl.ClientName.Equals("clientname")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Transport.Equals("tcp")); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); } [Test] @@ -170,22 +170,22 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/temp?brokerlist='tcp://localhost:5672',routingkey='jim'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); + Assert.IsTrue(service.Transport.Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); Assert.IsTrue(connectionurl.GetOption("routingkey").Equals("jim")); } @@ -194,22 +194,22 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/temp?brokerlist='localhost:'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); + Assert.IsTrue(service.Transport.Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); } [Test] @@ -217,21 +217,21 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/temp?brokerlist='tcp://localhost:5672',routingkey='jim',timeout='200',immediatedelivery='true'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("tcp")); + Assert.IsTrue(service.Transport.Equals("tcp")); - Assert.IsTrue(service.getHost().Equals("localhost")); - Assert.IsTrue(service.getPort() == 5672); + Assert.IsTrue(service.Host.Equals("localhost")); + Assert.IsTrue(service.Port == 5672); Assert.IsTrue(connectionurl.GetOption("routingkey").Equals("jim")); Assert.IsTrue(connectionurl.GetOption("timeout").Equals("200")); @@ -243,20 +243,20 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/messages?brokerlist='vm://default:2'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod() == null); - Assert.IsTrue(connectionurl.GetUsername().Equals("guest")); - Assert.IsTrue(connectionurl.GetPassword().Equals("guest")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/messages")); + Assert.IsTrue(connectionurl.FailoverMethod == null); + Assert.IsTrue(connectionurl.Username.Equals("guest")); + Assert.IsTrue(connectionurl.Password.Equals("guest")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/messages")); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("vm")); - Assert.AreEqual("localhost", service.getHost()); - Assert.AreEqual(2, service.getPort()); + Assert.IsTrue(service.Transport.Equals("vm")); + Assert.AreEqual("localhost", service.Host); + Assert.AreEqual(2, service.Port); } [Test] @@ -264,25 +264,25 @@ namespace Qpid.Client.Tests.url { String url = "amqp://ritchiem:bob@default/temp?brokerlist='vm://default:2;vm://default:3',failover='roundrobin'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetFailoverMethod().Equals("roundrobin")); - Assert.IsTrue(connectionurl.GetUsername().Equals("ritchiem")); - Assert.IsTrue(connectionurl.GetPassword().Equals("bob")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/temp")); + Assert.IsTrue(connectionurl.FailoverMethod.Equals("roundrobin")); + Assert.IsTrue(connectionurl.Username.Equals("ritchiem")); + Assert.IsTrue(connectionurl.Password.Equals("bob")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/temp")); - Assert.AreEqual(2, connectionurl.GetBrokerCount()); + Assert.AreEqual(2, connectionurl.BrokerCount); - BrokerInfo service = connectionurl.GetBrokerInfo(0); + IBrokerInfo service = connectionurl.GetBrokerInfo(0); - Assert.IsTrue(service.getTransport().Equals("vm")); - Assert.AreEqual("localhost", service.getHost()); - Assert.IsTrue(service.getPort() == 2); + Assert.IsTrue(service.Transport.Equals("vm")); + Assert.AreEqual("localhost", service.Host); + Assert.IsTrue(service.Port == 2); service = connectionurl.GetBrokerInfo(1); - Assert.IsTrue(service.getTransport().Equals("vm")); - Assert.AreEqual("localhost", service.getHost()); - Assert.IsTrue(service.getPort() == 3); + Assert.IsTrue(service.Transport.Equals("vm")); + Assert.AreEqual("localhost", service.Host); + Assert.IsTrue(service.Port == 3); } [Test] @@ -306,14 +306,14 @@ namespace Qpid.Client.Tests.url { String url = "amqp://user:@default/test?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connectionurl = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connectionurl.GetUsername().Equals("user")); - Assert.IsTrue(connectionurl.GetPassword().Equals("")); - Assert.IsTrue(connectionurl.GetVirtualHost().Equals("/test")); - Assert.IsTrue(connectionurl.GetClientName().StartsWith(Dns.GetHostName())); + Assert.IsTrue(connectionurl.Username.Equals("user")); + Assert.IsTrue(connectionurl.Password.Equals("")); + Assert.IsTrue(connectionurl.VirtualHost.Equals("/test")); + Assert.IsTrue(connectionurl.ClientName.StartsWith(Dns.GetHostName())); - Assert.IsTrue(connectionurl.GetBrokerCount() == 1); + Assert.IsTrue(connectionurl.BrokerCount == 1); } [Test] @@ -372,8 +372,8 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/t.-_+!=:?brokerlist='tcp://localhost:5672'"; - ConnectionInfo connection = QpidConnectionInfo.FromUrl(url); - Assert.IsTrue(connection.GetVirtualHost().Equals("/t.-_+!=:")); + IConnectionInfo connection = QpidConnectionInfo.FromUrl(url); + Assert.IsTrue(connection.VirtualHost.Equals("/t.-_+!=:")); } [Test] @@ -381,10 +381,10 @@ namespace Qpid.Client.Tests.url { String url = "amqp://guest:guest@default/test=:?brokerlist='tcp://localhost'"; - ConnectionInfo connection = QpidConnectionInfo.FromUrl(url); + IConnectionInfo connection = QpidConnectionInfo.FromUrl(url); - BrokerInfo broker = connection.GetBrokerInfo(0); - Assert.IsTrue(broker.getPort() == BrokerInfoConstants.DEFAULT_PORT); + IBrokerInfo broker = connection.GetBrokerInfo(0); + Assert.IsTrue(broker.Port == BrokerInfoConstants.DEFAULT_PORT); } diff --git a/dotnet/Qpid.Client/Client/AMQConnection.cs b/dotnet/Qpid.Client/Client/AMQConnection.cs index 3192b0018d..1a342f0b15 100644 --- a/dotnet/Qpid.Client/Client/AMQConnection.cs +++ b/dotnet/Qpid.Client/Client/AMQConnection.cs @@ -26,7 +26,7 @@ using System.Threading; using log4net; using Qpid.Client.Failover; using Qpid.Client.Protocol; -using Qpid.Client.qms; +using Qpid.Client.Qms; using Qpid.Client.State; using Qpid.Client.Transport; using Qpid.Client.Transport.Socket.Blocking; @@ -40,7 +40,7 @@ namespace Qpid.Client { private static readonly ILog _log = LogManager.GetLogger(typeof(AMQConnection)); - ConnectionInfo _connectionInfo; + IConnectionInfo _connectionInfo; private int _nextChannelId = 0; // _Connected should be refactored with a suitable wait object. @@ -121,7 +121,7 @@ namespace Qpid.Client get { return _protocolWriter; } } - public AMQConnection(ConnectionInfo connectionInfo) + public AMQConnection(IConnectionInfo connectionInfo) { if (connectionInfo == null) { @@ -129,7 +129,7 @@ namespace Qpid.Client } _log.Info("ConnectionInfo: " + connectionInfo); _connectionInfo = connectionInfo; - _log.Info("password = " + _connectionInfo.GetPassword()); + _log.Info("password = " + _connectionInfo.Password); _failoverPolicy = new FailoverPolicy(connectionInfo); // We are not currently connected. @@ -140,7 +140,7 @@ namespace Qpid.Client { try { - BrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo(); + IBrokerInfo brokerInfo = _failoverPolicy.GetNextBrokerInfo(); _log.Info("Connecting to " + brokerInfo); MakeBrokerConnection(brokerInfo); break; @@ -220,12 +220,12 @@ namespace Qpid.Client get { CheckNotClosed(); - return _connectionInfo.GetClientName(); + return _connectionInfo.ClientName; } set { CheckNotClosed(); - _connectionInfo.SetClientName(value); + _connectionInfo.ClientName = value; } } @@ -505,7 +505,7 @@ namespace Qpid.Client { get { - return _failoverPolicy.GetCurrentBrokerInfo().getHost(); + return _failoverPolicy.GetCurrentBrokerInfo().Host; } } @@ -513,7 +513,7 @@ namespace Qpid.Client { get { - return _failoverPolicy.GetCurrentBrokerInfo().getPort(); + return _failoverPolicy.GetCurrentBrokerInfo().Port; } } @@ -521,7 +521,7 @@ namespace Qpid.Client { get { - return _connectionInfo.GetUsername(); + return _connectionInfo.Username; } } @@ -529,7 +529,7 @@ namespace Qpid.Client { get { - return _connectionInfo.GetPassword(); + return _connectionInfo.Password; } } @@ -537,7 +537,7 @@ namespace Qpid.Client { get { - return _connectionInfo.GetVirtualHost(); + return _connectionInfo.VirtualHost; } } @@ -674,7 +674,7 @@ namespace Qpid.Client public bool AttemptReconnection(String host, int port, bool useSSL) { - BrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL); + IBrokerInfo bd = new AmqBrokerInfo("amqp", host, port, useSSL); _failoverPolicy.setBroker(bd); @@ -691,7 +691,7 @@ namespace Qpid.Client return false; } - private void MakeBrokerConnection(BrokerInfo brokerDetail) + private void MakeBrokerConnection(IBrokerInfo brokerDetail) { try { @@ -708,7 +708,7 @@ namespace Qpid.Client _transport = LoadTransportFromAssembly(brokerDetail.getHost(), brokerDetail.getPort(), assemblyName, transportType); */ - _transport = new BlockingSocketTransport(brokerDetail.getHost(), brokerDetail.getPort(), this); + _transport = new BlockingSocketTransport(brokerDetail.Host, brokerDetail.Port, this); // Connect. _transport.Open(); diff --git a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs index 81a5f10647..f26756ccad 100644 --- a/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs +++ b/dotnet/Qpid.Client/Client/AmqBrokerInfo.cs @@ -21,11 +21,11 @@ using System; using System.Collections; using System.Text; -using Qpid.Client.qms; +using Qpid.Client.Qms; namespace Qpid.Client { - public class AmqBrokerInfo : BrokerInfo + public class AmqBrokerInfo : IBrokerInfo { public readonly string URL_FORMAT_EXAMPLE = "://[:][?