Issue #51: ActiveMQ 1.6 interfaces have changed
- Updated NMS.ActiveMQ to v1.6.1 and Apache.NMS API to v1.6.0 - Amended wrapper implementation to match new API
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Apache.NMS;
|
||||
using NUnit.Framework;
|
||||
using Spring.Collections;
|
||||
|
||||
namespace Spring.Messaging.Nms.Connections
|
||||
{
|
||||
/// <summary>
|
||||
/// Test suite for <see cref="CachedSession"/>.
|
||||
/// </summary>
|
||||
/// <author>Andreas Kluth</author>
|
||||
[TestFixture]
|
||||
public class CachedSessionTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates that events raised by the session cached are propagated to a registered consumer.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EventsArePropagated()
|
||||
{
|
||||
TestSession targetSession = new TestSession();
|
||||
CachedSession session = CreateCachedSession(targetSession);
|
||||
|
||||
bool committedWasRaised = false;
|
||||
bool rolledBackWasRaised = false;
|
||||
bool startedWasRaised = false;
|
||||
|
||||
session.TransactionCommittedListener += _ => committedWasRaised = true;
|
||||
session.TransactionRolledBackListener += _ => rolledBackWasRaised = true;
|
||||
session.TransactionStartedListener += _ => startedWasRaised = true;
|
||||
|
||||
targetSession.TransactionCommitted();
|
||||
targetSession.TransactionRolledBack();
|
||||
targetSession.TransactionStarted();
|
||||
|
||||
Assert.IsTrue(committedWasRaised);
|
||||
Assert.IsTrue(rolledBackWasRaised);
|
||||
Assert.IsTrue(startedWasRaised);
|
||||
}
|
||||
|
||||
private CachedSession CreateCachedSession(ISession targetSession)
|
||||
{
|
||||
return new CachedSession(targetSession, new LinkedList(), new CachingConnectionFactory());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
connection.Start();
|
||||
LastCall.On(connection).Repeat.Twice();
|
||||
connection.PurgeTempDestinations();
|
||||
LastCall.On( connection ).Repeat.Twice();
|
||||
connection.Stop();
|
||||
LastCall.On(connection).Repeat.Once();
|
||||
connection.Close();
|
||||
@@ -64,10 +66,12 @@ namespace Spring.Messaging.Nms.Connections
|
||||
SingleConnectionFactory scf = new SingleConnectionFactory(connection);
|
||||
IConnection con1 = scf.CreateConnection();
|
||||
con1.Start();
|
||||
con1.PurgeTempDestinations();
|
||||
con1.Stop(); // should be ignored
|
||||
con1.Close(); // should be ignored
|
||||
IConnection con2 = scf.CreateConnection();
|
||||
con2.Start();
|
||||
con1.PurgeTempDestinations();
|
||||
con2.Stop(); // should be ignored
|
||||
con2.Close(); // should be ignored.
|
||||
scf.Dispose();
|
||||
|
||||
@@ -50,6 +50,11 @@ namespace Spring.Messaging.Nms.Connections
|
||||
closeCount++;
|
||||
}
|
||||
|
||||
public void PurgeTempDestinations()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConsumerTransformerDelegate ConsumerTransformer
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
|
||||
@@ -75,9 +75,6 @@ namespace Spring.Messaging.Nms.Connections
|
||||
public IMessageConsumer CreateConsumer(IDestination destination, string selector)
|
||||
{
|
||||
return new TestMessageConsumer();
|
||||
//IConnectionFactory connectionFactory = (IConnectionFactory)mocks.CreateMock(typeof(IConnectionFactory));
|
||||
//IMessageConsumer msgConsumer = (IMessageConsumer) mocks.CreateMock(typeof (IMessageConsumer));
|
||||
//return msgConsumer;
|
||||
}
|
||||
|
||||
public IMessageConsumer CreateConsumer(IDestination destination, string selector, TimeSpan requestTimeout)
|
||||
@@ -147,15 +144,11 @@ namespace Spring.Messaging.Nms.Connections
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region ISession Members
|
||||
|
||||
public void DeleteDestination(IDestination destination)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public IMessage CreateMessage()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -201,6 +194,11 @@ namespace Spring.Messaging.Nms.Connections
|
||||
closeCount++;
|
||||
}
|
||||
|
||||
public void Recover()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
|
||||
@@ -239,6 +237,40 @@ namespace Spring.Messaging.Nms.Connections
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
#region Transaction State Events
|
||||
|
||||
public void TransactionStarted()
|
||||
{
|
||||
if(TransactionStartedListener != null)
|
||||
{
|
||||
TransactionStartedListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransactionCommitted()
|
||||
{
|
||||
if(TransactionCommittedListener != null)
|
||||
{
|
||||
TransactionCommittedListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransactionRolledBack()
|
||||
{
|
||||
if(TransactionRolledBackListener != null)
|
||||
{
|
||||
TransactionRolledBackListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public event SessionTxEventDelegate TransactionStartedListener;
|
||||
|
||||
public event SessionTxEventDelegate TransactionCommittedListener;
|
||||
|
||||
public event SessionTxEventDelegate TransactionRolledBackListener;
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
<Compile Include="NmsExceptionTests.cs" />
|
||||
<Compile Include="NmsCompilerOptionsTests.cs" />
|
||||
<Compile Include="Messaging\Nms\Config\NmsNamespaceHandlerTests.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\CachedSessionTest.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\CachingConnectionFactoryTests.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\MessageTransactionManagerTests.cs" />
|
||||
<Compile Include="Messaging\Nms\Connections\SingleConnectionFactoryTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user