added compiling (but not working) unit test case

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@367748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-01-10 19:30:13 +00:00
parent da77d2c649
commit 3ed3dd46dd
13 changed files with 129 additions and 90 deletions

View File

@ -163,7 +163,7 @@
<buildfiles refid="tas.win32" />
</nant>
<!-- build OpenWire.Client.Tests assembly -->
<nant buildfile="tests/OpenWire.Client/OpenWire.Client.build" target="build" />
<nant buildfile="tests/OpenWire.Client/OpenWire.Client.build" target="test" />
<!-- build tests for task assemblies -->
<nant target="build">
<buildfiles refid="tas.core.tests"/>

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQBytesMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQMapMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQObjectMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQStreamMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;

View File

@ -1,12 +1,3 @@
//
// Marshalling code for Open Wire Format for ActiveMQTextMessage
//
//
// NOTE!: This file is autogenerated - do not modify!
// if you need to make a change, please see the Groovy scripts in the
// activemq-openwire module
//
using System;
using System.Collections;
@ -17,9 +8,14 @@ namespace OpenWire.Client.Commands {
public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage {
public const byte ID_ActiveMQTextMessage = 28;
private String text;
public ActiveMQTextMessage() {
}
public ActiveMQTextMessage(String text) {
this.text = text;
}
// TODO generate Equals method
// TODO generate GetHashCode method

View File

@ -14,6 +14,14 @@ namespace OpenWire.Client {
private string password;
private string clientId;
public ConnectionFactory() {
}
public ConnectionFactory(string host, int port) {
this.host = host;
this.port = port;
}
public IConnection CreateConnection() {
return CreateConnection(userName, password);
}

View File

@ -39,6 +39,20 @@ namespace OpenWire.Client {
/// </summary>
ITopic GetTopic(string name);
/// <summary>
/// Creates a new message with an empty body
/// </summary>
IMessage CreateMessage();
/// <summary>
/// Creates a new text message with an empty body
/// </summary>
ITextMessage CreateTextMessage();
/// <summary>
/// Creates a new text message with the given body
/// </summary>
ITextMessage CreateTextMessage(string text);
}
}

View File

@ -50,13 +50,25 @@ namespace OpenWire.Client {
}
public IQueue GetQueue(string name) {
return new ActiveMQQueue(name);
return new ActiveMQQueue(name);
}
public ITopic GetTopic(string name) {
return new ActiveMQTopic(name);
}
public IMessage CreateMessage() {
return new ActiveMQMessage();
}
public ITextMessage CreateTextMessage() {
return new ActiveMQTextMessage();
}
public ITextMessage CreateTextMessage(string text) {
return new ActiveMQTextMessage(text);
}
// Implementation methods
public void DoSend(IDestination destination, IMessage message) {
ActiveMQMessage command = ActiveMQMessage.Transform(message);

View File

@ -0,0 +1,33 @@
using System;
using System.IO;
using NUnit.Framework;
using OpenWire.Client;
namespace OpenWire.Client {
[ TestFixture ]
public class ClientTest : TestSupport {
[ Test ]
public void SendAndSyncReceive() {
IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
using (IConnection connection = factory.CreateConnection()) {
ISession session = connection.CreateSession();
IDestination destination = session.GetQueue("FOO.BAR");
IMessageConsumer consumer = session.CreateConsumer(destination);
IMessageProducer producer = session.CreateProducer(destination);
string expected = "Hello World!";
ITextMessage request = session.CreateTextMessage(expected);
producer.Send(request);
ITextMessage message = (ITextMessage) consumer.Receive();
Assert.AreEqual(expected, message.Text);
}
}
}
}

View File

@ -1,32 +1,40 @@
<?xml version="1.0"?>
<project name="OpenWire.Core" default="build">
<!--
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 OpenWire.Core -->
<csc target="library" define="${current.build.defines}" warnaserror="true" debug="${build.debug}" output="${build.dir}/bin/${project.name}.dll" doc="${build.dir}/bin/${project.name}.xml">
<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="../CommonAssemblyInfo.cs" />
</sources>
<resources basedir="Resources">
<include name="**/*" />
</resources>
<references>
<include name="${build.dir}/bin/log4net.dll"/>
<include name="System.Web.dll"/>
</references>
</csc>
</target>
</project>
<?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>
</project>

View File

@ -0,0 +1,13 @@
using System;
using System.IO;
using OpenWire.Client;
namespace OpenWire.Client {
/// <summary>
/// useful base class for test cases
/// </summary>
public abstract class TestSupport {
}
}