forked from hibernating-rhinos/rhino-esb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to Windsor 2.5 Beta 2 and fixed deprecated warnings.
- Loading branch information
1 parent
2322754
commit b33ba20
Showing
31 changed files
with
547 additions
and
520 deletions.
There are no files selected for viewing
83 changes: 42 additions & 41 deletions
83
Rhino.ServiceBus.Tests/Bugs/Occasional_consumer_resolving_when_not_subscribed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,58 @@ | ||
using System; | ||
using System.Threading; | ||
using Castle.MicroKernel.Registration; | ||
using Castle.Windsor; | ||
using Castle.Windsor.Configuration.Interpreters; | ||
using Rhino.ServiceBus.Impl; | ||
using Xunit; | ||
|
||
namespace Rhino.ServiceBus.Tests.Bugs | ||
{ | ||
public class Occasional_consumer_resolving_when_not_subscribed : OccasionalConsumerOf<SimpleMessage> | ||
{ | ||
private readonly IWindsorContainer container; | ||
public static ManualResetEvent wait; | ||
public static bool GotConsumed; | ||
public class Occasional_consumer_resolving_when_not_subscribed : OccasionalConsumerOf<SimpleMessage> | ||
{ | ||
private readonly IWindsorContainer container; | ||
public static ManualResetEvent wait; | ||
public static bool GotConsumed; | ||
|
||
public Occasional_consumer_resolving_when_not_subscribed() | ||
public Occasional_consumer_resolving_when_not_subscribed() | ||
{ | ||
container = new WindsorContainer(new XmlInterpreter()); | ||
container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility()); | ||
container.AddComponent<Occasional_consumer_resolving_when_not_subscribed>(); | ||
container.AddComponent<Not_consumed>(); | ||
container.Register(Component.For<Occasional_consumer_resolving_when_not_subscribed>()); | ||
container.Register(Component.For<Not_consumed>()); | ||
} | ||
|
||
[Fact] | ||
public void Would_not_gather_occasional_consumer_if_not_instance_subscribed() | ||
{ | ||
using (var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
wait = new ManualResetEvent(false); | ||
bus.Start(); | ||
using (bus.AddInstanceSubscription(this)) | ||
{ | ||
bus.Send(new SimpleMessage()); | ||
wait.WaitOne(TimeSpan.FromSeconds(5), false); | ||
} | ||
} | ||
Assert.False(GotConsumed); | ||
} | ||
|
||
public void Consume(SimpleMessage message) | ||
{ | ||
} | ||
} | ||
|
||
public class SimpleMessage { } | ||
|
||
public class Not_consumed : OccasionalConsumerOf<SimpleMessage> | ||
{ | ||
public void Consume(SimpleMessage message) | ||
{ | ||
Occasional_consumer_resolving_when_not_subscribed.GotConsumed = true; | ||
Occasional_consumer_resolving_when_not_subscribed.wait.Set(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Would_not_gather_occasional_consumer_if_not_instance_subscribed() | ||
{ | ||
using (var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
wait = new ManualResetEvent(false); | ||
bus.Start(); | ||
using (bus.AddInstanceSubscription(this)) | ||
{ | ||
bus.Send(new SimpleMessage()); | ||
wait.WaitOne(TimeSpan.FromSeconds(5), false); | ||
} | ||
} | ||
Assert.False(GotConsumed); | ||
} | ||
|
||
public void Consume(SimpleMessage message) | ||
{ | ||
} | ||
} | ||
|
||
public class SimpleMessage { } | ||
|
||
public class Not_consumed : OccasionalConsumerOf<SimpleMessage> | ||
{ | ||
public void Consume(SimpleMessage message) | ||
{ | ||
Occasional_consumer_resolving_when_not_subscribed.GotConsumed = true; | ||
Occasional_consumer_resolving_when_not_subscribed.wait.Set(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 59 additions & 58 deletions
117
Rhino.ServiceBus.Tests/Bugs/WhenTransactionCommitErrors_ShouldNotCrash.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,80 @@ | ||
using System; | ||
using System.Messaging; | ||
using System.Transactions; | ||
using Castle.MicroKernel.Registration; | ||
using Castle.Windsor; | ||
using Castle.Windsor.Configuration.Interpreters; | ||
using Rhino.ServiceBus.Impl; | ||
using Xunit; | ||
|
||
namespace Rhino.ServiceBus.Tests.Bugs | ||
{ | ||
public class WhenTransactionCommitErrors_ShouldNotCrash_Msmq : MsmqTestBase | ||
{ | ||
public class BadEnlistment : IEnlistmentNotification | ||
{ | ||
public BadEnlistment() | ||
{ | ||
Transaction.Current.EnlistVolatile(this, EnlistmentOptions.None); | ||
} | ||
public class WhenTransactionCommitErrors_ShouldNotCrash_Msmq : MsmqTestBase | ||
{ | ||
public class BadEnlistment : IEnlistmentNotification | ||
{ | ||
public BadEnlistment() | ||
{ | ||
Transaction.Current.EnlistVolatile(this, EnlistmentOptions.None); | ||
} | ||
|
||
public void Prepare(PreparingEnlistment preparingEnlistment) | ||
{ | ||
preparingEnlistment.ForceRollback(new InvalidOperationException("blah")); | ||
} | ||
public void Prepare(PreparingEnlistment preparingEnlistment) | ||
{ | ||
preparingEnlistment.ForceRollback(new InvalidOperationException("blah")); | ||
} | ||
|
||
public void Commit(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
public void Commit(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
|
||
public void Rollback(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
public void Rollback(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
|
||
public void InDoubt(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
} | ||
public void InDoubt(Enlistment enlistment) | ||
{ | ||
enlistment.Done(); | ||
} | ||
} | ||
|
||
public class MsgToCreateBadTxEnlistment{} | ||
public class MsgToCreateBadTxEnlistment { } | ||
|
||
public class ConsumerEnlistingInBadTransaction : ConsumerOf<MsgToCreateBadTxEnlistment> | ||
{ | ||
public void Consume(MsgToCreateBadTxEnlistment message) | ||
{ | ||
new BadEnlistment(); | ||
} | ||
} | ||
public class ConsumerEnlistingInBadTransaction : ConsumerOf<MsgToCreateBadTxEnlistment> | ||
{ | ||
public void Consume(MsgToCreateBadTxEnlistment message) | ||
{ | ||
new BadEnlistment(); | ||
} | ||
} | ||
|
||
private static IWindsorContainer CreateContainer() | ||
{ | ||
var container = new WindsorContainer(new XmlInterpreter()); | ||
container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility()); | ||
container.Kernel.AddComponent<ConsumerEnlistingInBadTransaction>(); | ||
return container; | ||
} | ||
private static IWindsorContainer CreateContainer() | ||
{ | ||
var container = new WindsorContainer(new XmlInterpreter()); | ||
container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility()); | ||
container.Register(Component.For<ConsumerEnlistingInBadTransaction>()); | ||
return container; | ||
} | ||
|
||
[Fact] | ||
public void Can_survive_errors_during_commit_phase() | ||
{ | ||
using(var container = CreateContainer()) | ||
using(var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
bus.Start(); | ||
[Fact] | ||
public void Can_survive_errors_during_commit_phase() | ||
{ | ||
using (var container = CreateContainer()) | ||
using (var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
bus.Start(); | ||
|
||
bus.Send(bus.Endpoint, new MsgToCreateBadTxEnlistment()); | ||
bus.Send(bus.Endpoint, new MsgToCreateBadTxEnlistment()); | ||
|
||
using (var errQueue = new MessageQueue(testQueuePath + ";errors")) | ||
{ | ||
var message = errQueue.Receive(); | ||
Assert.Equal("Rhino.ServiceBus.Tests.Bugs.WhenTransactionCommitErrors_ShouldNotCrash_Msmq+MsgToCreateBadTxEnlistment", message.Label); | ||
var err = errQueue.Receive(); | ||
Assert.Equal("Error description for: Rhino.ServiceBus.Tests.Bugs.WhenTransactionCommitErrors_ShouldNotCrash_Msmq+MsgToCreateBadTxEnlistment", err.Label); | ||
} | ||
} | ||
} | ||
} | ||
using (var errQueue = new MessageQueue(testQueuePath + ";errors")) | ||
{ | ||
var message = errQueue.Receive(); | ||
Assert.Equal("Rhino.ServiceBus.Tests.Bugs.WhenTransactionCommitErrors_ShouldNotCrash_Msmq+MsgToCreateBadTxEnlistment", message.Label); | ||
var err = errQueue.Receive(); | ||
Assert.Equal("Error description for: Rhino.ServiceBus.Tests.Bugs.WhenTransactionCommitErrors_ShouldNotCrash_Msmq+MsgToCreateBadTxEnlistment", err.Label); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.