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
This commit is contained in:
James Strachan 2006-01-11 16:07:52 +00:00
parent 39cd4bff1a
commit 1c44792498
5 changed files with 58 additions and 46 deletions

View File

@ -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 {
/// </summary>
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

View File

@ -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;
}

View File

@ -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);
/// <summary>
/// Represents the logical networking transport layer.
/// </summary>
public interface Transport {
public interface ITransport {
void Oneway(Command command);
FutureResponse AsyncRequest(Command command);

View File

@ -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);
}
*/
}
}
}

View File

@ -1,40 +1,47 @@
<?xml version="1.0"?>
<project name="OpenWire.Core" default="test">
<!--
Required properties:
* build.dir - (path) root level to build to, assemblies will go in ${build.dir}/bin
* build.debug - (true|false) debug build?
* current.build.defines - framework-specific build defines
-->
<target name="build">
<!-- build test assembly -->
<csc target="library" define="${current.build.defines}" warnaserror="true" debug="${build.debug}" output="${build.dir}/bin/${project.name}.Tests.dll">
<nowarn>
<!-- do not report warnings for missing XML comments -->
<warning number="1591" />
<!-- do not report deprecation warnings -->
<warning number="0618" />
</nowarn>
<sources failonempty="true">
<include name="**/*.cs" />
<!-- common assembly-level attributes -->
<include name="../../src/CommonAssemblyInfo.cs" />
</sources>
<references>
<include name="${lib.framework.dir}/log4net.dll" />
<include name="${build.dir}/bin/openwire.dll" />
<include name="${lib.framework.dir}/nunit.framework.dll" />
</references>
<resources failonempty="false" basedir="Resources" dynamicprefix="true" prefix="XML:">
<include name="**/*.xml"/>
</resources>
</csc>
</target>
<target name="test" depends="build">
<nunit2>
<formatter type="Plain" />
<test assemblyname="${build.dir}/bin/${project.name}.Tests.dll" appconfig="${path::combine(nant.location, 'nant.tests.config')}">
</test>
</nunit2>
</target>
<!--
Required properties:
* build.dir - (path) root level to build to, assemblies will go in ${build.dir}/bin
* build.debug - (true|false) debug build?
* current.build.defines - framework-specific build defines
-->
<target name="build">
<!-- build test assembly -->
<csc target="library" define="${current.build.defines}"
warnaserror="true" debug="${build.debug}"
output="${build.dir}/bin/${project.name}.Tests.dll">
<nowarn>
<!-- do not report warnings for missing XML comments -->
<warning number="1591" />
<!-- do not report deprecation warnings -->
<warning number="0618" />
</nowarn>
<sources failonempty="true">
<include name="**/*.cs" />
<!-- common assembly-level attributes -->
<include name="../../src/CommonAssemblyInfo.cs" />
</sources>
<references defaultexcludes="true">
<include name="mscorlib.dll" />
<include name="System.dll" />
<include name="nunit.framework.dll" />
<include name="log4net.dll" />
<include name="${build.dir}/bin/${project.name}.dll" />
</references>
<resources failonempty="false" basedir="Resources"
dynamicprefix="true" prefix="XML:">
<include name="**/*.xml" />
</resources>
</csc>
</target>
<target name="test" depends="build">
<nunit2>
<formatter type="Plain" />
<test assemblyname="${build.dir}/bin/${project.name}.Tests.dll">
</test>
</nunit2>
</target>
</project>