From 1c447924982594d7e71ab70b7614f5a774d7c8b9 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Wed, 11 Jan 2006 16:07:52 +0000 Subject: [PATCH] refactored Transport -> ITransport along with adding a stub working NUnit test case and build git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@368050 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/OpenWire.Client/Connection.cs | 8 +- .../src/OpenWire.Client/ConnectionFactory.cs | 4 +- .../Core/{Transport.cs => ITransport.cs} | 6 +- .../tests/OpenWire.Client/ClientTest.cs | 5 ++ .../OpenWire.Client/OpenWire.Client.build | 81 ++++++++++--------- 5 files changed, 58 insertions(+), 46 deletions(-) rename openwire-dotnet/src/OpenWire.Client/Core/{Transport.cs => ITransport.cs} (71%) diff --git a/openwire-dotnet/src/OpenWire.Client/Connection.cs b/openwire-dotnet/src/OpenWire.Client/Connection.cs index a9b28b368c..4693126001 100755 --- a/openwire-dotnet/src/OpenWire.Client/Connection.cs +++ b/openwire-dotnet/src/OpenWire.Client/Connection.cs @@ -10,7 +10,7 @@ namespace OpenWire.Client { public class Connection : IConnection { private ConnectionInfo info; - private Transport transport; + private ITransport transport; IList sessions = new ArrayList(); private bool transacted; private bool connected; @@ -18,7 +18,7 @@ namespace OpenWire.Client { private AcknowledgementMode acknowledgementMode; private long sessionCounter; - public Connection(Transport transport, ConnectionInfo info) { + public Connection(ITransport transport, ConnectionInfo info) { this.transport = transport; this.info = info; } @@ -52,7 +52,7 @@ namespace OpenWire.Client { // Properties - public Transport Transport { + public ITransport ITransport { get { return transport; } set { this.transport = value; } } @@ -84,7 +84,7 @@ namespace OpenWire.Client { /// public Response SyncRequest(Command command) { CheckConnected(); - Response response = Transport.Request(command); + Response response = ITransport.Request(command); if (response is ExceptionResponse) { ExceptionResponse exceptionResponse = (ExceptionResponse) response; // TODO include stack trace diff --git a/openwire-dotnet/src/OpenWire.Client/ConnectionFactory.cs b/openwire-dotnet/src/OpenWire.Client/ConnectionFactory.cs index d35b6415dc..5dee3d3dc5 100755 --- a/openwire-dotnet/src/OpenWire.Client/ConnectionFactory.cs +++ b/openwire-dotnet/src/OpenWire.Client/ConnectionFactory.cs @@ -28,7 +28,7 @@ namespace OpenWire.Client { public IConnection CreateConnection(string userName, string password) { ConnectionInfo info = CreateConnectionInfo(userName, password); - Transport transport = CreateTransport(); + ITransport transport = CreateITransport(); Connection connection = new Connection(transport, info); connection.ClientId = clientId; return connection; @@ -77,7 +77,7 @@ namespace OpenWire.Client { return Guid.NewGuid().ToString(); } - protected Transport CreateTransport() { + protected ITransport CreateITransport() { // TODO return null; } diff --git a/openwire-dotnet/src/OpenWire.Client/Core/Transport.cs b/openwire-dotnet/src/OpenWire.Client/Core/ITransport.cs similarity index 71% rename from openwire-dotnet/src/OpenWire.Client/Core/Transport.cs rename to openwire-dotnet/src/OpenWire.Client/Core/ITransport.cs index a1f3903e91..ae639db916 100755 --- a/openwire-dotnet/src/OpenWire.Client/Core/Transport.cs +++ b/openwire-dotnet/src/OpenWire.Client/Core/ITransport.cs @@ -6,13 +6,13 @@ using OpenWire.Client.Core; namespace OpenWire.Client.Core { - public delegate void CommandHandler(Transport sender, Command command); - public delegate void ExceptionHandler(Transport sender, Exception command); + public delegate void CommandHandler(ITransport sender, Command command); + public delegate void ExceptionHandler(ITransport sender, Exception command); /// /// Represents the logical networking transport layer. /// - public interface Transport { + public interface ITransport { void Oneway(Command command); FutureResponse AsyncRequest(Command command); diff --git a/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs b/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs index 58e743ddc6..f6abc15b23 100644 --- a/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs +++ b/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs @@ -14,6 +14,10 @@ namespace OpenWire.Client { public void SendAndSyncReceive() { IConnectionFactory factory = new ConnectionFactory("localhost", 61616); + Assert.IsTrue(factory != null, "created valid factory: " + factory); + + Console.WriteLine("Worked!"); + /* using (IConnection connection = factory.CreateConnection()) { ISession session = connection.CreateSession(); IDestination destination = session.GetQueue("FOO.BAR"); @@ -28,6 +32,7 @@ namespace OpenWire.Client { Assert.AreEqual(expected, message.Text); } + */ } } } diff --git a/openwire-dotnet/tests/OpenWire.Client/OpenWire.Client.build b/openwire-dotnet/tests/OpenWire.Client/OpenWire.Client.build index d02e613866..9dbd767425 100755 --- a/openwire-dotnet/tests/OpenWire.Client/OpenWire.Client.build +++ b/openwire-dotnet/tests/OpenWire.Client/OpenWire.Client.build @@ -1,40 +1,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +