2006-01-10 14:30:13 -05:00
|
|
|
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);
|
|
|
|
|
2006-01-11 11:07:52 -05:00
|
|
|
Assert.IsTrue(factory != null, "created valid factory: " + factory);
|
|
|
|
|
|
|
|
Console.WriteLine("Worked!");
|
2006-01-11 13:58:57 -05:00
|
|
|
|
2006-01-10 14:30:13 -05:00
|
|
|
using (IConnection connection = factory.CreateConnection()) {
|
|
|
|
ISession session = connection.CreateSession();
|
2006-01-11 13:58:57 -05:00
|
|
|
Console.WriteLine("Created a session: " + session);
|
|
|
|
|
2006-01-10 14:30:13 -05:00
|
|
|
IDestination destination = session.GetQueue("FOO.BAR");
|
2006-01-11 13:58:57 -05:00
|
|
|
Assert.IsTrue(destination != null, "No queue available!");
|
|
|
|
Console.WriteLine("Using destination: " + destination);
|
|
|
|
|
2006-01-10 14:30:13 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|