diff --git a/.gitignore b/.gitignore index 3ecfdb073..81e89fb6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ -build +nugets build32 binaries obj bin +*.vshost.* .nu _ReSharper.* _UpgradeReport.* @@ -14,7 +15,6 @@ _UpgradeReport.* *~ *.swp *.user -logs TestResults TestResult.xml results @@ -30,6 +30,9 @@ Artifacts LogFiles csx *.ncrunchproject -run-git.cmd *.ncrunchsolution _NCrunch_NServiceBus/* +logs +run-git.cmd +src/Chocolatey/Build/* +App_Packages diff --git a/buildsupport/FubuCore.dll b/buildsupport/FubuCore.dll index bc83892c3..de611bc01 100644 Binary files a/buildsupport/FubuCore.dll and b/buildsupport/FubuCore.dll differ diff --git a/buildsupport/FubuCore.pdb b/buildsupport/FubuCore.pdb deleted file mode 100644 index 2c861d0a3..000000000 Binary files a/buildsupport/FubuCore.pdb and /dev/null differ diff --git a/buildsupport/GitFlowVersion/Build/GitFlowVersionTask.targets b/buildsupport/GitFlowVersion/Build/GitFlowVersionTask.targets index a86a24af6..842a319eb 100644 --- a/buildsupport/GitFlowVersion/Build/GitFlowVersionTask.targets +++ b/buildsupport/GitFlowVersion/Build/GitFlowVersionTask.targets @@ -7,31 +7,39 @@ + - + - - + - - + + + + diff --git a/buildsupport/GitFlowVersion/GitFlowVersion.exe b/buildsupport/GitFlowVersion/GitFlowVersion.exe index e6ac23338..7bef59da5 100644 Binary files a/buildsupport/GitFlowVersion/GitFlowVersion.exe and b/buildsupport/GitFlowVersion/GitFlowVersion.exe differ diff --git a/buildsupport/GitFlowVersion/GitFlowVersion.pdb b/buildsupport/GitFlowVersion/GitFlowVersion.pdb index a7222ce8e..3812304ae 100644 Binary files a/buildsupport/GitFlowVersion/GitFlowVersion.pdb and b/buildsupport/GitFlowVersion/GitFlowVersion.pdb differ diff --git a/buildsupport/GitFlowVersion/GitFlowVersionTask.dll b/buildsupport/GitFlowVersion/GitFlowVersionTask.dll index 7acba0866..f01dd30a0 100644 Binary files a/buildsupport/GitFlowVersion/GitFlowVersionTask.dll and b/buildsupport/GitFlowVersion/GitFlowVersionTask.dll differ diff --git a/buildsupport/GitFlowVersion/GitFlowVersionTask.pdb b/buildsupport/GitFlowVersion/GitFlowVersionTask.pdb index 4b71b1a03..660391984 100644 Binary files a/buildsupport/GitFlowVersion/GitFlowVersionTask.pdb and b/buildsupport/GitFlowVersion/GitFlowVersionTask.pdb differ diff --git a/buildsupport/GitFlowVersion/LibGit2Sharp.dll b/buildsupport/GitFlowVersion/LibGit2Sharp.dll index 93d322ed5..a8e940c4b 100644 Binary files a/buildsupport/GitFlowVersion/LibGit2Sharp.dll and b/buildsupport/GitFlowVersion/LibGit2Sharp.dll differ diff --git a/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-11f8336.dll b/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-11f8336.dll deleted file mode 100644 index d06ebea12..000000000 Binary files a/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-11f8336.dll and /dev/null differ diff --git a/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-65e9dc6.dll b/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-65e9dc6.dll new file mode 100644 index 000000000..d548c861e Binary files /dev/null and b/buildsupport/GitFlowVersion/NativeBinaries/amd64/git2-65e9dc6.dll differ diff --git a/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-11f8336.dll b/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-11f8336.dll deleted file mode 100644 index 7d66ec112..000000000 Binary files a/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-11f8336.dll and /dev/null differ diff --git a/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-65e9dc6.dll b/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-65e9dc6.dll new file mode 100644 index 000000000..040f87c75 Binary files /dev/null and b/buildsupport/GitFlowVersion/NativeBinaries/x86/git2-65e9dc6.dll differ diff --git a/buildsupport/MSBuild.Community.Tasks.dll b/buildsupport/MSBuild.Community.Tasks.dll new file mode 100644 index 000000000..6d43c0e5b Binary files /dev/null and b/buildsupport/MSBuild.Community.Tasks.dll differ diff --git a/buildsupport/NuGet.Core.dll b/buildsupport/NuGet.Core.dll index 390e4e025..a5787205f 100644 Binary files a/buildsupport/NuGet.Core.dll and b/buildsupport/NuGet.Core.dll differ diff --git a/buildsupport/PepitaPackage.dll b/buildsupport/PepitaPackage.dll new file mode 100644 index 000000000..d1509d1b2 Binary files /dev/null and b/buildsupport/PepitaPackage.dll differ diff --git a/buildsupport/RippleRestoreTask.dll b/buildsupport/RippleRestoreTask.dll index bb438ef2a..e443473c5 100644 Binary files a/buildsupport/RippleRestoreTask.dll and b/buildsupport/RippleRestoreTask.dll differ diff --git a/buildsupport/RippleRestoreTask.pdb b/buildsupport/RippleRestoreTask.pdb deleted file mode 100644 index ef5ffaf6e..000000000 Binary files a/buildsupport/RippleRestoreTask.pdb and /dev/null differ diff --git a/buildsupport/RippleRestoreTask.targets b/buildsupport/RippleRestoreTask.targets index 9f45f0113..cb3f1b839 100644 --- a/buildsupport/RippleRestoreTask.targets +++ b/buildsupport/RippleRestoreTask.targets @@ -2,7 +2,7 @@ $(MSBuildProjectDirectory)\..\ - + RippleRestoreTarget; $(BuildDependsOn); diff --git a/buildsupport/Timestamp/Timestamp.dll b/buildsupport/Timestamp/Timestamp.dll deleted file mode 100644 index 4d0be4e1c..000000000 Binary files a/buildsupport/Timestamp/Timestamp.dll and /dev/null differ diff --git a/buildsupport/Timestamp/Timestamp.pdb b/buildsupport/Timestamp/Timestamp.pdb deleted file mode 100644 index b34f48cac..000000000 Binary files a/buildsupport/Timestamp/Timestamp.pdb and /dev/null differ diff --git a/buildsupport/ripple.exe b/buildsupport/ripple.exe index 6daed2576..f2b3de268 100644 Binary files a/buildsupport/ripple.exe and b/buildsupport/ripple.exe differ diff --git a/buildsupport/ripple.pdb b/buildsupport/ripple.pdb deleted file mode 100644 index 25d4f108c..000000000 Binary files a/buildsupport/ripple.pdb and /dev/null differ diff --git a/ripple.cmd b/ripple.cmd new file mode 100644 index 000000000..74b6af73f --- /dev/null +++ b/ripple.cmd @@ -0,0 +1 @@ +buildsupport\ripple.exe %* \ No newline at end of file diff --git a/ripple.config b/ripple.config index 8e8b61f15..5f482d90b 100644 --- a/ripple.config +++ b/ripple.config @@ -1,5 +1,5 @@ - + NServiceBus.SqlServer packaging/nuget src @@ -8,56 +8,19 @@ CurrentMajor,NextMajor Current,NextMajor - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_a_message_is_audited.cs deleted file mode 100644 index c17f3a0cc..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_a_message_is_audited.cs +++ /dev/null @@ -1,119 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Audit -{ - using System; - using System.Linq; - using EndpointTemplates; - using AcceptanceTesting; - using MessageMutator; - using NUnit.Framework; - -#pragma warning disable 612, 618 - - public class When_a_message_is_audited : NServiceBusAcceptanceTest - { - [Test] - public void Should_preserve_the_original_body() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeAudited()))) - .WithEndpoint() - .Done(c => c.AuditChecksum != default(byte)) - .Run(); - - Assert.AreEqual(context.OriginalBodyChecksum, context.AuditChecksum, "The body of the message sent to audit should be the same as the original message coming off the queue"); - } - - - public class Context : ScenarioContext - { - public byte OriginalBodyChecksum { get; set; } - - public byte AuditChecksum { get; set; } - } - - public class EndpointWithAuditOn : EndpointConfigurationBuilder - { - public EndpointWithAuditOn() - { - EndpointSetup() - .AuditTo(); - } - - class BodyMutator : IMutateTransportMessages, NServiceBus.INeedInitialization - { - public Context Context { get; set; } - - public void MutateIncoming(TransportMessage transportMessage) - { - - var originalBody = transportMessage.Body; - - Context.OriginalBodyChecksum = Checksum(originalBody); - - var decryptedBody = new byte[originalBody.Length]; - - Buffer.BlockCopy(originalBody,0,decryptedBody,0,originalBody.Length); - - //decrypt - decryptedBody[0]++; - - transportMessage.Body = decryptedBody; - } - - - public void MutateOutgoing(object[] messages, TransportMessage transportMessage) - { - //not the way to do it for real but good enough for this test - transportMessage.Body[0]--; - } - - public void Init() - { - Configure.Component(DependencyLifecycle.InstancePerCall); - } - } - - - class MessageToBeAuditedHandler : IHandleMessages{ public void Handle(MessageToBeAudited message) {}} - } - - class AuditSpyEndpoint : EndpointConfigurationBuilder - { - public AuditSpyEndpoint() - { - EndpointSetup(); - } - - class BodySpy : IMutateIncomingTransportMessages, NServiceBus.INeedInitialization - { - public Context Context { get; set; } - - public void MutateIncoming(TransportMessage transportMessage) - { - Context.AuditChecksum = Checksum(transportMessage.Body); - } - - public void Init() - { - Configure.Component(DependencyLifecycle.InstancePerCall); - } - } - } - - public static byte Checksum(byte[] data) - { - var longSum = data.Sum(x => (long)x); - return unchecked((byte)longSum); - } - - [Serializable] - public class MessageToBeAudited : IMessage - { - } - } - -#pragma warning restore 612, 618 - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_using_auditing_as_a_feature.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_using_auditing_as_a_feature.cs deleted file mode 100644 index 1df939607..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Audit/When_using_auditing_as_a_feature.cs +++ /dev/null @@ -1,111 +0,0 @@ - -namespace NServiceBus.AcceptanceTests.Audit -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_using_auditing_as_a_feature : NServiceBusAcceptanceTest - { - [Test] - public void Message_should_not_be_forwarded_to_auditQueue_when_auditing_is_disabled() - { - var context = new Context(); - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeAudited()))) - .WithEndpoint() - .Done(c => c.IsMessageHandlingComplete) - .Run(); - - Assert.IsFalse(context.IsMessageHandledByTheAuditEndpoint); - } - - [Test] - public void Message_should_be_forwarded_to_auditQueue_when_auditing_is_enabled() - { - var context = new Context(); - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeAudited()))) - .WithEndpoint() - .Done(c => c.IsMessageHandlingComplete) - .Run(); - - Assert.IsTrue(context.IsMessageHandledByTheAuditEndpoint); - } - - public class Context : ScenarioContext - { - public bool IsMessageHandlingComplete { get; set; } - public bool IsMessageHandledByTheAuditEndpoint { get; set; } - } - - public class EndpointWithAuditOff : EndpointConfigurationBuilder - { - - public EndpointWithAuditOff() - { - // Although the AuditTo seems strange here, this test tries to fake the scenario where - // even though the user has specified audit config, because auditing is explicitly turned - // off, no messages should be audited. - EndpointSetup(c => Configure.Features.Disable()) - .AuditTo(); - - } - - class MessageToBeAuditedHandler : IHandleMessages - { - public Context MyContext { get; set; } - - public void Handle(MessageToBeAudited message) - { - MyContext.IsMessageHandlingComplete = true; - } - } - } - - public class EndpointWithAuditOn : EndpointConfigurationBuilder - { - - public EndpointWithAuditOn() - { - EndpointSetup() - .AuditTo(); - } - - class MessageToBeAuditedHandler : IHandleMessages - { - public Context MyContext { get; set; } - - public void Handle(MessageToBeAudited message) - { - MyContext.IsMessageHandlingComplete = true; - } - } - } - - public class EndpointThatHandlesAuditMessages : EndpointConfigurationBuilder - { - - public EndpointThatHandlesAuditMessages() - { - EndpointSetup(); - } - - class AuditMessageHandler : IHandleMessages - { - public Context MyContext { get; set; } - - public void Handle(MessageToBeAudited message) - { - MyContext.IsMessageHandledByTheAuditEndpoint = true; - } - } - } - - [Serializable] - public class MessageToBeAudited : IMessage - { - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/MessingAround.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/MessingAround.cs deleted file mode 100644 index b9348f5c2..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/MessingAround.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using System.Collections.Generic; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class MessingAround : NServiceBusAcceptanceTest - { - [Test, Ignore("Just added for convenience")] - public void CanExecuteEntirePipelineInRealisticScenario() - { - Scenario.Define(() => new Context { Id = Guid.NewGuid() }) - .WithEndpoint(b => b.Given((bus, context) => bus.Send(new MyMessage { Id = context.Id }))) - .WithEndpoint() - .Done(c => c.WasCalled) - .Repeat(r => r.For(Serializers.Xml) - .For(Builders.Windsor)) - .Should(c => - { - Assert.True(c.WasCalled, "The message handler should be called"); - Assert.AreEqual(1, c.TimesCalled, "The message handler should only be invoked once"); - Assert.AreEqual(Environment.MachineName, c.ReceivedHeaders[Headers.OriginatingMachine], "The sender should attach the machine name as a header"); - Assert.True(c.ReceivedHeaders[Headers.OriginatingEndpoint].Contains("Sender"), "The sender should attach its endpoint name as a header"); - Assert.AreEqual(Environment.MachineName, c.ReceivedHeaders[Headers.ProcessingMachine], "The receiver should attach the machine name as a header"); - Assert.True(c.ReceivedHeaders[Headers.ProcessingEndpoint].Contains("Receiver"), "The receiver should attach its endpoint name as a header"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool WasCalled { get; set; } - public int TimesCalled { get; set; } - public IDictionary ReceivedHeaders { get; set; } - public Guid Id { get; set; } - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup() - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - EndpointSetup(); - } - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyMessage message) - { - if (Context.Id != message.Id) - return; - - Context.TimesCalled++; - - Context.ReceivedHeaders = Bus.CurrentMessageContext.Headers; - - Context.WasCalled = true; - } - } - - [Serializable] - public class MyMessage : ICommand - { - public Guid Id { get; set; } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_aborting_the_behavior_chain.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_aborting_the_behavior_chain.cs deleted file mode 100644 index dcb50ea51..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_aborting_the_behavior_chain.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - - public class When_aborting_the_behavior_chain : NServiceBusAcceptanceTest - { - [Test] - public void Subsequent_handlers_will_not_be_invoked() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.Send(Address.Local, new SomeMessage()))) - .Done(c => c.FirstHandlerInvoked) - .Run(); - - Assert.That(context.FirstHandlerInvoked, Is.True); - Assert.That(context.SecondHandlerInvoked, Is.False); - } - - public class Context : ScenarioContext - { - public bool FirstHandlerInvoked { get; set; } - public bool SecondHandlerInvoked { get; set; } - } - - [Serializable] - public class SomeMessage : IMessage { } - - public class MyEndpoint : EndpointConfigurationBuilder - { - public MyEndpoint() - { - EndpointSetup(); - } - - class EnsureOrdering : ISpecifyMessageHandlerOrdering - { - public void SpecifyOrder(Order order) - { - order.Specify(First.Then()); - } - } - - class FirstHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(SomeMessage message) - { - Context.FirstHandlerInvoked = true; - - Bus.DoNotContinueDispatchingCurrentMessageToHandlers(); - } - } - - class SecondHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(SomeMessage message) - { - Context.SecondHandlerInvoked = true; - } - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_handling_current_message_later.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_handling_current_message_later.cs deleted file mode 100644 index 00420aed9..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_handling_current_message_later.cs +++ /dev/null @@ -1,157 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using System.Linq; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - - public class When_handling_current_message_later : NServiceBusAcceptanceTest - { - [Test] - public void Should_commit_unit_of_work() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.Send(Address.Local, new SomeMessage()))) - .Done(c => c.Done) - .Run(); - - Assert.That(context.AnotherMessageReceivedCount, Is.EqualTo(2), - "First handler sends a message to self, which should result in AnotherMessage being dispatched twice"); - } - - [Test, Description("NOTE the double negation - we should probably modify this behavior somehow")] - public void Should_not_not_execute_subsequent_handlers() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.Send(Address.Local, new SomeMessage()))) - .Done(c => c.Done) - .Run(); - - Assert.That(context.ThirdHandlerInvocationCount, Is.EqualTo(2), - "Since calling HandleCurrentMessageLater does not discontinue message dispatch, the third handler should be called twice as well"); - } - - [Test] - public void Handlers_are_executed_in_the_right_order() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.Send(Address.Local, new SomeMessage()))) - .Done(c => c.Done) - .Run(); - - var events = context.Events; - CollectionAssert - .AreEquivalent(new[] - { - "FirstHandler:Executed", - "SecondHandler:Sending message to the back of the queue", - "ThirdHandler:Executed", - "FirstHandler:Executed", - "SecondHandler:Handling the message this time", - "ThirdHandler:Executed", - }, - events); - } - - public class Context : ScenarioContext - { - public string[] Events { get; set; } - - public bool SomeMessageHasBeenRequeued { get; set; } - - public bool Done - { - get { return ThirdHandlerInvocationCount >= 2 && AnotherMessageReceivedCount == 2; } - } - - public int AnotherMessageReceivedCount { get; set; } - - public int ThirdHandlerInvocationCount { get; set; } - } - - [Serializable] - public class SomeMessage : IMessage { } - - [Serializable] - public class AnotherMessage : IMessage { } - - public class MyEndpoint : EndpointConfigurationBuilder - { - public MyEndpoint() - { - EndpointSetup(); - } - - class EnsureOrdering : ISpecifyMessageHandlerOrdering - { - public void SpecifyOrder(Order order) - { - order.Specify(First.Then().AndThen()); - } - } - - class FirstHandler : IHandleMessages, IHandleMessages - { - public Context Context { get; set; } - public IBus Bus { get; set; } - - public void Handle(SomeMessage message) - { - Context.RegisterEvent("FirstHandler:Executed"); - Bus.SendLocal(new AnotherMessage()); - } - - public void Handle(AnotherMessage message) - { - Context.AnotherMessageReceivedCount++; - } - } - - class SecondHandler : IHandleMessages - { - public Context Context { get; set; } - public IBus Bus { get; set; } - public void Handle(SomeMessage message) - { - if (!Context.SomeMessageHasBeenRequeued) - { - Context.RegisterEvent("SecondHandler:Sending message to the back of the queue"); - Bus.HandleCurrentMessageLater(); - Context.SomeMessageHasBeenRequeued = true; - } - else - { - Context.RegisterEvent("SecondHandler:Handling the message this time"); - } - } - } - - class ThirdHandler : IHandleMessages - { - public Context Context { get; set; } - public void Handle(SomeMessage message) - { - Context.RegisterEvent("ThirdHandler:Executed"); - Context.ThirdHandlerInvocationCount++; - } - } - } - } - - static class ContextEx - { - public static void RegisterEvent(this When_handling_current_message_later.Context context, string description) - { - context.Events = context.Events - .Concat(new[] {description}) - .ToArray(); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_registering_a_callback_for_a_local_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_registering_a_callback_for_a_local_message.cs deleted file mode 100644 index d00d0102b..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_registering_a_callback_for_a_local_message.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_registering_a_callback_for_a_local_message : NServiceBusAcceptanceTest - { - [Test] - public void Should_trigger_the_callback_when_the_response_comes_back() - { - Scenario.Define() - .WithEndpoint(b=>b.Given( - (bus,context)=>bus.SendLocal(new MyRequest()).Register(r => - { - Assert.True(context.HandlerGotTheRequest); - context.CallbackFired = true; - }))) - .Done(c => c.CallbackFired) - .Repeat(r =>r.For(Transports.Default)) - .Should(c => - { - Assert.True(c.CallbackFired); - Assert.True(c.HandlerGotTheRequest); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool HandlerGotTheRequest { get; set; } - - public bool CallbackFired { get; set; } - } - - public class EndpointWithLocalCallback : EndpointConfigurationBuilder - { - public EndpointWithLocalCallback() - { - EndpointSetup(); - } - - public class MyRequestHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyRequest request) - { - Assert.False(Context.CallbackFired); - Context.HandlerGotTheRequest = true; - - Bus.Return(1); - } - } - } - - [Serializable] - public class MyRequest : IMessage{} - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_sending_a_message_to_another_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_sending_a_message_to_another_endpoint.cs deleted file mode 100644 index 44e5b2bc6..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_sending_a_message_to_another_endpoint.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using System.Collections.Generic; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_a_message_to_another_endpoint : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_the_message() - { - Scenario.Define(() => new Context { Id = Guid.NewGuid() }) - .WithEndpoint(b => b.Given((bus, context) => bus.Send(new MyMessage { Id = context.Id }))) - .WithEndpoint() - .Done(c => c.WasCalled) - .Repeat(r =>r.For(Serializers.Binary) - .For() - ) - .Should(c => - { - Assert.True(c.WasCalled, "The message handler should be called"); - Assert.AreEqual(1, c.TimesCalled, "The message handler should only be invoked once"); - Assert.AreEqual(Environment.MachineName, c.ReceivedHeaders[Headers.OriginatingMachine], "The sender should attach the machine name as a header"); - Assert.True(c.ReceivedHeaders[Headers.OriginatingEndpoint].Contains("Sender"), "The sender should attach its endpoint name as a header"); - Assert.AreEqual(Environment.MachineName, c.ReceivedHeaders[Headers.ProcessingMachine], "The receiver should attach the machine name as a header"); - Assert.True(c.ReceivedHeaders[Headers.ProcessingEndpoint].Contains("Receiver"), "The receiver should attach its endpoint name as a header"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool WasCalled { get; set; } - - public int TimesCalled { get; set; } - - public IDictionary ReceivedHeaders { get; set; } - - public Guid Id { get; set; } - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup() - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - EndpointSetup(); - } - } - - [Serializable] - public class MyMessage : ICommand - { - public Guid Id { get; set; } - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyMessage message) - { - if (Context.Id != message.Id) - return; - - Context.TimesCalled++; - - Context.ReceivedHeaders = Bus.CurrentMessageContext.Headers; - - Context.WasCalled = true; - } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_a_custom_correlation_id.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_a_custom_correlation_id.cs deleted file mode 100644 index f1221c4e1..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_a_custom_correlation_id.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using MessageMutator; - using NUnit.Framework; - - public class When_using_a_custom_correlation_id : NServiceBusAcceptanceTest - { - static string CorrelationId = "my_custom_correlation_id"; - - [Test] - public void Should_use_the_given_id_as_the_transport_level_correlation_id() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.Send(Address.Local, CorrelationId, new MyRequest()))) - .Done(c => c.GotRequest) - .Run(); - - Assert.AreEqual(CorrelationId, context.CorrelationIdReceived, "Correlation ids should match"); - } - - public class Context : ScenarioContext - { - public bool GotRequest { get; set; } - - public string CorrelationIdReceived { get; set; } - } - - public class CorrelationEndpoint : EndpointConfigurationBuilder - { - public CorrelationEndpoint() - { - EndpointSetup(); - } - - class GetValueOfIncomingCorrelationId:IMutateIncomingTransportMessages,INeedInitialization - { - public Context Context { get; set; } - - public void MutateIncoming(TransportMessage transportMessage) - { - Context.CorrelationIdReceived = transportMessage.CorrelationId; - } - - public void Init() - { - Configure.Component(DependencyLifecycle.InstancePerCall); - } - } - - public class MyResponseHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyRequest response) - { - Context.GotRequest = true; - } - } - } - - - [Serializable] - public class MyRequest : IMessage - { - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_callbacks_in_a_scaleout_scenario.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_callbacks_in_a_scaleout_scenario.cs deleted file mode 100644 index db1df8120..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BasicMessaging/When_using_callbacks_in_a_scaleout_scenario.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BasicMessaging -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - using Support; - - public class When_using_callbacks_in_a_scaleout_scenario : NServiceBusAcceptanceTest - { - [Test] - public void Each_client_should_have_a_unique_input_queue_to_avoid_processing_each_others_callbacks() - { - Scenario.Define(() => new Context{Id = Guid.NewGuid()}) - .WithEndpoint(b => b.CustomConfig(c=>RuntimeEnvironment.MachineNameAction = () => "ClientA") - .Given((bus, context) => bus.Send(new MyRequest { Id = context.Id, Client = RuntimeEnvironment.MachineName }) - .Register(r => context.CallbackAFired = true))) - .WithEndpoint(b => b.CustomConfig(c=>RuntimeEnvironment.MachineNameAction = () => "ClientB") - .Given((bus, context) => bus.Send(new MyRequest { Id = context.Id, Client = RuntimeEnvironment.MachineName }) - .Register(r => context.CallbackBFired = true))) - .WithEndpoint() - .Done(c => c.ClientAGotResponse && c.ClientBGotResponse) - .Repeat(r =>r.For() - ) - .Should(c => - { - Assert.True(c.CallbackAFired, "Callback on ClientA should fire"); - Assert.True(c.CallbackBFired, "Callback on ClientB should fire"); - Assert.False(c.ResponseEndedUpAtTheWrongClient, "One of the responses ended up at the wrong client"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public Guid Id { get; set; } - - public bool ClientAGotResponse { get; set; } - - public bool ClientBGotResponse { get; set; } - - public bool ResponseEndedUpAtTheWrongClient { get; set; } - - public bool CallbackAFired { get; set; } - - public bool CallbackBFired { get; set; } - } - - public class Client : EndpointConfigurationBuilder - { - public Client() - { - EndpointSetup(c => Configure.ScaleOut(s => s.UseUniqueBrokerQueuePerMachine())) - .AddMapping(typeof(Server)); - } - - public class MyResponseHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyResponse response) - { - if (Context.Id != response.Id) - return; - - if (RuntimeEnvironment.MachineName == "ClientA") - Context.ClientAGotResponse = true; - else - { - Context.ClientBGotResponse = true; - } - - if (RuntimeEnvironment.MachineName != response.Client) - Context.ResponseEndedUpAtTheWrongClient = true; - } - } - } - - public class Server : EndpointConfigurationBuilder - { - public Server() - { - EndpointSetup(); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyRequest request) - { - if (Context.Id != request.Id) - return; - - - Bus.Reply(new MyResponse { Id = request.Id,Client = request.Client }); - } - } - } - - [Serializable] - public class MyRequest : IMessage - { - public Guid Id { get; set; } - - public string Client { get; set; } - } - - [Serializable] - public class MyResponse : IMessage - { - public Guid Id { get; set; } - - public string Client { get; set; } - } - - - - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/BusStartStop/When_bus_start_and_stops_with_a_pending_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/BusStartStop/When_bus_start_and_stops_with_a_pending_message.cs deleted file mode 100644 index 8b252ea7e..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/BusStartStop/When_bus_start_and_stops_with_a_pending_message.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace NServiceBus.AcceptanceTests.BusStartStop -{ - using System; - using System.Threading; - using AcceptanceTesting.Support; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_bus_start_and_stops_with_a_pending_message : NServiceBusAcceptanceTest - { - [Test] - public void Should_not_throw() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => SendMessages(b)) - .Run(TimeSpan.FromMilliseconds(100)); - - Thread.Sleep(100); - } - - - EndpointBehaviorBuilder SendMessages(EndpointBehaviorBuilder b) - { - return b.Given((bus, context) => bus.SendLocal(new Message())); - } - - public class Context : ScenarioContext - { - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(); - } - - class MessageHandler : IHandleMessages - { - public void Handle(Message message) - { - Thread.Sleep(100); - } - } - } - - [Serializable] - public class Message : IMessage - { - } - - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Configuration/When_a_config_override_is_found.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Configuration/When_a_config_override_is_found.cs deleted file mode 100644 index 3e130676c..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Configuration/When_a_config_override_is_found.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Configuration -{ - using Config; - using Config.ConfigurationSource; - using EndpointTemplates; - using AcceptanceTesting; - using Faults.Forwarder; - using NUnit.Framework; - using Unicast; - using Unicast.Transport; - - public class When_a_config_override_is_found : NServiceBusAcceptanceTest - { - static Address CustomErrorQ = Address.Parse("MyErrorQ"); - - [Test] - public void Should_be_used_instead_of_pulling_the_settings_from_appconfig() - { - var context = Scenario.Define() - .WithEndpoint(b => b.When(c => c.EndpointsStarted, (bus, cc) => - { - var unicastBus = (UnicastBus)bus; - var transport = (TransportReceiver)unicastBus.Transport; - var fm = (FaultManager)transport.FailureManager; - - cc.ErrorQueueUsedByTheEndpoint = fm.ErrorQueue; - cc.IsDone = true; - })) - .Done(c => c.IsDone) - .Run(); - - Assert.AreEqual(CustomErrorQ, context.ErrorQueueUsedByTheEndpoint, "The error queue should have been changed"); - - } - - public class Context : ScenarioContext - { - public bool IsDone { get; set; } - - public Address ErrorQueueUsedByTheEndpoint { get; set; } - } - - public class ConfigOverrideEndpoint : EndpointConfigurationBuilder - { - public ConfigOverrideEndpoint() - { - EndpointSetup(c => c.MessageForwardingInCaseOfFault()); - } - - public class ConfigErrorQueue : IProvideConfiguration - { - public MessageForwardingInCaseOfFaultConfig GetConfiguration() - { - - return new MessageForwardingInCaseOfFaultConfig - { - ErrorQueue = CustomErrorQ.ToString() - }; - } - } - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/DataBus/When_sending_databus_properties.cs b/src/NServiceBus.SqlServer.AcceptanceTests/DataBus/When_sending_databus_properties.cs deleted file mode 100644 index db691ccc6..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/DataBus/When_sending_databus_properties.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace NServiceBus.AcceptanceTests.DataBus -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_databus_properties:NServiceBusAcceptanceTest - { - static byte[] PayloadToSend = new byte[1024 * 1024 * 10]; - - [Test] - public void Should_receive_the_message_the_largeproperty_correctly() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus=> bus.Send(new MyMessageWithLargePayload - { - Payload = new DataBusProperty(PayloadToSend) - }))) - .WithEndpoint() - .Done(context => context.ReceivedPayload != null) - .Repeat(r => r.For()) - .Should(c => Assert.AreEqual(PayloadToSend, c.ReceivedPayload, "The large payload should be marshalled correctly using the databus")) - .Run(); - } - - public class Context : ScenarioContext - { - public byte[] ReceivedPayload { get; set; } - } - - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(c => c.FileShareDataBus(@".\databus\sender")) - .AddMapping(typeof (Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - EndpointSetup(c => c.FileShareDataBus(@".\databus\sender")); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyMessageWithLargePayload messageWithLargePayload) - { - Context.ReceivedPayload = messageWithLargePayload.Payload.Value; - } - } - } - - [Serializable] - public class MyMessageWithLargePayload : ICommand - { - public DataBusProperty Payload { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Encryption/When_using_encryption.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Encryption/When_using_encryption.cs deleted file mode 100644 index 6c982f323..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Encryption/When_using_encryption.cs +++ /dev/null @@ -1,117 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Encryption -{ - using System; - using System.Collections.Generic; - using Config; - using Config.ConfigurationSource; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_using_encryption : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_decrypted_message() - { - Scenario.Define() - .WithEndpoint(b => b.Given((bus, context) => bus.SendLocal(new MessageWithSecretData - { - Secret = "betcha can't guess my secret", - SubProperty = new MySecretSubProperty {Secret = "My sub secret"}, - CreditCards = new List - { - new CreditCardDetails - { - ValidTo = DateTime.UtcNow.AddYears(1), - Number = "312312312312312" - }, - new CreditCardDetails - { - ValidTo = DateTime.UtcNow.AddYears(2), - Number = "543645546546456" - } - } - }))) - .Done(c => c.Done) - .Repeat(r => r.For()) - .Should(c => - { - Assert.AreEqual("betcha can't guess my secret", c.Secret); - Assert.AreEqual("My sub secret", c.SubPropertySecret); - CollectionAssert.AreEquivalent(new List { "312312312312312", "543645546546456" }, c.CreditCards); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool Done { get; set; } - - public string Secret { get; set; } - - public string SubPropertySecret { get; set; } - - public List CreditCards { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(c => c.RijndaelEncryptionService()); - } - - public class Handler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MessageWithSecretData message) - { - Context.Secret = message.Secret.Value; - - Context.SubPropertySecret = message.SubProperty.Secret.Value; - - Context.CreditCards = new List - { - message.CreditCards[0].Number.Value, - message.CreditCards[1].Number.Value - }; - - Context.Done = true; - } - } - } - - [Serializable] - public class MessageWithSecretData : IMessage - { - public WireEncryptedString Secret { get; set; } - public MySecretSubProperty SubProperty { get; set; } - public List CreditCards { get; set; } - } - - [Serializable] - public class CreditCardDetails - { - public DateTime ValidTo { get; set; } - public WireEncryptedString Number { get; set; } - } - - [Serializable] - public class MySecretSubProperty - { - public WireEncryptedString Secret { get; set; } - } - - public class ConfigureEncryption: IProvideConfiguration - { - RijndaelEncryptionServiceConfig rijndaelEncryptionServiceConfig = new RijndaelEncryptionServiceConfig { Key = "gdDbqRpqdRbTs3mhdZh9qCaDaxJXl+e6" }; - - public RijndaelEncryptionServiceConfig GetConfiguration() - { - return rijndaelEncryptionServiceConfig; - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/BusExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/BusExtensions.cs deleted file mode 100644 index 6c087c009..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/BusExtensions.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NServiceBus.AcceptanceTests.EndpointTemplates -{ - using AcceptanceTesting; - - public static class BusExtensions - { - public static void EnsureSubscriptionMessagesHaveArrived(this IBus bus) - { - Configure.Instance.Builder.Build() - .Wait(); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/ConfigureExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/ConfigureExtensions.cs deleted file mode 100644 index 1b85ade99..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/ConfigureExtensions.cs +++ /dev/null @@ -1,187 +0,0 @@ -namespace NServiceBus.AcceptanceTests.EndpointTemplates -{ - using System; - using System.Collections.Generic; - using System.Configuration; - using AcceptanceTesting; - using NServiceBus.ObjectBuilder.Autofac; - using NServiceBus.ObjectBuilder.CastleWindsor; - using NServiceBus.ObjectBuilder.Common.Config; - using NServiceBus.ObjectBuilder.Ninject; - using NServiceBus.ObjectBuilder.Spring; - using NServiceBus.ObjectBuilder.StructureMap; - using NServiceBus.ObjectBuilder.Unity; - using NServiceBus.Serializers.Binary; - using NServiceBus.Serializers.Json; - using NServiceBus.Serializers.XML; - using Persistence.InMemory.SagaPersister; - using Persistence.InMemory.SubscriptionStorage; - using Persistence.Msmq.SubscriptionStorage; - using Persistence.NHibernate; - using Persistence.Raven.SagaPersister; - using Persistence.Raven.SubscriptionStorage; - using SagaPersisters.NHibernate; - using Unicast.Subscriptions.NHibernate; - - public static class ConfigureExtensions - { - static string NHibernateConnectionString = @"Server=localhost\sqlexpress;Database=nservicebus;Trusted_Connection=True;"; - - public static string GetOrNull(this IDictionary dictionary, string key) - { - if (!dictionary.ContainsKey(key)) - { - return null; - } - - return dictionary[key]; - } - - public static Configure DefineHowManySubscriptionMessagesToWaitFor(this Configure config, int numberOfSubscriptionsToWaitFor) - { - config.Configurer.ConfigureProperty( - spy => spy.NumberOfSubscriptionsToWaitFor, numberOfSubscriptionsToWaitFor); - - return config; - } - - public static Configure DefineTransport(this Configure config, IDictionary settings) - { - if (!settings.ContainsKey("Transport")) - settings = ScenarioDescriptors.Transports.Default.Settings; - - var transportType = Type.GetType(settings["Transport"]); - - return config.UseTransport(transportType, () => settings["Transport.ConnectionString"]); - - } - - public static Configure DefineSerializer(this Configure config, string serializer) - { - if (string.IsNullOrEmpty(serializer)) - return config;//xml is the default - - var type = Type.GetType(serializer); - - if (type == typeof (XmlMessageSerializer)) - { - Configure.Serialization.Xml(); - return config; - } - - - if (type == typeof (JsonMessageSerializer)) - { - Configure.Serialization.Json(); - return config; - } - - if (type == typeof(BsonMessageSerializer)) - { - Configure.Serialization.Bson(); - return config; - } - - if (type == typeof (BinaryMessageSerializer)) - { - Configure.Serialization.Binary(); - return config; - } - - throw new InvalidOperationException("Unknown serializer:" + serializer); - } - - - public static Configure DefineSagaPersister(this Configure config, string persister) - { - if (string.IsNullOrEmpty(persister)) - return config.InMemorySagaPersister(); - - var type = Type.GetType(persister); - - if (type == typeof(InMemorySagaPersister)) - return config.InMemorySagaPersister(); - - if (type == typeof(RavenSagaPersister)) - { - config.RavenPersistence(() => "url=http://localhost:8080"); - return config.RavenSagaPersister(); - - } - - if (type == typeof(SagaPersister)) - { - NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection {new ConnectionStringSettings("NServiceBus/Persistence", NHibernateConnectionString)}; - return config.UseNHibernateSagaPersister(); - } - - throw new InvalidOperationException("Unknown persister:" + persister); - } - - - public static Configure DefineSubscriptionStorage(this Configure config, string persister) - { - if (string.IsNullOrEmpty(persister)) - return config.InMemorySubscriptionStorage(); - - var type = Type.GetType(persister); - - if (type == typeof(InMemorySubscriptionStorage)) - return config.InMemorySubscriptionStorage(); - - if (type == typeof(RavenSubscriptionStorage)) - { - config.RavenPersistence(() => "url=http://localhost:8080"); - return config.RavenSubscriptionStorage(); - - } - - if (type == typeof(SubscriptionStorage)) - { - NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection {new ConnectionStringSettings("NServiceBus/Persistence", NHibernateConnectionString)}; - return config.UseNHibernateSubscriptionPersister(); - } - - - if (type == typeof(MsmqSubscriptionStorage)) - { - return config.MsmqSubscriptionStorage(); - } - - throw new InvalidOperationException("Unknown persister:" + persister); - } - - public static Configure DefineBuilder(this Configure config, string builder) - { - if (string.IsNullOrEmpty(builder)) - return config.DefaultBuilder(); - - var type = Type.GetType(builder); - - if (type == typeof(AutofacObjectBuilder)) - { - ConfigureCommon.With(config, new AutofacObjectBuilder(null)); - - return config; - } - - if (type == typeof(WindsorObjectBuilder)) - return config.CastleWindsorBuilder(); - - if (type == typeof(NinjectObjectBuilder)) - return config.NinjectBuilder(); - - if (type == typeof(SpringObjectBuilder)) - return config.SpringFrameworkBuilder(); - - if (type == typeof(StructureMapObjectBuilder)) - return config.StructureMapBuilder(); - - if (type == typeof(UnityObjectBuilder)) - return config.StructureMapBuilder(); - - - throw new InvalidOperationException("Unknown builder:" + builder); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/DefaultServer.cs b/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/DefaultServer.cs deleted file mode 100644 index 18859f18d..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/EndpointTemplates/DefaultServer.cs +++ /dev/null @@ -1,102 +0,0 @@ -namespace NServiceBus.AcceptanceTests.EndpointTemplates -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Reflection; - using AcceptanceTesting.Support; - using Config.ConfigurationSource; - using Hosting.Helpers; - using NServiceBus; - using Settings; - - public class DefaultServer : IEndpointSetupTemplate - { - public Configure GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration, IConfigurationSource configSource) - { - var settings = runDescriptor.Settings; - - SetupLogging(endpointConfiguration); - - var types = GetTypesToUse(endpointConfiguration); - - var transportToUse = settings.GetOrNull("Transport"); - - Configure.Features.Enable(); - - SettingsHolder.SetDefault("ScaleOut.UseSingleBrokerQueue", true); - - var config = Configure.With(types) - .DefineEndpointName(endpointConfiguration.EndpointName) - .CustomConfigurationSource(configSource) - .DefineBuilder(settings.GetOrNull("Builder")) - .DefineSerializer(settings.GetOrNull("Serializer")) - .DefineTransport(settings) - .DefineSagaPersister(settings.GetOrNull("SagaPersister")); - - if (transportToUse == null || - transportToUse.Contains("Msmq") || - transportToUse.Contains("SqlServer") || - transportToUse.Contains("RabbitMq")) - config.UseInMemoryTimeoutPersister(); - - if (transportToUse == null || transportToUse.Contains("Msmq") || transportToUse.Contains("SqlServer")) - config.DefineSubscriptionStorage(settings.GetOrNull("SubscriptionStorage")); - - return config.UnicastBus(); - } - - static IEnumerable GetTypesToUse(EndpointConfiguration endpointConfiguration) - { - var assemblies = new AssemblyScanner().GetScannableAssemblies(); - - var types = assemblies.Assemblies - //exclude all test types by default - .Where(a => a != Assembly.GetExecutingAssembly()) - .SelectMany(a => a.GetTypes()); - - - types = types.Union(GetNestedTypeRecursive(endpointConfiguration.BuilderType.DeclaringType, endpointConfiguration.BuilderType)); - - types = types.Union(endpointConfiguration.TypesToInclude); - - return types.Where(t => !endpointConfiguration.TypesToExclude.Contains(t)).ToList(); - } - - static IEnumerable GetNestedTypeRecursive(Type rootType,Type builderType) - { - yield return rootType; - - if (typeof(IEndpointConfigurationFactory).IsAssignableFrom(rootType) && rootType != builderType) - yield break; - - foreach (var nestedType in rootType.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SelectMany(t => GetNestedTypeRecursive(t, builderType))) - { - yield return nestedType; - } - } - - static void SetupLogging(EndpointConfiguration endpointConfiguration) - { - var logDir = ".\\logfiles\\"; - - if (!Directory.Exists(logDir)) - Directory.CreateDirectory(logDir); - - var logFile = Path.Combine(logDir, endpointConfiguration.EndpointName + ".txt"); - - if (File.Exists(logFile)) - File.Delete(logFile); - - var logLevel = "WARN"; - var logLevelOverride = Environment.GetEnvironmentVariable("tests_loglevel"); - - if (!string.IsNullOrEmpty(logLevelOverride)) - logLevel = logLevelOverride; - - SetLoggingLibrary.Log4Net(null, - Logging.Loggers.Log4NetAdapter.Log4NetAppenderFactory.CreateRollingFileAppender(logLevel, logFile)); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_doing_request_response_between_sites.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_doing_request_response_between_sites.cs deleted file mode 100644 index e868615a6..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_doing_request_response_between_sites.cs +++ /dev/null @@ -1,143 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Gateway -{ - using System; - using Config; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_doing_request_response_between_sites : NServiceBusAcceptanceTest - { - static readonly byte[] PayloadToSend = new byte[1024 * 1024 * 10]; - - [Test] - public void Should_be_able_to_reply_to_the_message_using_databus() - { - Scenario.Define() - .WithEndpoint( - b => b.Given((bus, context) => - bus.SendToSites(new[] { "SiteB" }, new MyRequest { Payload = new DataBusProperty(PayloadToSend) }) - .Register(result => context.GotCallback = true))) - .WithEndpoint() - .Done(c => c.GotResponseBack && c.GotCallback) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.AreEqual(PayloadToSend, c.SiteBReceivedPayload, - "The large payload should be marshalled correctly using the databus"); - Assert.AreEqual(PayloadToSend, c.SiteAReceivedPayloadInResponse, - "The large payload should be marshalled correctly using the databus"); - Assert.AreEqual(@"http,http://localhost:25899/SiteA/NumberOfWorkerThreads=1Default=True", c.OriginatingSiteForRequest); - Assert.AreEqual(@"http,http://localhost:25899/SiteB/NumberOfWorkerThreads=1Default=True", c.OriginatingSiteForResponse); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool GotResponseBack { get; set; } - public bool GotCallback { get; set; } - public byte[] SiteBReceivedPayload { get; set; } - public byte[] SiteAReceivedPayloadInResponse { get; set; } - public string OriginatingSiteForRequest { get; set; } - public string OriginatingSiteForResponse { get; set; } - } - - public class SiteA : EndpointConfigurationBuilder - { - public SiteA() - { - EndpointSetup(c => c.RunGateway() - .UseInMemoryGatewayPersister() - .FileShareDataBus(@".\databus\siteA")) - .WithConfig(c => - { - c.Sites = new SiteCollection - { - new SiteConfig - { - Key = "SiteB", - Address = "http://localhost:25899/SiteB/", - ChannelType = "http" - } - }; - - c.Channels = new ChannelCollection - { - new ChannelConfig - { - Address = "http://localhost:25899/SiteA/", - ChannelType = "http", - Default = true - } - }; - }); - } - - public class MyResponseHandler : IHandleMessages - { - public Context Context { get; set; } - public IBus Bus { get; set; } - - public void Handle(MyResponse response) - { - Context.GotResponseBack = true; - Context.SiteAReceivedPayloadInResponse = response.OriginalPayload.Value; - - // Inspect the headers to find the originating site address - Context.OriginatingSiteForResponse = Bus.CurrentMessageContext.Headers[Headers.OriginatingSite]; - } - } - } - - public class SiteB : EndpointConfigurationBuilder - { - public SiteB() - { - EndpointSetup(c => c.RunGateway().UseInMemoryGatewayPersister() - .FileShareDataBus(@".\databus\siteB")) - .WithConfig(c => - { - c.Channels = new ChannelCollection - { - new ChannelConfig - { - Address = "http://localhost:25899/SiteB/", - ChannelType = "http", - Default = true - } - }; - }); - - } - - public class MyRequestHandler : IHandleMessages - { - public IBus Bus { get; set; } - public Context Context { get; set; } - - public void Handle(MyRequest request) - { - Context.SiteBReceivedPayload = request.Payload.Value; - Bus.Reply(new MyResponse {OriginalPayload = request.Payload}); - - // Inspect the headers to find the originating site address - Context.OriginatingSiteForRequest = Bus.CurrentMessageContext.Headers[Headers.OriginatingSite]; - } - } - } - - [Serializable] - public class MyRequest : ICommand - { - public DataBusProperty Payload { get; set; } - } - - [Serializable] - public class MyResponse : IMessage - { - public DataBusProperty OriginalPayload { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_sending_a_message_via_the_gateway.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_sending_a_message_via_the_gateway.cs deleted file mode 100644 index 16126fca9..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_sending_a_message_via_the_gateway.cs +++ /dev/null @@ -1,118 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Gateway -{ - using System; - using System.IO; - using System.Net; - using System.Web; - using Config; - using EndpointTemplates; - using AcceptanceTesting; - using NServiceBus.Gateway.Utils; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_a_message_via_the_gateway : NServiceBusAcceptanceTest - { - [Test] - public void Should_process_message() - { - Scenario.Define() - .WithEndpoint(b => b.When(bus => - { - var webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:25898/Headquarters/"); - webRequest.Method = "POST"; - webRequest.ContentType = "text/xml; charset=utf-8"; - webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"; - - webRequest.Headers.Add("Content-Encoding", "utf-8"); - webRequest.Headers.Add("NServiceBus.CallType", "Submit"); - webRequest.Headers.Add("NServiceBus.AutoAck", "true"); - webRequest.Headers.Add("MySpecialHeader", "MySpecialValue"); - webRequest.Headers.Add("NServiceBus.Id", Guid.NewGuid().ToString("N")); - - const string message = ""; - - using (var messagePayload = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(message))) - { - webRequest.Headers.Add(HttpRequestHeader.ContentMd5, HttpUtility.UrlEncode(Hasher.Hash(messagePayload))); - webRequest.ContentLength = messagePayload.Length; - - using (var requestStream = webRequest.GetRequestStream()) - { - messagePayload.CopyTo(requestStream); - } - } - - while (true) - { - try - { - using (var myWebResponse = (HttpWebResponse) webRequest.GetResponse()) - { - if (myWebResponse.StatusCode == HttpStatusCode.OK) - { - break; - } - } - } - catch (WebException) - { - } - } - })) - .Done(c => c.GotMessage) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.IsTrue(c.GotMessage); - Assert.AreEqual("MySpecialValue", c.MySpecialHeader); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool GotMessage { get; set; } - - public string MySpecialHeader { get; set; } - } - - public class Headquarters : EndpointConfigurationBuilder - { - public Headquarters() - { - EndpointSetup(c => c.RunGateway().UseInMemoryGatewayPersister()) - .IncludeType() - .WithConfig(c => - { - c.Channels = new ChannelCollection - { - new ChannelConfig - { - Address = "http://localhost:25898/Headquarters/", - ChannelType = "http" - } - }; - }); - } - - public class MyResponseHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyRequest response) - { - Context.GotMessage = true; - Context.MySpecialHeader = Bus.GetMessageHeader(response, "MySpecialHeader"); - } - } - } - } - - [Serializable] - public class MyRequest : IMessage - { - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_using_a_custom_correlation_id.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_using_a_custom_correlation_id.cs deleted file mode 100644 index d24576325..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Gateway/When_using_a_custom_correlation_id.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Gateway -{ - using System; - using Config; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_a_message_to_another_site : NServiceBusAcceptanceTest - { - [Test] - public void Should_be_able_to_reply_to_the_message() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendToSites(new[] { "SiteA" }, new MyRequest()))) - .WithEndpoint() - .Done(c => c.GotResponseBack) - .Repeat(r => r.For(Transports.Default) - ) - .Should(c => - { - Assert.IsTrue(c.GotResponseBack); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool GotResponseBack { get; set; } - } - - public class Headquarters : EndpointConfigurationBuilder - { - public Headquarters() - { - EndpointSetup(c => c.RunGateway().UseInMemoryGatewayPersister()) - .WithConfig(c => - { - c.Sites = new SiteCollection - { - new SiteConfig - { - Key = "SiteA", - Address = "http://localhost:25899/SiteA/", - ChannelType = "http" - } - }; - - c.Channels = new ChannelCollection - { - new ChannelConfig - { - Address = "http://localhost:25899/Headquarters/", - ChannelType = "http" - } - }; - - - }); - } - - public class MyResponseHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyResponse response) - { - Context.GotResponseBack = true; - } - } - } - - public class SiteA : EndpointConfigurationBuilder - { - public SiteA() - { - EndpointSetup(c => c.RunGateway().UseInMemoryGatewayPersister()) - .WithConfig(c => - { - c.Channels = new ChannelCollection - { - new ChannelConfig - { - Address = "http://localhost:25899/SiteA/", - ChannelType = "http" - } - }; - }); - } - - public class MyRequestHandler : IHandleMessages - { - public IBus Bus { get; set; } - - public void Handle(MyRequest request) - { - Bus.Reply(new MyResponse()); - } - } - } - - [Serializable] - public class MyRequest : IMessage - { - } - - [Serializable] - public class MyResponse : IMessage - { - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_calling_DoNotContinueDispatchingCurrentMessageToHandlers_from_inmemory.cs b/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_calling_DoNotContinueDispatchingCurrentMessageToHandlers_from_inmemory.cs deleted file mode 100644 index 357a94f06..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_calling_DoNotContinueDispatchingCurrentMessageToHandlers_from_inmemory.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace NServiceBus.AcceptanceTests.InMemory -{ - using System; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - - public class When_calling_DoNotContinueDispatchingCurrentMessageToHandlers_from_inmemory : NServiceBusAcceptanceTest - { - [Test] - public void Subsequent_inmemory_handlers_will_not_be_invoked() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new SomeMessage()))) - .Done(c => c.SecondHandlerInvoked) - .Run(); - - Assert.IsTrue(context.FirstHandlerInvoked); - Assert.IsTrue(context.SecondHandlerInvoked); - Assert.IsTrue(context.InMemoryEventReceivedByHandler1); - Assert.IsFalse(context.InMemoryEventReceivedByHandler2); - } - - public class Context : ScenarioContext - { - public bool FirstHandlerInvoked { get; set; } - public bool SecondHandlerInvoked { get; set; } - - public bool InMemoryEventReceivedByHandler1 { get; set; } - public bool InMemoryEventReceivedByHandler2 { get; set; } - - } - - [Serializable] - public class SomeMessage : IMessage { } - - [Serializable] - public class InMemoryEvent : IEvent - { - } - - public class MyEndpoint : EndpointConfigurationBuilder - { - public MyEndpoint() - { - EndpointSetup(); - } - - class EnsureOrdering : ISpecifyMessageHandlerOrdering - { - public void SpecifyOrder(Order order) - { - order.Specify(First.Then().AndThen().AndThen()); - } - } - - class FirstHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(SomeMessage message) - { - Context.FirstHandlerInvoked = true; - - Bus.InMemory.Raise(m => { }); - - } - } - - class SecondHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(SomeMessage message) - { - Context.SecondHandlerInvoked = true; - } - } - - class MyEventHandler1 : IHandleMessages - { - public Context Context { get; set; } - public IBus Bus { get; set; } - - public void Handle(InMemoryEvent messageThatIsEnlisted) - { - Bus.DoNotContinueDispatchingCurrentMessageToHandlers(); - - Context.InMemoryEventReceivedByHandler1 = true; - } - } - - class MyEventHandler2 : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(InMemoryEvent messageThatIsEnlisted) - { - Context.InMemoryEventReceivedByHandler2 = true; - } - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_raising_an_in_memory_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_raising_an_in_memory_event.cs deleted file mode 100644 index a31ca184e..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/InMemory/When_raising_an_in_memory_event.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace NServiceBus.AcceptanceTests.InMemory -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_raising_an_in_memory_event : NServiceBusAcceptanceTest - { - [Test] - public void Should_be_delivered_to_handlers() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given((bus, c) => bus.SendLocal(m => { }))) - .Done(c => c.WasInMemoryEventReceivedByHandler1 && c.WasInMemoryEventReceivedByHandler2) - .Run(); - - Assert.True(context.WasInMemoryEventReceivedByHandler1, "class MyEventHandler1 did not receive the in-memory event"); - Assert.True(context.WasInMemoryEventReceivedByHandler2, "class MyEventHandler2 did not receive the in-memory event"); - } - - public class Context : ScenarioContext - { - public bool WasInMemoryEventReceivedByHandler1 { get; set; } - public bool WasInMemoryEventReceivedByHandler2 { get; set; } - - } - - public class InMemoryEndpoint : EndpointConfigurationBuilder - { - public InMemoryEndpoint() - { - EndpointSetup(); - } - - public class CommandHandler : IHandleMessages - { - public IBus Bus { get; set; } - public void Handle(SomeCommand messageThatIsEnlisted) - { - Bus.InMemory.Raise(m => { }); - } - } - - public class MyEventHandler1 : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyInMemoryEvent messageThatIsEnlisted) - { - Context.WasInMemoryEventReceivedByHandler1 = true; - } - } - - public class MyEventHandler2 : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyInMemoryEvent messageThatIsEnlisted) - { - Context.WasInMemoryEventReceivedByHandler2 = true; - } - } - } - - - [Serializable] - public class SomeCommand : ICommand - { - } - - [Serializable] - public class MyInMemoryEvent : IEvent - { - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj index 40915a754..782d904a3 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj +++ b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj @@ -32,52 +32,10 @@ true - - ..\packages\Autofac\lib\net40\Autofac.dll - - - ..\packages\Castle.Core\lib\net40-client\Castle.Core.dll - - - ..\packages\Castle.Windsor\lib\net40\Castle.Windsor.dll - - - ..\packages\Common.Logging\lib\1.0\Common.Logging.dll - - - ..\packages\Iesi.Collections\lib\Net35\Iesi.Collections.dll - ..\packages\log4net\lib\2.0\log4net.dll - - ..\packages\CommonServiceLocator\lib\NET35\Microsoft.Practices.ServiceLocation.dll - - - ..\packages\Unity\lib\NET35\Microsoft.Practices.Unity.dll - - - ..\packages\Unity\lib\NET35\Microsoft.Practices.Unity.Configuration.dll - - - ..\packages\Unity.Interception\lib\NET35\Microsoft.Practices.Unity.Interception.dll - - - ..\packages\Unity.Interception\lib\NET35\Microsoft.Practices.Unity.Interception.Configuration.dll - - - ..\packages\NHibernate\lib\Net35\NHibernate.dll - - - ..\packages\Ninject\lib\net40\Ninject.dll - - - ..\packages\Ninject.Extensions.ContextPreservation\lib\net40\Ninject.Extensions.ContextPreservation.dll - - - ..\packages\Ninject.Extensions.NamedScope\lib\net40\Ninject.Extensions.NamedScope.dll - ..\packages\NServiceBus.Interfaces\lib\net40\NServiceBus.dll @@ -87,122 +45,16 @@ ..\packages\NServiceBus\lib\net40\NServiceBus.Core.dll - - ..\packages\NServiceBus.NHibernate\lib\net40\NServiceBus.NHibernate.dll - - - ..\packages\NServiceBus.Autofac\lib\net40\NServiceBus.ObjectBuilder.Autofac.dll - - - ..\packages\NServiceBus.CastleWindsor\lib\net40\NServiceBus.ObjectBuilder.CastleWindsor.dll - - - ..\packages\NServiceBus.Ninject\lib\net40\NServiceBus.ObjectBuilder.Ninject.dll - - - ..\packages\NServiceBus.Spring\lib\net40\NServiceBus.ObjectBuilder.Spring.dll - - - ..\packages\NServiceBus.StructureMap\lib\net40\NServiceBus.ObjectBuilder.StructureMap.dll - - - ..\packages\NServiceBus.Unity\lib\net40\NServiceBus.ObjectBuilder.Unity.dll - ..\packages\NUnit\lib\nunit.framework.dll - - ..\packages\RavenDB.Client\lib\net40\Raven.Abstractions.dll - - - ..\packages\RavenDB.Client\lib\net40\Raven.Client.Lightweight.dll - - - ..\packages\Spring.Core\lib\net40\Spring.Core.dll - - - ..\packages\structuremap\lib\net40\StructureMap.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -213,6 +65,18 @@ NServiceBus.SqlServer + + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBusAcceptanceTest.cs b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBusAcceptanceTest.cs deleted file mode 100644 index 7a6e7957c..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBusAcceptanceTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NServiceBus.AcceptanceTests -{ - using System; - using AcceptanceTesting.Customization; - using NUnit.Framework; - - /// - /// Base class for all the NSB test that sets up our conventions - /// - [TestFixture] - public abstract class NServiceBusAcceptanceTest - { - [SetUp] - public void SetUp() - { - Environment.SetEnvironmentVariable("Transport.UseSpecific", "SqlServer", EnvironmentVariableTarget.Process); - - Conventions.EndpointNamingConvention= t => - { - var baseNs = typeof (NServiceBusAcceptanceTest).Namespace; - var testName = GetType().Name; - return t.FullName.Replace(baseNs + ".", "").Replace(testName + "+", ""); - }; - - Conventions.DefaultRunDescriptor = () => ScenarioDescriptors.Transports.Default; - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/NServiceBusPerformanceTest.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Performance/NServiceBusPerformanceTest.cs deleted file mode 100644 index 160dde110..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/NServiceBusPerformanceTest.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Performance -{ - using System; - using System.Diagnostics; - using System.IO; - using System.Linq; - using AcceptanceTesting; - using AcceptanceTesting.Support; - - public abstract class NServiceBusPerformanceTest : NServiceBusAcceptanceTest - { - protected static int NumberOfTestMessages - { - get - { - int nr; - - if (!int.TryParse(Environment.GetEnvironmentVariable("NServiceBus.MaxMessagesForPerformanceTests"), out nr)) - { - return 3000; - } - - return nr; - } - } - - protected static int MaxConcurrencyLevel - { - get - { - int nr; - - if (!int.TryParse(Environment.GetEnvironmentVariable("NServiceBus.MaxConcurrencyLevel"), out nr)) - { - return 15; - } - - return nr; - } - } - - protected static void DisplayTestResults(RunSummary summary) - { - var caller = - new StackTrace().GetFrames() - .First(f => typeof(NServiceBusPerformanceTest).IsAssignableFrom(f.GetMethod().DeclaringType.BaseType)); - - var testCategory = - caller.GetMethod() - .DeclaringType.Namespace.Replace(typeof(NServiceBusPerformanceTest).Namespace + ".", ""); - var testCase = caller.GetMethod().Name; - - var c = summary.RunDescriptor.ScenarioContext as PerformanceTestContext; - - var messagesPerSecondsProcessed = c.NumberOfTestMessages/ - (c.LastMessageProcessedAt - c.FirstMessageProcessedAt).TotalSeconds; - - Console.Out.WriteLine("Results: {0} messages, {1} msg/s", c.NumberOfTestMessages, - messagesPerSecondsProcessed); - - using (var file = new StreamWriter(".\\PerformanceTestResults.txt", true)) - { - file.WriteLine(string.Join(";", summary.RunDescriptor.Key, testCategory, testCase, - c.NumberOfTestMessages, messagesPerSecondsProcessed)); - } - - Console.Out.WriteLine("##teamcity[buildStatisticValue key='{0}' value='{1:0}']", - summary.RunDescriptor.Key + "." + testCategory + "." + testCase, messagesPerSecondsProcessed); - } - } - - public class PerformanceTestContext : ScenarioContext - { - public DateTime FirstMessageProcessedAt { get; set; } - - public DateTime LastMessageProcessedAt { get; set; } - public int NumberOfTestMessages; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Receive/Receive_performance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Receive/Receive_performance.cs deleted file mode 100644 index feb0096f9..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Receive/Receive_performance.cs +++ /dev/null @@ -1,132 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Performance.Receive -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using AcceptanceTesting; - using AcceptanceTesting.Support; - using Config; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class Receive_performance : NServiceBusPerformanceTest - { - [Test] - public void With_dtc_enabled() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(SendTestMessages) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_dtc_suppressed() - { - - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DisableDistributedTransactions())); - SendTestMessages(b); - }) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_no_transactions() - { - - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Disable()); - SendTestMessages(b); - }) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_ambient_tx_suppressed() - { - - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DoNotWrapHandlersExecutionInATransactionScope())); - SendTestMessages(b); - }) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - - public class Context : PerformanceTestContext - { - - - public bool Complete { get; set; } - } - - public class ReceiveEndpoint : EndpointConfigurationBuilder - { - public ReceiveEndpoint() - { - EndpointSetup() - .WithConfig(c => c.MaximumConcurrencyLevel = MaxConcurrencyLevel); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - static int numberOfMessagesProcessed; - - - public void Handle(MyMessage messageThatIsEnlisted) - { - var current = Interlocked.Increment(ref numberOfMessagesProcessed); - - if (current == 1) - { - Context.FirstMessageProcessedAt = DateTime.UtcNow; - } - - if (current == Context.NumberOfTestMessages) - { - Context.LastMessageProcessedAt = DateTime.UtcNow; - Context.Complete = true; - } - - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - - - - protected static void SendTestMessages(EndpointBehaviorBuilder b) - { - b.Given((bus, context) => Parallel.For(0, context.NumberOfTestMessages, (s, c) => bus.SendLocal(new MyMessage()))); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/RequestResponse/Request_response_performance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Performance/RequestResponse/Request_response_performance.cs deleted file mode 100644 index d3c94d586..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/RequestResponse/Request_response_performance.cs +++ /dev/null @@ -1,155 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Performance.RequestResponse -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using AcceptanceTesting; - using Config; - using EndpointTemplates; - using AcceptanceTesting.Support; - using NUnit.Framework; - using ScenarioDescriptors; - - public class Request_response_performance : NServiceBusPerformanceTest - { - [Test] - public void With_dtc_enabled() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => SendMessages(b)) - .WithEndpoint() - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_dtc_supressed() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DisableDistributedTransactions())); - SendMessages(b); - }) - .WithEndpoint(b => b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DisableDistributedTransactions()))) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_no_transactions() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Disable()); - SendMessages(b); - }) - .WithEndpoint(b => b.CustomConfig(c => Configure.Transactions.Disable())) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test] - public void With_ambient_tx_suppressed() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DoNotWrapHandlersExecutionInATransactionScope())); - SendMessages(b); - }) - .WithEndpoint(b => b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DoNotWrapHandlersExecutionInATransactionScope()))) - .Done(c => c.Complete) - .Repeat(r => r.For(Transports.Default)) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - private static EndpointBehaviorBuilder SendMessages(EndpointBehaviorBuilder b) - { - return b.Given((bus, context) => Parallel.For(0, context.NumberOfTestMessages, (s, c) => bus.Send(new MyMessage()))); - } - - public class Context : PerformanceTestContext - { - public bool Complete { get; set; } - } - - public class ClientEndpoint : EndpointConfigurationBuilder - { - public ClientEndpoint() - { - EndpointSetup() - .WithConfig(c => c.MaximumConcurrencyLevel = MaxConcurrencyLevel) - .AddMapping(typeof(ServerEndpoint)); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - static int numberOfMessagesProcessed; - - - public void Handle(MyResponse messageThatIsEnlisted) - { - var current = Interlocked.Increment(ref numberOfMessagesProcessed); - - if (current == 1) - { - Context.FirstMessageProcessedAt = DateTime.UtcNow; - } - - if (current == Context.NumberOfTestMessages) - { - Context.LastMessageProcessedAt = DateTime.UtcNow; - Context.Complete = true; - } - - } - } - } - - public class ServerEndpoint : EndpointConfigurationBuilder - { - public ServerEndpoint() - { - EndpointSetup() - .WithConfig(c => c.MaximumConcurrencyLevel = MaxConcurrencyLevel); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MyMessage message) - { - Bus.Reply(new MyResponse()); - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - - [Serializable] - public class MyResponse : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Sagas/Saga_performance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Sagas/Saga_performance.cs deleted file mode 100644 index 5bea7b4d3..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Performance/Sagas/Saga_performance.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Performance.Sagas -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using AcceptanceTesting; - using AcceptanceTesting.Support; - using Config; - using EndpointTemplates; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class Saga_performance : NServiceBusPerformanceTest - { - [Test, Ignore("Fails in build server! Not reliable")] - public void With_dtc_enabled() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(SendTestMessages) - .Done(c => c.Complete) - .Repeat(r => r.For()) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - [Test, Ignore("Fails in build server! Not reliable")] - public void With_dtc_supressed() - { - Scenario.Define(() => new Context { NumberOfTestMessages = NumberOfTestMessages }) - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DisableDistributedTransactions())); - SendTestMessages(b); - }) - .Done(c => c.Complete) - .Repeat(r => r.For()) - .Report(DisplayTestResults) - .MaxTestParallelism(1) - .Run(); - } - - public class Context : PerformanceTestContext - { - - public bool Complete { get; set; } - } - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup() - .WithConfig(c => c.MaximumConcurrencyLevel = MaxConcurrencyLevel); - } - - public class MySaga : Saga,IAmStartedByMessages - { - public Context Context { get; set; } - - static int numberOfMessagesProcessed; - - - public void Handle(MyMessage message) - { - Data.SomeId = message.SomeId; - - var current = Interlocked.Increment(ref numberOfMessagesProcessed); - - if (current == 1) - { - Context.FirstMessageProcessedAt = DateTime.UtcNow; - } - - if (current == Context.NumberOfTestMessages) - { - Context.LastMessageProcessedAt = DateTime.UtcNow; - Context.Complete = true; - } - - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m=>m.SomeId) - .ToSaga(s=>s.SomeId); - - } - - - public class MySagaData : IContainSagaData - { - public virtual Guid Id { get; set; } - public virtual string Originator { get; set; } - public virtual string OriginalMessageId { get; set; } - - [Unique] - public virtual Guid SomeId { get; set; } - } - - } - - - } - - [Serializable] - public class MyMessage : ICommand - { - public Guid SomeId { get; set; } - } - - - - protected static void SendTestMessages(EndpointBehaviorBuilder b) - { - b.Given((bus, context) => Parallel.For(0, context.NumberOfTestMessages, (s, c) => bus.SendLocal(new MyMessage - { - SomeId = Guid.NewGuid() - }))); - } - } - - - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Properties/AssemblyInfo.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Properties/AssemblyInfo.cs deleted file mode 100644 index a8d1cb232..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NServiceBus.IntegrationTests.Automated")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NServiceBus.IntegrationTests.Automated")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("eebba921-499c-46ab-ac43-56aaf1af7947")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/PubSubAcceptanceTest.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/PubSubAcceptanceTest.cs deleted file mode 100644 index d14b480ec..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/PubSubAcceptanceTest.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using Features; - using Unicast.Subscriptions; - using Unicast.Subscriptions.MessageDrivenSubscriptions; - - [Serializable] - public class Subscriptions - { - public static Action> OnEndpointSubscribed = actionToPerform => - { - if (Feature.IsEnabled()) - { - Configure.Instance.Builder.Build().ClientSubscribed += - (sender, args) => - { - actionToPerform(args); - }; - } - }; - - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event.cs deleted file mode 100644 index 0f701abe0..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event.cs +++ /dev/null @@ -1,115 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using Features; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_publishing_an_event : NServiceBusAcceptanceTest - { - [Test] - public void Should_be_delivered_to_allsubscribers() - { - Scenario.Define() - .WithEndpoint(b => - b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s => - { - if (s.SubscriberReturnAddress.Queue.Contains("Subscriber1")) - context.Subscriber1Subscribed = true; - - if (s.SubscriberReturnAddress.Queue.Contains("Subscriber2")) - context.Subscriber2Subscribed = true; - })) - .When(c => c.Subscriber1Subscribed && c.Subscriber2Subscribed, bus => bus.Publish(new MyEvent())) - ) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.Subscriber1Subscribed = true; - })) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.Subscriber2Subscribed = true; - })) - .Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent) - .Repeat(r => r.For(Transports.Msmq)) - .Should(c => - { - Assert.True(c.Subscriber1GotTheEvent); - Assert.True(c.Subscriber2GotTheEvent); - }) - - .Run(); - } - - public class Context : ScenarioContext - { - public bool Subscriber1GotTheEvent { get; set; } - - public bool Subscriber2GotTheEvent { get; set; } - - - public bool Subscriber1Subscribed { get; set; } - - public bool Subscriber2Subscribed { get; set; } - } - - public class Publisher : EndpointConfigurationBuilder - { - public Publisher() - { - EndpointSetup(); - } - } - - public class Subscriber1 : EndpointConfigurationBuilder - { - public Subscriber1() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof(Publisher)); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - Context.Subscriber1GotTheEvent = true; - } - } - } - - public class Subscriber2 : EndpointConfigurationBuilder - { - public Subscriber2() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof(Publisher)); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - Context.Subscriber2GotTheEvent = true; - } - } - } - - [Serializable] - public class MyEvent : IEvent - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_using_a_broker_transport_with_centralized_routing.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_using_a_broker_transport_with_centralized_routing.cs deleted file mode 100644 index 192486017..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_using_a_broker_transport_with_centralized_routing.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_publishing_an_event_using_a_broker_transport_with_centralized_routing : NServiceBusAcceptanceTest - { - [Test, Ignore("Not reliable!")] - public void Should_be_delivered_to_allsubscribers_without_the_need_for_config() - { - Scenario.Define() - .WithEndpoint(b => b.When(c => c.EndpointsStarted, (bus, context) => - { - bus.Publish(new MyEvent()); - })) - .WithEndpoint() - .WithEndpoint() - .Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent) - .Repeat(r => r.For()) - .Should(c => - { - Assert.True(c.Subscriber1GotTheEvent); - Assert.True(c.Subscriber2GotTheEvent); - }) - - .Run(); - } - - public class Context : ScenarioContext - { - public bool Subscriber1GotTheEvent { get; set; } - - public bool Subscriber2GotTheEvent { get; set; } - } - - public class CentralizedPublisher : EndpointConfigurationBuilder - { - public CentralizedPublisher() - { - EndpointSetup(); - } - } - - public class CentralizedSubscriber1 : EndpointConfigurationBuilder - { - public CentralizedSubscriber1() - { - EndpointSetup(); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - Context.Subscriber1GotTheEvent = true; - } - } - } - - public class CentralizedSubscriber2 : EndpointConfigurationBuilder - { - public CentralizedSubscriber2() - { - EndpointSetup(); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - Context.Subscriber2GotTheEvent = true; - } - } - } - - [Serializable] - public class MyEvent : IEvent - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_only_local_messagehandlers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_only_local_messagehandlers.cs deleted file mode 100644 index 1f1801745..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_only_local_messagehandlers.cs +++ /dev/null @@ -1,102 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_publishing_an_event_with_only_local_messagehandlers : NServiceBusAcceptanceTest - { - [Test] - public void Should_trigger_the_catch_all_handler_for_message_driven_subscriptions() - { - Scenario.Define() - .WithEndpoint(b => - b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s => - { - context.LocalEndpointSubscribed = true; - })) - .When(c => c.LocalEndpointSubscribed, bus => bus.Publish(new EventHandledByLocalEndpoint())) - ) - .Done(c => c.CatchAllHandlerGotTheMessage) - .Repeat(r => r.For()) - .Should(c => - { - Assert.True(c.CatchAllHandlerGotTheMessage); - }) - - .Run(); - } - - [Test] - public void Should_trigger_the_catch_all_handler_for_publishers_with_centralized_pubsub() - { - Scenario.Define() - .WithEndpoint(b => b.When(c => c.EndpointsStarted, (bus, context) => bus.Publish(new EventHandledByLocalEndpoint()))) - .Done(c => c.CatchAllHandlerGotTheMessage) - .Repeat(r => r.For(Transports.ActiveMQ)) //exclude active since the support for polymorphic routing is not implemented - .Should(c => - { - Assert.True(c.CatchAllHandlerGotTheMessage); - }) - - .Run(); - } - - public class Context : ScenarioContext - { - - public bool CatchAllHandlerGotTheMessage { get; set; } - - public bool LocalEndpointSubscribed { get; set; } - } - - public class MessageDrivenPublisher : EndpointConfigurationBuilder - { - public MessageDrivenPublisher() - { - EndpointSetup() - .AddMapping(typeof(MessageDrivenPublisher)); //an explicit mapping is needed - } - - class CatchAllHandler:IHandleMessages //not enough for auto subscribe to work - { - public Context Context { get; set; } - public void Handle(IEvent message) - { - Context.CatchAllHandlerGotTheMessage = true; - } - } - - class DummyHandler : IHandleMessages //explicit handler for the event is needed - { - public Context Context { get; set; } - public void Handle(EventHandledByLocalEndpoint message) - { - } - } - } - - public class CentralizedStoragePublisher : EndpointConfigurationBuilder - { - public CentralizedStoragePublisher() - { - EndpointSetup(c => Configure.Features.AutoSubscribe(s => s.DoNotRequireExplicitRouting())); - } - - class CatchAllHandler : IHandleMessages - { - public Context Context { get; set; } - public void Handle(IEvent message) - { - Context.CatchAllHandlerGotTheMessage = true; - } - } - } - [Serializable] - public class EventHandledByLocalEndpoint : IEvent - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_the_subscriber_scaled_out.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_the_subscriber_scaled_out.cs deleted file mode 100644 index b0ce7e90b..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_publishing_an_event_with_the_subscriber_scaled_out.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using System.Collections.Generic; - using System.Linq; - using EndpointTemplates; - using AcceptanceTesting; - using Features; - using NUnit.Framework; - using ScenarioDescriptors; - using Unicast.Subscriptions; - using Unicast.Subscriptions.MessageDrivenSubscriptions; - - public class When_publishing_an_event_with_the_subscriber_scaled_out : NServiceBusAcceptanceTest - { - static string Server1 = "Server1"; - static string Server2 = "Server2"; - - [Test]//https://github.com/NServiceBus/NServiceBus/issues/1101 - public void Should_only_publish_one_event() - { - Scenario.Define() - .WithEndpoint(b => - b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s => - { - if (s.SubscriberReturnAddress.Queue != "MyEndpoint") - return; - - context.NumberOfSubcriptionsReceived++; - })) - .When(c => c.NumberOfSubcriptionsReceived >= 2, (bus, c) => - { - c.SubcribersOfTheEvent = Configure.Instance.Builder.Build() - .GetSubscriberAddressesForMessage(new[] { new MessageType(typeof(MyEvent)) }).Select(a => a.ToString()).ToList(); - }) - ) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.NumberOfSubcriptionsReceived++; - })) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.NumberOfSubcriptionsReceived++; - })) - .Done(c => c.SubcribersOfTheEvent != null) - .Repeat(r => r.For(Transports.SqlServer) - .For(SubscriptionStorages.Msmq)) - .Should(c => - { - Assert.AreEqual(1, c.SubcribersOfTheEvent.Count(), "There should only be one logical subscriber"); - }) - .MaxTestParallelism(1)//we force the endpoint names so we can't run this is parallell - .Run(); - } - - public class Context : ScenarioContext - { - public int NumberOfSubcriptionsReceived { get; set; } - - public IEnumerable SubcribersOfTheEvent { get; set; } - } - - public class Publisher : EndpointConfigurationBuilder - { - public Publisher() - { - EndpointSetup(); - } - } - - public class Subscriber1 : EndpointConfigurationBuilder - { - public Subscriber1() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof (Publisher)) - .CustomMachineName(Server1) - .CustomEndpointName("MyEndpoint"); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - } - } - } - - public class Subscriber2 : EndpointConfigurationBuilder - { - public Subscriber2() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof(Publisher)) - .CustomMachineName(Server2) - .CustomEndpointName("MyEndpoint"); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - } - } - } - - [Serializable] - public class MyEvent : IEvent - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_subscribing_to_a_polymorphic_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_subscribing_to_a_polymorphic_event.cs deleted file mode 100644 index 2d9cf6f54..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/PubSub/When_subscribing_to_a_polymorphic_event.cs +++ /dev/null @@ -1,124 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PubSub -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using Features; - using NUnit.Framework; - using Unicast.Subscriptions.MessageDrivenSubscriptions; - - public class When_subscribing_to_a_polymorphic_event : NServiceBusAcceptanceTest - { - [Test] - public void Event_should_be_delivered() - { - var cc = new Context(); - - Scenario.Define(cc) - .WithEndpoint(b => b.Given((bus, context) => EnableNotificationsOnSubscribe(context)) - .When(c => c.Subscriber1Subscribed && c.Subscriber2Subscribed, bus => bus.Publish(new MyEvent()))) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.Subscriber1Subscribed = true; - })) - .WithEndpoint(b => b.Given((bus, context) => - { - bus.Subscribe(); - - if (!Feature.IsEnabled()) - context.Subscriber2Subscribed = true; - })) - .Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent) - .Run(); - - Assert.True(cc.Subscriber1GotTheEvent); - Assert.True(cc.Subscriber2GotTheEvent); - } - - public class Context : ScenarioContext - { - public bool Subscriber1GotTheEvent { get; set; } - - public bool Subscriber2GotTheEvent { get; set; } - - public int NumberOfSubscribers { get; set; } - - public bool Subscriber1Subscribed { get; set; } - - public bool Subscriber2Subscribed { get; set; } - } - - public class Publisher : EndpointConfigurationBuilder - { - public Publisher() - { - EndpointSetup(); - } - } - - public class Subscriber1 : EndpointConfigurationBuilder - { - public Subscriber1() - { - EndpointSetup(c=>Configure.Features.Disable()) - .AddMapping(typeof(Publisher)); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(IMyEvent messageThatIsEnlisted) - { - Context.Subscriber1GotTheEvent = true; - } - } - } - - public class Subscriber2 : EndpointConfigurationBuilder - { - public Subscriber2() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof(Publisher)); - } - - public class MyEventHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyEvent messageThatIsEnlisted) - { - Context.Subscriber2GotTheEvent = true; - } - } - } - static void EnableNotificationsOnSubscribe(Context context) - { - if (Feature.IsEnabled()) - { - Configure.Instance.Builder.Build().ClientSubscribed += - (sender, args) => - { - if (args.SubscriberReturnAddress.Queue.Contains("Subscriber1")) - context.Subscriber1Subscribed = true; - - if (args.SubscriberReturnAddress.Queue.Contains("Subscriber2")) - context.Subscriber2Subscribed = true; - }; - } - } - - [Serializable] - public class MyEvent : IMyEvent - { - } - - public interface IMyEvent : IEvent - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_doing_flr_with_default_settings.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_doing_flr_with_default_settings.cs deleted file mode 100644 index 2748a128a..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_doing_flr_with_default_settings.cs +++ /dev/null @@ -1,126 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using Config; - using Faults; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_doing_flr_with_default_settings : NServiceBusAcceptanceTest - { - [Test] - public void Should_do_5_retries_by_default_with_dtc_on() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .Done(c => c.HandedOverToSlr || c.NumberOfTimesInvoked > 5) - .Repeat(r => r.For()) - .Should(c => Assert.AreEqual(5, c.NumberOfTimesInvoked, "The FLR should by default retry 5 times")) - .Run(); - - } - - [Test] - public void Should_do_5_retries_by_default_with_native_transactions() - { - Scenario.Define() - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Advanced(a => a.DisableDistributedTransactions())); - b.Given(bus => bus.SendLocal(new MessageToBeRetried())); - }) - .Done(c => c.HandedOverToSlr || c.NumberOfTimesInvoked > 5) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.AreEqual(5, c.NumberOfTimesInvoked, "The FLR should by default retry 5 times")) - .Run(); - - } - - [Test] - public void Should_not_do_any_retries_if_transactions_are_off() - { - Scenario.Define() - .WithEndpoint(b => - { - b.CustomConfig(c => Configure.Transactions.Disable()); - b.Given((bus, context) => - { - bus.SendLocal(new MessageToBeRetried()); - bus.SendLocal(new MessageToBeRetried { SecondMessage = true }); - }); - }) - .Done(c => c.SecondMessageReceived || c.NumberOfTimesInvoked > 1) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.AreEqual(1, c.NumberOfTimesInvoked, "No retries should be in use if transactions are off")) - .Run(); - - } - - public class Context : ScenarioContext - { - public int NumberOfTimesInvoked { get; set; } - - public bool HandedOverToSlr { get; set; } - - public bool SecondMessageReceived { get; set; } - } - - public class RetryEndpoint : EndpointConfigurationBuilder - { - public RetryEndpoint() - { - EndpointSetup( - c => c.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance)) - .WithConfig(c => c.MaximumConcurrencyLevel = 1); - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - - } - - public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e) - { - Context.HandedOverToSlr = true; - } - - public void Init(Address address) - { - - } - } - - class MessageToBeRetriedHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MessageToBeRetried message) - { - if (message.SecondMessage) - { - Context.SecondMessageReceived = true; - return; - } - - Context.NumberOfTimesInvoked++; - - throw new Exception("Simulated exception"); - } - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - public bool SecondMessage { get; set; } - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_message_fails_with_retries_set_to_0.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_message_fails_with_retries_set_to_0.cs deleted file mode 100644 index af1a81736..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_message_fails_with_retries_set_to_0.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using System.Collections.Generic; - using Config; - using Faults; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_message_fails_with_retries_set_to_0 : NServiceBusAcceptanceTest - { - [Test] - public void Should_not_retry_the_message() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .Done(c => c.HandedOverToSlr) - .Run(); - - Assert.AreEqual(1, context.NumberOfTimesInvoked,"No FLR should be in use if MaxRetries is set to 0"); - Assert.AreEqual(Environment.MachineName, context.HeadersOfTheFailedMessage[Headers.ProcessingMachine], "The receiver should attach the machine name as a header"); - Assert.True(context.HeadersOfTheFailedMessage[Headers.ProcessingEndpoint].Contains("RetryEndpoint"), "The receiver should attach its endpoint name as a header"); - } - - public class Context : ScenarioContext - { - public int NumberOfTimesInvoked { get; set; } - - public bool HandedOverToSlr { get; set; } - - public Dictionary HeadersOfTheFailedMessage { get; set; } - } - - public class RetryEndpoint : EndpointConfigurationBuilder - { - public RetryEndpoint() - { - EndpointSetup(c => c.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance)) - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class CustomFaultManager: IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - - } - - public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e) - { - Context.HandedOverToSlr = true; - Context.HeadersOfTheFailedMessage = message.Headers; - } - - public void Init(Address address) - { - - } - } - - class MessageToBeRetriedHandler:IHandleMessages - { - public Context Context { get; set; } - public void Handle(MessageToBeRetried message) - { - Context.NumberOfTimesInvoked++; - throw new Exception("Simulated exception"); - } - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_messages_fails_flr.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_messages_fails_flr.cs deleted file mode 100644 index cad977568..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_messages_fails_flr.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using Config; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_messages_fails_flr : NServiceBusAcceptanceTest - { - static TimeSpan SlrDelay = TimeSpan.FromSeconds(5); - - [Test] - public void Should_be_moved_to_slr() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .Done(c => c.NumberOfTimesInvoked >= 2) - .Repeat(r => r.For(Transports.Default)) - .Should(context => - { - Assert.GreaterOrEqual(1,context.NumberOfSlrRetriesPerformed, "The SLR should only do one retry"); - Assert.GreaterOrEqual(context.TimeOfSecondAttempt - context.TimeOfFirstAttempt,SlrDelay , "The SLR should delay the retry"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public int NumberOfTimesInvoked { get; set; } - - public DateTime TimeOfFirstAttempt { get; set; } - public DateTime TimeOfSecondAttempt { get; set; } - - public int NumberOfSlrRetriesPerformed { get; set; } - } - - public class SLREndpoint : EndpointConfigurationBuilder - { - public SLREndpoint() - { - EndpointSetup() - .WithConfig(c => - { - c.MaxRetries = 0; //to skip the FLR - }) - .WithConfig(c => - { - c.NumberOfRetries = 1; - c.TimeIncrease = SlrDelay; - }); - } - - - class MessageToBeRetriedHandler:IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(MessageToBeRetried message) - { - Context.NumberOfTimesInvoked++; - - if (Context.NumberOfTimesInvoked == 1) - Context.TimeOfFirstAttempt = DateTime.UtcNow; - - if (Context.NumberOfTimesInvoked == 2) - { - Context.TimeOfSecondAttempt = DateTime.UtcNow; - } - - Context.NumberOfSlrRetriesPerformed = int.Parse(Bus.CurrentMessageContext.Headers[Headers.Retries]); - - throw new Exception("Simulated exception"); - } - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_sending_a_message_off_to_slr.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_sending_a_message_off_to_slr.cs deleted file mode 100644 index dd8cb31e0..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Retries/When_sending_a_message_off_to_slr.cs +++ /dev/null @@ -1,145 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using System.Linq; - using Config; - using Faults; - using EndpointTemplates; - using AcceptanceTesting; - using MessageMutator; - using NUnit.Framework; - -#pragma warning disable 612, 618 - - public class When_sending_a_message_off_to_slr : NServiceBusAcceptanceTest - { - [Test] - public void Should_preserve_the_original_body_for_regular_exceptions() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .Done(c => c.SlrChecksum != default(byte)) - .Run(); - - Assert.AreEqual(context.OriginalBodyChecksum, context.SlrChecksum, "The body of the message sent to slr should be the same as the original message coming off the queue"); - - } - [Test] - public void Should_preserve_the_original_body_for_serialization_exceptions() - { - var context = new Context - { - SimulateSerializationException = true - }; - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .Done(c => c.SlrChecksum != default(byte)) - .Run(); - - Assert.AreEqual(context.OriginalBodyChecksum, context.SlrChecksum, "The body of the message sent to slr should be the same as the original message coming off the queue"); - - } - - public class Context : ScenarioContext - { - public byte OriginalBodyChecksum { get; set; } - - public byte SlrChecksum { get; set; } - - public bool SimulateSerializationException { get; set; } - } - - public class RetryEndpoint : EndpointConfigurationBuilder - { - public RetryEndpoint() - { - EndpointSetup(c => c.Configurer.ConfigureComponent(DependencyLifecycle.SingleInstance)) - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class BodyMutator : IMutateTransportMessages, NServiceBus.INeedInitialization - { - public Context Context { get; set; } - - public void MutateIncoming(TransportMessage transportMessage) - { - - var originalBody = transportMessage.Body; - - Context.OriginalBodyChecksum = Checksum(originalBody); - - var decryptedBody = new byte[originalBody.Length]; - - Buffer.BlockCopy(originalBody,0,decryptedBody,0,originalBody.Length); - - //decrypt - decryptedBody[0]++; - - if (Context.SimulateSerializationException) - decryptedBody[1]++; - - transportMessage.Body = decryptedBody; - } - - - public void MutateOutgoing(object[] messages, TransportMessage transportMessage) - { - transportMessage.Body[0]--; - } - - public void Init() - { - Configure.Component(DependencyLifecycle.InstancePerCall); - } - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - Context.SlrChecksum = RetryEndpoint.Checksum(message.Body); - } - - public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e) - { - Context.SlrChecksum = RetryEndpoint.Checksum(message.Body); - } - - public void Init(Address address) - { - - } - } - - class MessageToBeRetriedHandler : IHandleMessages - { - public void Handle(MessageToBeRetried message) - { - throw new Exception("Simulated exception"); - } - } - - public static byte Checksum(byte[] data) - { - var longSum = data.Sum(x => (long)x); - return unchecked((byte)longSum); - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - } - } - -#pragma warning restore 612, 618 - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_is_started_by_an_event_published_by_another_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_is_started_by_an_event_published_by_another_saga.cs deleted file mode 100644 index 8a602e61f..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_is_started_by_an_event_published_by_another_saga.cs +++ /dev/null @@ -1,139 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using Features; - using NUnit.Framework; - using PubSub; - using Saga; - using ScenarioDescriptors; - - //Repro for #1323 - public class When_a_saga_is_started_by_an_event_published_by_another_saga : NServiceBusAcceptanceTest - { - [Test] - public void Should_start_the_saga_and_request_a_timeout() - { - Scenario.Define() - .WithEndpoint(b => - b.Given( - (bus, context) => - Subscriptions.OnEndpointSubscribed(s => - { - if (s.SubscriberReturnAddress.Queue.Contains("SagaThatIsStartedByTheEvent")) - { - context.IsEventSubscriptionReceived = true; - } - })) - .When(c => c.IsEventSubscriptionReceived, - bus => - bus.SendLocal(new StartSaga {DataId = Guid.NewGuid()})) - ) - .WithEndpoint( - b => b.Given((bus, context) => bus.Subscribe())) - - .Done(c => c.DidSaga1Complete && c.DidSaga2Complete) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.DidSaga1Complete && c.DidSaga2Complete)) - .Run(); - } - - public class Context : ScenarioContext - { - public bool DidSaga1Complete { get; set; } - public bool DidSaga2Complete { get; set; } - public bool IsEventSubscriptionReceived { get; set; } - } - - public class SagaThatPublishesAnEvent : EndpointConfigurationBuilder - { - public SagaThatPublishesAnEvent() - { - EndpointSetup(c => Configure.Features.Disable()); - } - - public class Saga1 : Saga, IAmStartedByMessages, IHandleTimeouts - { - public Context Context { get; set; } - - public void Handle(StartSaga message) - { - Data.DataId = message.DataId; - - //Publish the event, which will start the second saga - Bus.Publish(m => { m.DataId = message.DataId; }); - - //Request a timeout - RequestTimeout(TimeSpan.FromSeconds(5)); - } - - public void Timeout(Timeout1 state) - { - MarkAsComplete(); - Context.DidSaga1Complete = true; - } - - public class Saga1Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - - public class Timeout1 - { - } - } - } - - public class SagaThatIsStartedByTheEvent : EndpointConfigurationBuilder - { - public SagaThatIsStartedByTheEvent() - { - EndpointSetup(c => Configure.Features.Disable()) - .AddMapping(typeof(SagaThatPublishesAnEvent)); - - } - - public class Saga2 : Saga, IAmStartedByMessages, IHandleTimeouts - { - public Context Context { get; set; } - - public void Handle(SomethingHappenedEvent message) - { - Data.DataId = message.DataId; - - //Request a timeout - RequestTimeout(TimeSpan.FromSeconds(5)); - } - - public void Timeout(Saga2Timeout state) - { - MarkAsComplete(); - Context.DidSaga2Complete = true; - } - - public class Saga2Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - - public class Saga2Timeout - { - } - } - } - - [Serializable] - public class StartSaga : ICommand - { - public Guid DataId { get; set; } - } - - public interface SomethingHappenedEvent : IEvent - { - Guid DataId { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_message_goes_through_the_slr.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_message_goes_through_the_slr.cs deleted file mode 100644 index 3246e79c5..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_a_saga_message_goes_through_the_slr.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - //repro for issue: https://github.com/NServiceBus/NServiceBus/issues/1020 - public class When_a_saga_message_goes_through_the_slr : NServiceBusAcceptanceTest - { - [Test] - public void Should_invoke_the_correct_handle_methods_on_the_saga() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSagaMessage { SomeId = Guid.NewGuid() }))) - .Done(c => c.SecondMessageProcessed) - .Repeat(r => r.For(Transports.Default)) - .Run(); - } - - public class Context : ScenarioContext - { - public bool SecondMessageProcessed { get; set; } - - - public int NumberOfTimesInvoked { get; set; } - } - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup(); - } - - public class TestSaga : Saga, IAmStartedByMessages,IHandleMessages - { - public Context Context { get; set; } - public void Handle(StartSagaMessage message) - { - Data.SomeId = message.SomeId; - - Bus.SendLocal(new SecondSagaMessage - { - SomeId = Data.SomeId - }); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m=>m.SomeId) - .ToSaga(s=>s.SomeId); - ConfigureMapping(m => m.SomeId) - .ToSaga(s => s.SomeId); - } - - public void Handle(SecondSagaMessage message) - { - Context.NumberOfTimesInvoked++; - var shouldFail = Context.NumberOfTimesInvoked < 2; //1 FLR and 1 SLR - - if(shouldFail) - throw new Exception("Simulated exception"); - - Context.SecondMessageProcessed = true; - } - } - - public class TestSagaData : IContainSagaData - { - public Guid Id { get; set; } - public string Originator { get; set; } - public string OriginalMessageId { get; set; } - public Guid SomeId { get; set; } - } - } - - [Serializable] - public class StartSagaMessage : ICommand - { - public Guid SomeId { get; set; } - } - public class SecondSagaMessage : ICommand - { - public Guid SomeId { get; set; } - } - - public class SomeTimeout - { - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs deleted file mode 100644 index 7a3fef8d5..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_an_endpoint_replies_to_a_saga.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - // Repro for issue https://github.com/NServiceBus/NServiceBus/issues/1277 to test the fix - // making sure that the saga correlation still works. - public class When_an_endpoint_replies_to_a_saga : NServiceBusAcceptanceTest - { - [Test] - public void Should_correlate_all_saga_messages_properly() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSaga { DataId = Guid.NewGuid() }))) - .WithEndpoint() - .Done(c => c.DidSagaReplyMessageGetCorrelated) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.True(c.DidSagaReplyMessageGetCorrelated); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool DidSagaReplyMessageGetCorrelated { get; set; } - } - - public class EndpointThatHandlesAMessageFromSagaAndReplies : EndpointConfigurationBuilder - { - public EndpointThatHandlesAMessageFromSagaAndReplies() - { - EndpointSetup(); - } - - class DoSomethingHandler : IHandleMessages - { - public IBus Bus { get; set; } - - public void Handle(DoSomething message) - { - Console.WriteLine("Received DoSomething command for DataId:{0} ... and responding with a reply", message.DataId); - Bus.Reply(new DoSomethingResponse { DataId = message.DataId }); - } - } - } - - public class EndpointThatHostsASaga : EndpointConfigurationBuilder - { - public EndpointThatHostsASaga() - { - EndpointSetup() - .AddMapping(typeof (EndpointThatHandlesAMessageFromSagaAndReplies)); - - } - - public class Saga2 : Saga, IAmStartedByMessages, IHandleMessages - { - public Context Context { get; set; } - - public void Handle(StartSaga message) - { - var dataId = Guid.NewGuid(); - Console.Out.WriteLine("Saga2 sending DoSomething for DataId: {0}", dataId); - Data.DataId = dataId; - Bus.Send(new DoSomething { DataId = dataId }); - } - - public void Handle(DoSomethingResponse message) - { - Context.DidSagaReplyMessageGetCorrelated = message.DataId == Data.DataId; - Console.Out.WriteLine("Saga received DoSomethingResponse for DataId: {0} and MarkAsComplete", message.DataId); - MarkAsComplete(); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - - public class MySaga2Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - } - } - - - [Serializable] - public class StartSaga : ICommand - { - public Guid DataId { get; set; } - } - - public class DoSomething : ICommand - { - public Guid DataId { get; set; } - } - - public class DoSomethingResponse : IMessage - { - public Guid DataId { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs deleted file mode 100644 index 8dea767a4..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_doing_request_response_between_sagas.cs +++ /dev/null @@ -1,108 +0,0 @@ - -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_doing_request_response_between_sagas : NServiceBusAcceptanceTest - { - [Test] - public void Should_autocorrelate_the_response_back_to_the_requesting_saga() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new InitiateRequestingSaga { DataId = Guid.NewGuid() }))) - .Done(c => c.DidRequestingSagaGetTheResponse) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.DidRequestingSagaGetTheResponse)) - .Run(TimeSpan.FromSeconds(20)); - } - - public class Context : ScenarioContext - { - public bool DidRequestingSagaGetTheResponse { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - - public Endpoint() - { - EndpointSetup(); - } - - public class RequestingSaga : Saga, - IAmStartedByMessages, - IHandleMessages - { - public Context Context { get; set; } - - public void Handle(InitiateRequestingSaga message) - { - Data.DataId = message.DataId; - Bus.SendLocal(new RequestToRespondingSaga()); - } - - public void Handle(ResponseFromOtherSaga message) - { - Context.DidRequestingSagaGetTheResponse = true; - MarkAsComplete(); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - public class RequestingSagaData : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - } - - - - - public class RespondingSaga : Saga, - IAmStartedByMessages - { - public Context Context { get; set; } - - public void Handle(RequestToRespondingSaga message) - { - Bus.Reply(new ResponseFromOtherSaga()); - } - - public override void ConfigureHowToFindSaga() - { - } - - public class RespondingSagaData : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - } - } - - [Serializable] - public class InitiateRequestingSaga : ICommand - { - public Guid DataId { get; set; } - } - - - [Serializable] - public class RequestToRespondingSaga : ICommand - { - } - - [Serializable] - public class ResponseFromOtherSaga : IMessage - { - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_is_mapped_to_an_existing_saga_instance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_is_mapped_to_an_existing_saga_instance.cs deleted file mode 100644 index 5e2ee84df..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_is_mapped_to_an_existing_saga_instance.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using SagaPersisters.NHibernate.AutoPersistence.Attributes; - using ScenarioDescriptors; - - public class When_receiving_a_message_that_is_mapped_to_an_existing_saga_instance : NServiceBusAcceptanceTest - { - static Guid IdThatSagaIsCorrelatedOn = Guid.NewGuid(); - - [Test] - public void Should_hydrate_and_invoke_the_existing_instance() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => - { - bus.SendLocal(new StartSagaMessage { SomeId = IdThatSagaIsCorrelatedOn }); - bus.SendLocal(new StartSagaMessage { SomeId = IdThatSagaIsCorrelatedOn, SecondMessage = true }); - })) - .Done(c => c.SecondMessageReceived) - .Repeat(r => r.For()) - .Should(c => - { - Assert.AreEqual(c.FirstSagaInstance, c.SecondSagaInstance, "The same saga instance should be invoked invoked for both messages"); - }) - - .Run(); - } - - public class Context : ScenarioContext - { - public bool SecondMessageReceived { get; set; } - - public Guid FirstSagaInstance { get; set; } - public Guid SecondSagaInstance { get; set; } - } - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup(c=>Configure.Transactions.Advanced(a => - { - a.DoNotWrapHandlersExecutionInATransactionScope(); - })); - } - - public class TestSaga : Saga, IAmStartedByMessages - { - public Context Context { get; set; } - public void Handle(StartSagaMessage message) - { - Data.SomeId = message.SomeId; - - if (message.SecondMessage) - { - Context.SecondSagaInstance = Data.Id; - Context.SecondMessageReceived = true; - } - else - { - Context.FirstSagaInstance = Data.Id; - } - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m=>m.SomeId) - .ToSaga(s=>s.SomeId); - } - } - - [TableName("SagaEndpointTestSagaData")] - public class TestSagaData : IContainSagaData - { - public virtual Guid Id { get; set; } - public virtual string Originator { get; set; } - public virtual string OriginalMessageId { get; set; } - - [Unique] - public virtual Guid SomeId { get; set; } - } - } - - [Serializable] - public class StartSagaMessage : ICommand - { - public Guid SomeId { get; set; } - - public bool SecondMessage { get; set; } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_complete_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_complete_saga.cs deleted file mode 100644 index 88fa76a1f..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_complete_saga.cs +++ /dev/null @@ -1,144 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_receiving_a_message_that_completes_the_saga : NServiceBusAcceptanceTest - { - [Test] - public void Should_hydrate_and_complete_the_existing_instance() - { - Scenario.Define(() => new Context { Id = Guid.NewGuid() }) - .WithEndpoint(b => - { - b.Given((bus, context) => bus.SendLocal(new StartSagaMessage {SomeId = context.Id})); - b.When(context => context.StartSagaMessageReceived, (bus, context) => bus.SendLocal(new CompleteSagaMessage { SomeId = context.Id })); - }) - .Done(c => c.SagaCompleted) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.IsNull(c.UnhandledException); - }) - - .Run(); - } - - [Test] - public void Should_ignore_messages_afterwards() - { - Scenario.Define(() => new Context {Id = Guid.NewGuid()}) - .WithEndpoint(b => - { - b.Given((bus, context) => bus.SendLocal(new StartSagaMessage { SomeId = context.Id })); - b.When(context => context.StartSagaMessageReceived, (bus, context) => bus.SendLocal(new CompleteSagaMessage { SomeId = context.Id })); - b.When(context => context.SagaCompleted, (bus, context) => bus.SendLocal(new AnotherMessage { SomeId = context.Id })); - }) - .Done(c => c.AnotherMessageReceived) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.IsNull(c.UnhandledException); - Assert.False(c.SagaReceivedAnotherMessage,"AnotherMessage should not be delivered to the saga after completion"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public Exception UnhandledException { get; set; } - public Guid Id { get; set; } - - public bool StartSagaMessageReceived { get; set; } - - public bool SagaCompleted { get; set; } - - public bool AnotherMessageReceived { get; set; } - public bool SagaReceivedAnotherMessage { get; set; } - } - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup( - c => c.RavenSagaPersister().UnicastBus().LoadMessageHandlers>()); - } - - - - public class TestSaga : Saga, IAmStartedByMessages, IHandleMessages, IHandleMessages - { - public Context Context { get; set; } - - public void Handle(StartSagaMessage message) - { - Data.SomeId = message.SomeId; - - Context.StartSagaMessageReceived = true; - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m=>m.SomeId) - .ToSaga(s=>s.SomeId); - ConfigureMapping(m => m.SomeId) - .ToSaga(s => s.SomeId); - ConfigureMapping(m => m.SomeId) - .ToSaga(s => s.SomeId); - } - - public void Handle(CompleteSagaMessage message) - { - MarkAsComplete(); - Context.SagaCompleted = true; - } - - public void Handle(AnotherMessage message) - { - Context.SagaReceivedAnotherMessage = true; - } - } - - public class TestSagaData : IContainSagaData - { - public Guid Id { get; set; } - public string Originator { get; set; } - public string OriginalMessageId { get; set; } - [Unique] - public Guid SomeId { get; set; } - } - } - - public class CompletionHandler : IHandleMessages - { - public Context Context { get; set; } - public void Handle(AnotherMessage message) - { - Context.AnotherMessageReceived = true; - } - } - - [Serializable] - public class StartSagaMessage : ICommand - { - public Guid SomeId { get; set; } - } - - [Serializable] - public class CompleteSagaMessage : ICommand - { - public Guid SomeId { get; set; } - } - - [Serializable] - public class AnotherMessage : ICommand - { - public Guid SomeId { get; set; } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_start_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_start_a_saga.cs deleted file mode 100644 index fb43ab762..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_receiving_a_message_that_should_start_a_saga.cs +++ /dev/null @@ -1,101 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_receiving_a_message_that_should_start_a_saga : NServiceBusAcceptanceTest - { - [Test] - public void Should_start_the_saga_and_call_all_messagehandlers_for_the_given_message() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSagaMessage()))) - .Done(context => context.InterceptingHandlerCalled && context.SagaStarted) - .Repeat(r => r.For()) - .Should(c => - { - Assert.True(c.InterceptingHandlerCalled, "The message handler should be called"); - Assert.True(c.SagaStarted, "The saga should have been started"); - }) - .Run(); - } - - - [Test] - public void Should_not_start_saga_if_a_interception_handler_has_been_invoked() - { - Scenario.Define(() => new SagaEndpointContext{InterceptSaga = true}) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSagaMessage()))) - .Done(context => context.InterceptingHandlerCalled) - .Repeat(r => r.For()) - .Should(c => - { - Assert.True(c.InterceptingHandlerCalled, "The intercepting handler should be called"); - Assert.False(c.SagaStarted, "The saga should not have been started since the intercepting handler stops the pipeline"); - }) - .Run(); - } - - - public class SagaEndpointContext : ScenarioContext - { - public bool InterceptingHandlerCalled { get; set; } - - public bool SagaStarted { get; set; } - - public bool InterceptSaga { get; set; } - } - - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup(c =>c.UnicastBus().LoadMessageHandlers>()); - } - - public class TestSaga : Saga, IAmStartedByMessages - { - public SagaEndpointContext Context { get; set; } - public void Handle(StartSagaMessage message) - { - Context.SagaStarted = true; - } - } - - public class TestSagaData : IContainSagaData - { - public Guid Id { get; set; } - public string Originator { get; set; } - public string OriginalMessageId { get; set; } - } - - public class InterceptingHandler : IHandleMessages - { - public SagaEndpointContext Context { get; set; } - - public IBus Bus { get; set; } - - public void Handle(StartSagaMessage message) - { - Context.InterceptingHandlerCalled = true; - - if(Context.InterceptSaga) - Bus.DoNotContinueDispatchingCurrentMessageToHandlers(); - } - } - } - - [Serializable] - public class StartSagaMessage : ICommand - { - } - - - } - -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs deleted file mode 100644 index ae27b2646..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_handle.cs +++ /dev/null @@ -1,105 +0,0 @@ - -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_sending_from_a_saga_handle : NServiceBusAcceptanceTest - { - [Test] - public void Should_match_different_saga() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSaga1 { DataId = Guid.NewGuid() }))) - .Done(c => c.DidSaga2ReceiveMessage) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.DidSaga2ReceiveMessage)) - .Run(TimeSpan.FromSeconds(20)); - } - - public class Context : ScenarioContext - { - public bool DidSaga2ReceiveMessage { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - - public Endpoint() - { - EndpointSetup(); - } - - public class Saga1 : Saga, IAmStartedByMessages, IHandleMessages - { - public Context Context { get; set; } - - public void Handle(StartSaga1 message) - { - var dataId = Guid.NewGuid(); - Data.DataId = dataId; - Bus.SendLocal(new MessageSaga1WillHandle - { - DataId = dataId - }); - } - - public void Handle(MessageSaga1WillHandle message) - { - Bus.SendLocal(new StartSaga2()); - MarkAsComplete(); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - - } - - public class Saga1Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - - - public class Saga2 : Saga, IAmStartedByMessages - { - public Context Context { get; set; } - - public void Handle(StartSaga2 message) - { - Context.DidSaga2ReceiveMessage = true; - } - - } - - public class Saga2Data : ContainSagaData - { - } - } - - - [Serializable] - public class StartSaga1 : ICommand - { - public Guid DataId { get; set; } - } - - - [Serializable] - public class StartSaga2 : ICommand - { - } - public class MessageSaga1WillHandle : IMessage - { - public Guid DataId { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs deleted file mode 100644 index e701e76df..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_sending_from_a_saga_timeout.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_sending_from_a_saga_timeout : NServiceBusAcceptanceTest - { - [Test] - public void Should_match_different_saga() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSaga1()))) - .Done(c => c.DidSaga2ReceiveMessage) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.DidSaga2ReceiveMessage)) - .Run(TimeSpan.FromSeconds(20)); - } - - public class Context : ScenarioContext - { - public bool DidSaga2ReceiveMessage { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - - public Endpoint() - { - EndpointSetup(); - } - - public class Saga1 : Saga, IAmStartedByMessages, IHandleTimeouts - { - public Context Context { get; set; } - - public void Handle(StartSaga1 message) - { - RequestTimeout(TimeSpan.FromSeconds(1), new Saga1Timeout()); - } - - public void Timeout(Saga1Timeout state) - { - Bus.SendLocal(new StartSaga2()); - MarkAsComplete(); - } - } - - public class Saga1Data : ContainSagaData - { - } - public class Saga2 : Saga, IAmStartedByMessages - { - public Context Context { get; set; } - - public void Handle(StartSaga2 message) - { - Context.DidSaga2ReceiveMessage = true; - } - - } - - public class Saga2Data : ContainSagaData - { - } - } - - - [Serializable] - public class StartSaga1 : ICommand - { - } - - [Serializable] - public class StartSaga2 : ICommand - { - } - - public class Saga1Timeout : IMessage - { - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs deleted file mode 100644 index 2e8b28a70..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_two_sagas_subscribe_to_the_same_event.cs +++ /dev/null @@ -1,155 +0,0 @@ - -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - // Repro for issue https://github.com/NServiceBus/NServiceBus/issues/1277 - public class When_two_sagas_subscribe_to_the_same_event : NServiceBusAcceptanceTest - { - [Test] - public void Should_invoke_all_handlers_on_all_sagas() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new StartSaga2 { DataId = Guid.NewGuid() }))) - .WithEndpoint() - .Done(c => c.DidSaga1EventHandlerGetInvoked && c.DidSaga2EventHandlerGetInvoked) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.True(c.DidSaga1EventHandlerGetInvoked && c.DidSaga2EventHandlerGetInvoked); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool DidSaga1EventHandlerGetInvoked { get; set; } - public bool DidSaga2EventHandlerGetInvoked { get; set; } - } - - public class EndpointThatHandlesAMessageAndPublishesEvent : EndpointConfigurationBuilder - { - public EndpointThatHandlesAMessageAndPublishesEvent() - { - EndpointSetup(); - } - - class OpenGroupCommandHandler : IHandleMessages - { - public IBus Bus { get; set; } - - public void Handle(OpenGroupCommand message) - { - Console.WriteLine("Received OpenGroupCommand for DataId:{0} ... and publishing GroupPendingEvent", message.DataId); - Bus.Publish(new GroupPendingEvent { DataId = message.DataId }); - } - } - } - - public class EndpointThatHostsTwoSagas : EndpointConfigurationBuilder - { - public EndpointThatHostsTwoSagas() - { - EndpointSetup() - .AddMapping(typeof(EndpointThatHandlesAMessageAndPublishesEvent)) - .AddMapping(typeof(EndpointThatHandlesAMessageAndPublishesEvent)); - } - - public class Saga1 : Saga, IAmStartedByMessages, IHandleMessages - { - public Context Context { get; set; } - - public void Handle(GroupPendingEvent message) - { - Data.DataId = message.DataId; - Console.Out.WriteLine("Saga1 received GroupPendingEvent for DataId: {0}", message.DataId); - Context.DidSaga1EventHandlerGetInvoked = true; - Bus.SendLocal(new CompleteSaga1Start { DataId = message.DataId }); - } - - public void Handle(CompleteSaga1Now message) - { - Console.Out.WriteLine("Saga1 received CompleteSaga1Now for DataId:{0} and MarkAsComplete", message.DataId); - - MarkAsComplete(); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - - public class MySaga1Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - } - - public class Saga2 : Saga, IAmStartedByMessages, IHandleMessages - { - public Context Context { get; set; } - - public void Handle(StartSaga2 message) - { - var dataId = Guid.NewGuid(); - Console.Out.WriteLine("Saga2 sending OpenGroupCommand for DataId: {0}", dataId); - Data.DataId = dataId; - Bus.Send(new OpenGroupCommand { DataId = dataId }); - } - - public void Handle(GroupPendingEvent message) - { - Context.DidSaga2EventHandlerGetInvoked = true; - Console.Out.WriteLine("Saga2 received GroupPendingEvent for DataId: {0} and MarkAsComplete", message.DataId); - MarkAsComplete(); - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - - public class MySaga2Data : ContainSagaData - { - [Unique] - public Guid DataId { get; set; } - } - } - } - - [Serializable] - public class GroupPendingEvent : IEvent - { - public Guid DataId { get; set; } - } - - public class OpenGroupCommand : ICommand - { - public Guid DataId { get; set; } - } - - [Serializable] - public class StartSaga2 : ICommand - { - public Guid DataId { get; set; } - } - - public class CompleteSaga1Start : ICommand - { - public Guid DataId { get; set; } - } - - public class CompleteSaga1Now : ICommand - { - public Guid DataId { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs deleted file mode 100644 index 760d092ac..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_a_received_message_for_timeout.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - public class When_using_a_received_message_for_timeout : NServiceBusAcceptanceTest - { - [Test, Ignore("Not working!")] - public void Timeout_should_be_received_after_expiration() - { - Scenario.Define(() => new Context {Id = Guid.NewGuid()}) - .WithEndpoint(b => - { - b.Given((bus, context) => bus.SendLocal(new StartSagaMessage {SomeId = context.Id})); - - b.When(context => context.StartSagaMessageReceived, - (bus, context) => - { - bus.EnsureSubscriptionMessagesHaveArrived(); - bus.Publish(new SomeEvent {SomeId = context.Id}); - }); - }) - .Done(c => c.TimeoutReceived) - .Repeat(r => r.For(Transports.Default)) - .Run(); - } - - public class Context : ScenarioContext - { - public Guid Id { get; set; } - - public bool StartSagaMessageReceived { get; set; } - - public bool SomeEventReceived { get; set; } - - public bool TimeoutReceived { get; set; } - } - - public class SagaEndpoint : EndpointConfigurationBuilder - { - public SagaEndpoint() - { - EndpointSetup(c => c.RavenSagaPersister() - .DefineHowManySubscriptionMessagesToWaitFor(1) - .UnicastBus()) - .AddMapping(typeof (SagaEndpoint)); - } - - public class TestSaga : Saga, IAmStartedByMessages, - IHandleMessages, IHandleTimeouts - { - public Context Context { get; set; } - - public void Handle(StartSagaMessage message) - { - Data.SomeId = message.SomeId; - Context.StartSagaMessageReceived = true; - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.SomeId) - .ToSaga(s => s.SomeId); - ConfigureMapping(m => m.SomeId) - .ToSaga(s => s.SomeId); - } - - public void Handle(SomeEvent message) - { - RequestTimeout(TimeSpan.FromMilliseconds(100), message); - Context.SomeEventReceived = true; - } - - public void Timeout(SomeEvent message) - { - Context.TimeoutReceived = true; - MarkAsComplete(); - } - } - - public class TestSagaData : IContainSagaData - { - public Guid Id { get; set; } - public string Originator { get; set; } - public string OriginalMessageId { get; set; } - - [Unique] - public Guid SomeId { get; set; } - } - } - - [Serializable] - public class StartSagaMessage : ICommand - { - public Guid SomeId { get; set; } - } - - [Serializable] - public class SomeEvent : IEvent - { - public Guid SomeId { get; set; } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_containSagaData.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_containSagaData.cs deleted file mode 100644 index 54504ea65..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Sagas/When_using_containSagaData.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using Saga; - using ScenarioDescriptors; - - // Repro for #SB-191 - public class When_using_containsagadata : NServiceBusAcceptanceTest - { - [Test] - public void Should_handle_timeouts_properly_when_using_NHibernate() - { - Scenario.Define() - .WithEndpoint( - b => b.Given(bus => bus.SendLocal(new StartSaga {DataId = Guid.NewGuid()}))) - .Done(c => c.DidAllSagaInstancesReceiveTimeouts) - .Repeat(r => r.For(Transports.SqlServer).For(SagaPersisters.NHibernate)) - .Should(c => - { - Assert.True(c.DidAllSagaInstancesReceiveTimeouts); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool DidAllSagaInstancesReceiveTimeouts { get; set; } - } - - public class EndpointThatHostsASaga : EndpointConfigurationBuilder - { - public EndpointThatHostsASaga() - { - EndpointSetup(); - } - - public class SagaThatUsesNHibernatePersistence : Saga, - IAmStartedByMessages, - IHandleTimeouts - { - public Context Context { get; set; } - - public void Handle(StartSaga message) - { - Data.DataId = message.DataId; - - RequestTimeout(TimeSpan.FromSeconds(5), new TimeHasPassed()); - } - - public void Timeout(TimeHasPassed state) - { - MarkAsComplete(); - - Context.DidAllSagaInstancesReceiveTimeouts = true; - } - - public override void ConfigureHowToFindSaga() - { - ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); - } - - public class MySagaData : ContainSagaData - { - [Unique] - public virtual Guid DataId { get; set; } - } - - public class TimeHasPassed - { - } - } - } - - [Serializable] - public class StartSaga : ICommand - { - public Guid DataId { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllBuilders.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllBuilders.cs deleted file mode 100644 index c8b0bcca5..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllBuilders.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using NServiceBus.AcceptanceTesting.Support; - - public class AllBuilders:ScenarioDescriptor - { - public AllBuilders() - { - Add(Builders.Unity); - Add(Builders.Autofac); - Add(Builders.Windsor); - Add(Builders.Spring); - Add(Builders.Ninject); - Add(Builders.StructureMap); - - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSagaPersisters.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSagaPersisters.cs deleted file mode 100644 index ab71a0b9a..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSagaPersisters.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using AcceptanceTesting.Support; - - public class AllSagaPersisters : ScenarioDescriptor - { - public AllSagaPersisters() - { - Add(SagaPersisters.InMemory); - Add(SagaPersisters.Raven); - Add(SagaPersisters.NHibernate); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSerializers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSerializers.cs deleted file mode 100644 index ce90fdb1f..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSerializers.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using NServiceBus.AcceptanceTesting.Support; - - public class AllSerializers : ScenarioDescriptor - { - public AllSerializers() - { - Add(Serializers.Bson); - Add(Serializers.Json); - Add(Serializers.Xml); - Add(Serializers.Binary); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSubscriptionStorages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSubscriptionStorages.cs deleted file mode 100644 index 4b1cce819..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllSubscriptionStorages.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using AcceptanceTesting.Support; - - public class AllSubscriptionStorages : ScenarioDescriptor - { - public AllSubscriptionStorages() - { - Add(SubscriptionStorages.InMemory); - Add(SubscriptionStorages.Raven); - Add(SubscriptionStorages.NHibernate); - Add(SubscriptionStorages.Msmq); - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllTransports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllTransports.cs deleted file mode 100644 index 5eaa17534..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/AllTransports.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using AcceptanceTesting.Support; - using Hosting.Helpers; - - public class AllTransports : ScenarioDescriptor - { - public AllTransports() - { - AddRange(ActiveTransports); - } - - static IEnumerable ActiveTransports - { - get - { - if (activeTransports == null) - { - //temporary fix until we can get rid of the "AllTransports" all together - activeTransports = new List - { - Transports.Default - }; - } - - return activeTransports; - } - } - - static ICollection activeTransports; - } - - public class AllDtcTransports : AllTransports - { - public AllDtcTransports() - { - Remove(Transports.RabbitMQ); - } - } - - public class AllBrokerTransports : AllTransports - { - public AllBrokerTransports() - { - Remove(Transports.Msmq); - } - } - - public class AllTransportsWithCentralizedPubSubSupport : AllTransports - { - public AllTransportsWithCentralizedPubSubSupport() - { - Remove(Transports.Msmq); - Remove(Transports.SqlServer); - } - } - - public class AllTransportsWithMessageDrivenPubSub : AllTransports - { - public AllTransportsWithMessageDrivenPubSub() - { - Remove(Transports.ActiveMQ); - Remove(Transports.RabbitMQ); - } - } - - public class TypeScanner - { - - public static IEnumerable GetAllTypesAssignableTo() - { - return AvailableAssemblies.SelectMany(a => a.GetTypes()) - .Where(t => typeof (T).IsAssignableFrom(t) && t != typeof(T)) - .ToList(); - } - - static IEnumerable AvailableAssemblies - { - get - { - if (assemblies == null) - { - var result = new AssemblyScanner().GetScannableAssemblies(); - - if (result.Errors.Any()) - { - foreach (var errors in result.Errors) - { - Console.Out.WriteLine(errors); - } - - throw new InvalidOperationException("Assembly scanning failed"); - } - - assemblies = result.Assemblies; - } - - return assemblies; - } - } - - static List assemblies; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Builders.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Builders.cs deleted file mode 100644 index 8ccf6c6b5..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Builders.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System.Collections.Generic; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.ObjectBuilder.Autofac; - using NServiceBus.ObjectBuilder.CastleWindsor; - using NServiceBus.ObjectBuilder.Ninject; - using NServiceBus.ObjectBuilder.Spring; - using NServiceBus.ObjectBuilder.StructureMap; - using NServiceBus.ObjectBuilder.Unity; - - public static class Builders - { - public static readonly RunDescriptor Unity = new RunDescriptor - { - Key = "Unity", - Settings = - new Dictionary - { - { - "Builder", typeof (UnityObjectBuilder).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Autofac = new RunDescriptor - { - Key = "Autofac", - Settings = - new Dictionary - { - { - "Builder", typeof (AutofacObjectBuilder).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Windsor = new RunDescriptor - { - Key = "Windsor", - Settings = - new Dictionary - { - { - "Builder", typeof (WindsorObjectBuilder).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Ninject = new RunDescriptor - { - Key = "Ninject", - Settings = - new Dictionary - { - { - "Builder", typeof (NinjectObjectBuilder).AssemblyQualifiedName - } - } - }; - - - public static readonly RunDescriptor Spring = new RunDescriptor - { - Key = "Spring", - Settings = - new Dictionary - { - { - "Builder", typeof (SpringObjectBuilder).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor StructureMap = new RunDescriptor - { - Key = "StructureMap", - Settings = - new Dictionary - { - { - "Builder", typeof (StructureMapObjectBuilder).AssemblyQualifiedName - } - } - }; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SagaPersisters.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SagaPersisters.cs deleted file mode 100644 index 4cc3a3014..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SagaPersisters.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System.Collections.Generic; - using AcceptanceTesting.Support; - using NServiceBus.SagaPersisters.NHibernate; - using Persistence.InMemory.SagaPersister; - using Persistence.Raven.SagaPersister; - - public static class SagaPersisters - { - public static readonly RunDescriptor InMemory = new RunDescriptor - { - Key = "InMemorySagaPersister", - Settings = - new Dictionary - { - { - "SagaPersister", - typeof (InMemorySagaPersister).AssemblyQualifiedName - } - } - }; - - - public static readonly RunDescriptor Raven = new RunDescriptor - { - Key = "RavenSagaPersister", - Settings = - new Dictionary - { - { - "SagaPersister", - typeof (RavenSagaPersister).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor NHibernate = new RunDescriptor - { - Key = "NHibernateSagaPersister", - Settings = - new Dictionary - { - { - "SagaPersister", - typeof (SagaPersister).AssemblyQualifiedName - } - } - }; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Serializers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Serializers.cs deleted file mode 100644 index c15b82e11..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Serializers.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System.Collections.Generic; - using AcceptanceTesting.Support; - using NServiceBus.Serializers.Binary; - using NServiceBus.Serializers.Json; - using NServiceBus.Serializers.XML; - - public static class Serializers - { - public static readonly RunDescriptor Binary = new RunDescriptor - { - Key = "Binary", - Settings = - new Dictionary - { - { - "Serializer", typeof (BinaryMessageSerializer).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Bson = new RunDescriptor - { - Key = "Bson", - Settings = - new Dictionary - { - { - "Serializer", typeof (BsonMessageSerializer).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Xml = new RunDescriptor - { - Key = "Xml", - Settings = - new Dictionary - { - { - "Serializer", typeof (XmlMessageSerializer).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Json = new RunDescriptor - { - Key = "Json", - Settings = - new Dictionary - { - { - "Serializer", typeof (JsonMessageSerializer).AssemblyQualifiedName - } - } - }; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SubscriptionStorages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SubscriptionStorages.cs deleted file mode 100644 index e92295568..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/SubscriptionStorages.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System.Collections.Generic; - using AcceptanceTesting.Support; - using Persistence.InMemory.SubscriptionStorage; - using Persistence.Msmq.SubscriptionStorage; - using Persistence.Raven.SubscriptionStorage; - using Unicast.Subscriptions.NHibernate; - - public static class SubscriptionStorages - { - public static readonly RunDescriptor InMemory = new RunDescriptor - { - Key = "InMemorySubscriptionStorage", - Settings = - new Dictionary - { - { - "SubscriptionStorage", - typeof (InMemorySubscriptionStorage).AssemblyQualifiedName - } - } - }; - - - public static readonly RunDescriptor Raven = new RunDescriptor - { - Key = "RavenSubscriptionStorage", - Settings = - new Dictionary - { - { - "SubscriptionStorage", - typeof (RavenSubscriptionStorage).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor NHibernate = new RunDescriptor - { - Key = "NHibernateSubscriptionStorage", - Settings = - new Dictionary - { - { - "SubscriptionStorage", - typeof (SubscriptionStorage).AssemblyQualifiedName - } - } - }; - - public static readonly RunDescriptor Msmq = new RunDescriptor - { - Key = "MsmqSubscriptionStorage", - Settings = - new Dictionary - { - { - "SubscriptionStorage", - typeof (MsmqSubscriptionStorage).AssemblyQualifiedName - } - } - }; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Transports.cs deleted file mode 100644 index 5baf74259..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ScenarioDescriptors/Transports.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace NServiceBus.AcceptanceTests.ScenarioDescriptors -{ - using System; - using System.Collections.Generic; - using System.Linq; - using AcceptanceTesting.Support; - using NServiceBus.Transports; - - public static class Transports - { - - public static IEnumerable AllAvailable - { - get - { - if (availableTransports == null) - availableTransports = GetAllAvailable().ToList(); - - return availableTransports; - } - } - - - public static RunDescriptor Default - { - get - { - var specificTransport = Environment.GetEnvironmentVariable("Transport.UseSpecific"); - - if (!string.IsNullOrEmpty(specificTransport)) - return AllAvailable.Single(r => r.Key == specificTransport); - - var transportsOtherThanMsmq = AllAvailable.Where(t => t != Msmq); - - if (transportsOtherThanMsmq.Count() == 1) - return transportsOtherThanMsmq.First(); - - return Msmq; - } - } - - public static RunDescriptor ActiveMQ - { - get { return AllAvailable.SingleOrDefault(r => r.Key == "ActiveMQ"); } - } - - public static RunDescriptor Msmq - { - get { return AllAvailable.SingleOrDefault(r => r.Key == "Msmq"); } - } - - public static RunDescriptor RabbitMQ - { - get { return AllAvailable.SingleOrDefault(r => r.Key == "RabbitMQ"); } - } - - - - public static RunDescriptor SqlServer - { - get { return AllAvailable.SingleOrDefault(r => r.Key == "SqlServer"); } - } - - static IEnumerable GetAllAvailable() - { - var foundTransportDefinitions = TypeScanner.GetAllTypesAssignableTo(); - - - foreach (var transportDefinitionType in foundTransportDefinitions) - { - var key = transportDefinitionType.Name; - - var runDescriptor = new RunDescriptor - { - Key = key, - Settings = - new Dictionary - { - {"Transport", transportDefinitionType.AssemblyQualifiedName} - } - }; - - var connectionString = Environment.GetEnvironmentVariable(key + ".ConnectionString"); - - if (string.IsNullOrEmpty(connectionString) && DefaultConnectionStrings.ContainsKey(key)) - connectionString = DefaultConnectionStrings[key]; - - - if (!string.IsNullOrEmpty(connectionString)) - { - runDescriptor.Settings.Add("Transport.ConnectionString", connectionString); - yield return runDescriptor; - } - else - { - Console.Out.WriteLine("No connection string found for transport: {0}, test will not be executed for this transport", key); - } - } - } - - static IList availableTransports; - - static readonly Dictionary DefaultConnectionStrings = new Dictionary - { - {"RabbitMQ", "host=localhost"}, - {"SqlServer", @"Server=localhost\sqlexpress;Database=nservicebus;Trusted_Connection=True;"}, - {"ActiveMQ", @"ServerUrl=activemq:tcp://localhost:61616"}, - {"Msmq", @"cacheSendConnection=false;journal=false;"} - }; - - - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Scheduling/When_scheduling_a_recurring_task.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Scheduling/When_scheduling_a_recurring_task.cs deleted file mode 100644 index ab24ef9dd..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Scheduling/When_scheduling_a_recurring_task.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Sagas -{ - using System; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_scheduling_a_recurring_task : NServiceBusAcceptanceTest - { - [Test] - public void Should_execute_the_task() - { - Scenario.Define() - .WithEndpoint() - .Done(c => c.ScheduleActionInvoked) - .Repeat(r => r.For(Transports.Default)) - .Run(TimeSpan.FromSeconds(60)); - } - - public class Context : ScenarioContext - { - public bool ScheduleActionInvoked { get; set; } - } - - public class SchedulingEndpoint : EndpointConfigurationBuilder - { - public SchedulingEndpoint() - { - EndpointSetup(); - } - - class SetupScheduledAction : IWantToRunWhenBusStartsAndStops - { - public void Start() - { - Schedule.Every(TimeSpan.FromSeconds(5)) - .Action("MyTask", () => - { - Console.Out.WriteLine("Task invoked"); - Configure.Instance.Builder.Build() - .ScheduleActionInvoked = true; - }); - } - - public void Stop() - { - - } - } - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/FakePromotableResourceManager.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/FakePromotableResourceManager.cs deleted file mode 100644 index 8e3adc743..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/FakePromotableResourceManager.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - - public class FakePromotableResourceManager : IPromotableSinglePhaseNotification, IEnlistmentNotification - { - public static Guid ResourceManagerId = Guid.Parse("6f057e24-a0d8-4c95-b091-b8dc9a916fa4"); - - public void Prepare(PreparingEnlistment preparingEnlistment) - { - preparingEnlistment.Prepared(); - } - - public void Commit(Enlistment enlistment) - { - enlistment.Done(); - } - - public void Rollback(Enlistment enlistment) - { - enlistment.Done(); - } - - public void InDoubt(Enlistment enlistment) - { - enlistment.Done(); - } - - - public void Initialize() - { - } - - public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment) - { - singlePhaseEnlistment.Committed(); - } - - public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment) - { - singlePhaseEnlistment.Done(); - } - - public byte[] Promote() - { - return TransactionInterop.GetTransmitterPropagationToken(new CommittableTransaction()); - - } - - - } - -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_disabled.cs deleted file mode 100644 index 095237133..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_disabled.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_receiving_a_message_with_dtc_disabled : NServiceBusAcceptanceTest - { - [Test] - public void Should_not_escalate_a_single_durable_rm_to_dtc_tx() - { - - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MyMessage()))) - .Done(c => c.HandlerInvoked) - .Repeat(r => r.For()) - .Should(c => - { - //this check mainly applies to MSMQ who creates a DTC tx right of the bat if DTC is on - Assert.AreEqual(Guid.Empty, c.DistributedIdentifierBefore, "No DTC tx should exist before enlistment"); - Assert.True(c.CanEnlistPromotable, "A promotable RM should be able to enlist"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool HandlerInvoked { get; set; } - - public Guid DistributedIdentifierBefore { get; set; } - - public bool CanEnlistPromotable { get; set; } - } - - public class NonDTCEndpoint : EndpointConfigurationBuilder - { - public NonDTCEndpoint() - { - Configure.Transactions.Advanced(a => a.DisableDistributedTransactions()); - EndpointSetup(); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyMessage messageThatIsEnlisted) - { - Context.DistributedIdentifierBefore = Transaction.Current.TransactionInformation.DistributedIdentifier; - - Context.CanEnlistPromotable = Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager()); - - Context.HandlerInvoked = true; - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_enabled.cs deleted file mode 100644 index 07eac2465..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_dtc_enabled.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_receiving_a_message_with_dtc_enabled : NServiceBusAcceptanceTest - { - [Test] - public void Should_enlist_the_receive_in_the_dtc_tx() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MyMessage()))) - .Done(c => c.HandlerInvoked) - .Repeat(r => r.For()) - .Should(c => Assert.False(c.CanEnlistPromotable, "There should exists a DTC tx")) - .Run(); - } - - [Test] - public void Basic_assumptions_promotable_should_fail_if_durable_already_exists() - { - using (var tx = new TransactionScope()) - { - Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None); - Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager())); - - tx.Complete(); - } - } - - - [Test] - public void Basic_assumptions_second_promotable_should_fail() - { - using (var tx = new TransactionScope()) - { - Assert.True(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager())); - - Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager())); - - tx.Complete(); - } - } - - - public class Context : ScenarioContext - { - public bool HandlerInvoked { get; set; } - - public bool CanEnlistPromotable { get; set; } - } - - public class DTCEndpoint : EndpointConfigurationBuilder - { - public DTCEndpoint() - { - EndpointSetup(); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyMessage messageThatIsEnlisted) - { - Context.CanEnlistPromotable = Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager()); - Context.HandlerInvoked = true; - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - - - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_the_default_settings.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_the_default_settings.cs deleted file mode 100644 index 3ab7159fe..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_the_default_settings.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_receiving_a_message_with_the_default_settings : NServiceBusAcceptanceTest - { - [Test] - public void Should_wrap_the_handler_pipeline_with_a_transactionscope() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MyMessage()))) - .Done(c => c.HandlerInvoked) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.AmbientTransactionExists, "There should exist an ambient transaction")) - .Run(); - } - - public class Context : ScenarioContext - { - public bool AmbientTransactionExists { get; set; } - public bool HandlerInvoked { get; set; } - } - - public class TransactionalEndpoint : EndpointConfigurationBuilder - { - public TransactionalEndpoint() - { - EndpointSetup(); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MyMessage messageThatIsEnlisted) - { - Context.AmbientTransactionExists = (Transaction.Current != null); - Context.HandlerInvoked = true; - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_transactions_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_transactions_disabled.cs deleted file mode 100644 index 69e05618d..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_receiving_a_message_with_transactions_disabled.cs +++ /dev/null @@ -1,82 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_receiving_a_message_with_transactions_disabled : NServiceBusAcceptanceTest - { - [Test] - public void Should_not_roll_the_message_back_to_the_queue_in_case_of_failure() - { - - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MyMessage()))) - .Done(c => c.TestComplete) - .Repeat(r => r.For(Transports.Default)) - .Should(c => - { - Assert.AreEqual(1, c.TimesCalled, "Should not retry the message"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool TestComplete { get; set; } - - public int TimesCalled { get; set; } - } - - public class NonTransactionalEndpoint : EndpointConfigurationBuilder - { - public NonTransactionalEndpoint() - { - EndpointSetup(c => Configure.Transactions.Disable()); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - public void Handle(MyMessage message) - { - Context.TimesCalled++; - - using (new TransactionScope(TransactionScopeOption.Suppress)) - { - Bus.SendLocal(new CompleteTest()); - } - - throw new Exception("Simulated exception"); - } - } - - public class CompleteTestHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(CompleteTest message) - { - Context.TestComplete = true; - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - - [Serializable] - public class CompleteTest : ICommand - { - } - - - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_a_message_from_a_non_transactional_endpoint_with_a_ambient_transaction_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_a_message_from_a_non_transactional_endpoint_with_a_ambient_transaction_enabled.cs deleted file mode 100644 index fa6c7d155..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_a_message_from_a_non_transactional_endpoint_with_a_ambient_transaction_enabled.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_a_message_from_a_non_transactional_endpoint_with_a_ambient_transaction_enabled : NServiceBusAcceptanceTest - { - [Test] - public void Should_not_roll_the_message_back_to_the_queue_in_case_of_failure() - { - - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MyMessage()))) - .Done(c => c.TestComplete) - .Repeat(r => r.For(Transports.Default)) //broken for active mq - .Should(c => - { - Assert.False(c.MessageEnlistedInTheAmbientTxReceived, "The enlisted bus.Send should not commit"); - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool TestComplete { get; set; } - - public bool MessageEnlistedInTheAmbientTxReceived { get; set; } - } - - public class NonTransactionalEndpoint : EndpointConfigurationBuilder - { - public NonTransactionalEndpoint() - { - EndpointSetup(c => - { - Configure.Transactions.Disable(); - Configure.Transactions.Advanced(t => t.WrapHandlersExecutionInATransactionScope()); - }); - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public IBus Bus { get; set; } - public void Handle(MyMessage message) - { - Bus.SendLocal(new CompleteTest - { - EnlistedInTheAmbientTx = true - }); - - using (new TransactionScope(TransactionScopeOption.Suppress)) - { - Bus.SendLocal(new CompleteTest()); - } - - throw new Exception("Simulated exception"); - } - } - - public class CompleteTestHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(CompleteTest message) - { - if (!Context.MessageEnlistedInTheAmbientTxReceived) - Context.MessageEnlistedInTheAmbientTxReceived = message.EnlistedInTheAmbientTx; - - Context.TestComplete = true; - } - } - } - - [Serializable] - public class MyMessage : ICommand - { - } - - [Serializable] - public class CompleteTest : ICommand - { - public bool EnlistedInTheAmbientTx { get; set; } - } - - - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_messages_within_an_ambient_transaction.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_messages_within_an_ambient_transaction.cs deleted file mode 100644 index a23fa309e..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Transactions/When_sending_messages_within_an_ambient_transaction.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Transactions -{ - using System; - using System.Transactions; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_messages_within_an_ambient_transaction : NServiceBusAcceptanceTest - { - [Test, Ignore("This test isn't suitable for this transport - https://github.com/Particular/NServiceBus.SqlServer/issues/13")] - public void Should_not_deliver_them_until_the_commit_phase() - { - Scenario.Define() - .WithEndpoint(b => b.Given((bus, context) => - { - using (var tx = new TransactionScope()) - { - bus.Send(new MessageThatIsEnlisted { SequenceNumber = 1 }); - bus.Send(new MessageThatIsEnlisted { SequenceNumber = 2 }); - - //send another message as well so that we can check the order in the receiver - using (new TransactionScope(TransactionScopeOption.Suppress)) - { - bus.Send(new MessageThatIsNotEnlisted()); - } - - tx.Complete(); - } - })) - .Done(c => c.MessageThatIsNotEnlistedHandlerWasCalled && c.TimesCalled >= 2) - .Repeat(r => r.For(Transports.Default)) //not stable for sqlserver - .Should(c => - { - Assert.AreEqual(1, c.SequenceNumberOfFirstMessage,"The transport should preserve the order in which the transactional messages are delivered to the queuing system"); - Assert.True(c.NonTransactionalHandlerCalledFirst,"The non transactional handler should be called first"); - } - ) - .Run(); - } - - [Test] - public void Should_not_deliver_them_on_rollback() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => - { - using (new TransactionScope()) - { - bus.Send(new MessageThatIsEnlisted()); - - //rollback - } - - bus.Send(new MessageThatIsNotEnlisted()); - - })) - .Done(c => c.MessageThatIsNotEnlistedHandlerWasCalled) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.False(c.MessageThatIsEnlistedHandlerWasCalled, "The transactional handler should not be called")) - .Run(); - } - - public class Context : ScenarioContext - { - public bool MessageThatIsEnlistedHandlerWasCalled { get; set; } - - public bool MessageThatIsNotEnlistedHandlerWasCalled { get; set; } - public int TimesCalled { get; set; } - - public int SequenceNumberOfFirstMessage { get; set; } - - public bool NonTransactionalHandlerCalledFirst { get; set; } - } - - public class TransactionalEndpoint : EndpointConfigurationBuilder - { - public TransactionalEndpoint() - { - EndpointSetup() - .AddMapping(typeof(TransactionalEndpoint)) - .AddMapping(typeof(TransactionalEndpoint)); - } - - public class MessageThatIsEnlistedHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MessageThatIsEnlisted messageThatIsEnlisted) - { - Context.MessageThatIsEnlistedHandlerWasCalled = true; - Context.TimesCalled++; - - if (Context.SequenceNumberOfFirstMessage == 0) - { - Context.SequenceNumberOfFirstMessage = messageThatIsEnlisted.SequenceNumber; - } - } - } - - public class MessageThatIsNotEnlistedHandler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(MessageThatIsNotEnlisted messageThatIsNotEnlisted) - { - Context.MessageThatIsNotEnlistedHandlerWasCalled = true; - Context.NonTransactionalHandlerCalledFirst = !Context.MessageThatIsEnlistedHandlerWasCalled; - } - } - } - - - [Serializable] - public class MessageThatIsEnlisted : ICommand - { - public int SequenceNumber { get; set; } - } - [Serializable] - public class MessageThatIsNotEnlisted : ICommand - { - } - - - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs b/src/NServiceBus.SqlServer.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs deleted file mode 100644 index e19464646..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/Versioning/When_multiple_versions_of_a_message_is_published.cs +++ /dev/null @@ -1,124 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Versioning -{ - using EndpointTemplates; - using AcceptanceTesting; - using Features; - using NUnit.Framework; - using PubSub; - using ScenarioDescriptors; - - public class When_multiple_versions_of_a_message_is_published : NServiceBusAcceptanceTest - { - [Test] - public void Should_deliver_is_to_both_v1_and_vX_subscribers() - { - Scenario.Define() - .WithEndpoint(b => - b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(s => - { - if (s.SubscriberReturnAddress.Queue.Contains("V1Subscriber")) - context.V1Subscribed = true; - - if (s.SubscriberReturnAddress.Queue.Contains("V2Subscriber")) - context.V2Subscribed = true; - }) - ) - .When(c => c.V1Subscribed && c.V2Subscribed, (bus, c) => bus.Publish(e => - { - e.SomeData = 1; - e.MoreInfo = "dasd"; - }))) - .WithEndpoint(b => b.Given((bus,c) => - { - bus.Subscribe(); - if (!Feature.IsEnabled()) - c.V1Subscribed = true; - })) - .WithEndpoint(b => b.Given((bus,c) => - { - bus.Subscribe(); - if (!Feature.IsEnabled()) - c.V2Subscribed = true; - })) - .Done(c => c.V1SubscriberGotTheMessage && c.V2SubscriberGotTheMessage) - .Repeat(r =>//broken for active mq until #1098 is fixed - r.For(Serializers.Binary)) //versioning isn't supported for binary serialization - .Should(c => - { - //put asserts in here if needed - }) - .Run(); - } - - public class Context : ScenarioContext - { - public bool V1SubscriberGotTheMessage { get; set; } - - public bool V2SubscriberGotTheMessage { get; set; } - - public bool V1Subscribed { get; set; } - - public bool V2Subscribed { get; set; } - } - - public class V2Publisher : EndpointConfigurationBuilder - { - public V2Publisher() - { - EndpointSetup(); - - } - } - public class V1Subscriber : EndpointConfigurationBuilder - { - public V1Subscriber() - { - EndpointSetup() - .ExcludeType() - .AddMapping(typeof(V2Publisher)); - - } - - - class V1Handler:IHandleMessages - { - public Context Context { get; set; } - public void Handle(V1Event message) - { - Context.V1SubscriberGotTheMessage = true; - } - } - } - - - public class V2Subscriber : EndpointConfigurationBuilder - { - public V2Subscriber() - { - EndpointSetup() - .AddMapping(typeof(V2Publisher)); - } - - class V2Handler : IHandleMessages - { - public Context Context { get; set; } - - public void Handle(V2Event message) - { - Context.V2SubscriberGotTheMessage = true; - } - } - } - - - public interface V1Event : IEvent - { - int SomeData { get; set; } - } - - public interface V2Event : V1Event - { - string MoreInfo { get; set; } - } - } -} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ripple.dependencies.config b/src/NServiceBus.SqlServer.AcceptanceTests/ripple.dependencies.config index b2d3469cc..4397c0e7e 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ripple.dependencies.config +++ b/src/NServiceBus.SqlServer.AcceptanceTests/ripple.dependencies.config @@ -1,19 +1,6 @@ -Autofac -Castle.Core -Castle.Windsor -Common.Logging -CommonServiceLocator -Iesi.Collections log4net -NHibernate -Ninject -Ninject.Extensions.ContextPreservation -Ninject.Extensions.NamedScope NUnit -RavenDB.Client -Spring.Core -structuremap -Unity -Unity.Interception NServiceBus -NServiceBus.Interfaces \ No newline at end of file +NServiceBus.Interfaces +NServiceBus.AcceptanceTesting +NServiceBus.AcceptanceTests.Sources \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.sln.DotSettings b/src/NServiceBus.SqlServer.sln.DotSettings index e0b2d50f7..1a34c021d 100644 --- a/src/NServiceBus.SqlServer.sln.DotSettings +++ b/src/NServiceBus.SqlServer.sln.DotSettings @@ -14,7 +14,7 @@ DO_NOT_SHOW ERROR ERROR - ERROR + WARNING ERROR ERROR ERROR @@ -38,7 +38,9 @@ ERROR ERROR ERROR + WARNING ERROR + ERROR ERROR ERROR ERROR @@ -54,6 +56,7 @@ SUGGESTION ERROR ERROR + ERROR ERROR ERROR ERROR @@ -87,13 +90,16 @@ ERROR ERROR ERROR + ERROR ERROR ERROR ERROR ERROR DO_NOT_SHOW + SUGGESTION ERROR ERROR + ERROR ERROR ERROR <?xml version="1.0" encoding="utf-16"?><Profile name="Format My Code Using &quot;Particular&quot; conventions"><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CssReformatCode>True</CssReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><HtmlReformatCode>True</HtmlReformatCode><CSShortenReferences>True</CSShortenReferences><CSharpFormatDocComments>True</CSharpFormatDocComments><CssAlphabetizeProperties>True</CssAlphabetizeProperties></Profile> diff --git a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj index 8a2c4258a..799984ff9 100644 --- a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj +++ b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj @@ -64,6 +64,7 @@ + diff --git a/src/NServiceBus.SqlServer/SqlServerMessageSender.cs b/src/NServiceBus.SqlServer/SqlServerMessageSender.cs index b5434d5eb..777919603 100644 --- a/src/NServiceBus.SqlServer/SqlServerMessageSender.cs +++ b/src/NServiceBus.SqlServer/SqlServerMessageSender.cs @@ -1,10 +1,12 @@ namespace NServiceBus.Transports.SQLServer { using System; + using System.Linq; using System.Data; using System.Data.SqlClient; using Serializers.Json; using Unicast.Queuing; + using System.Collections.Generic; /// /// SqlServer implementation of . @@ -17,9 +19,16 @@ public class SqlServerMessageSender : ISendMessages static JsonMessageSerializer Serializer = new JsonMessageSerializer(null); - public string ConnectionString { get; set; } - + public string DefaultConnectionString { get; set; } + + public Dictionary ConnectionStringCollection { get; private set; } + public UnitOfWork UnitOfWork { get; set; } + + public SqlServerMessageSender() + { + ConnectionStringCollection = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + } /// /// Sends the given to the . @@ -34,25 +43,33 @@ public void Send(TransportMessage message, Address address) { try { + //If there is a connectionstring configured for the queue, use that connectionstring + var queueConnectionString = DefaultConnectionString; + if (ConnectionStringCollection.Keys.Contains(address.Queue)) + { + queueConnectionString = ConnectionStringCollection[address.Queue]; + } - if (UnitOfWork.HasActiveTransaction()) + if (UnitOfWork.HasActiveTransaction(queueConnectionString)) { - using ( - var command = new SqlCommand(string.Format(SqlSend, address.Queue), - UnitOfWork.Transaction.Connection, UnitOfWork.Transaction) - { - CommandType = CommandType.Text - }) + //if there is an active transaction for the connection, we can use the same native transaction + var transaction = UnitOfWork.GetTransaction(queueConnectionString); + + using (var command = new SqlCommand(string.Format(SqlSend, TableNameUtils.GetTableName(address)), transaction.Connection, transaction) + { + CommandType = CommandType.Text + }) { ExecuteQuery(message, command); } } else { - using (var connection = new SqlConnection(ConnectionString)) + //When there is no transaction, a DTC transaction or not yet a native transaction we use a new (pooled) connection + using (var connection = new SqlConnection(queueConnectionString)) { connection.Open(); - using (var command = new SqlCommand(string.Format(SqlSend, address.Queue), connection) + using (var command = new SqlCommand(string.Format(SqlSend, TableNameUtils.GetTableName(address)), connection) { CommandType = CommandType.Text }) diff --git a/src/NServiceBus.SqlServer/SqlServerPollingDequeueStrategy.cs b/src/NServiceBus.SqlServer/SqlServerPollingDequeueStrategy.cs index 40f41451a..e73936a24 100644 --- a/src/NServiceBus.SqlServer/SqlServerPollingDequeueStrategy.cs +++ b/src/NServiceBus.SqlServer/SqlServerPollingDequeueStrategy.cs @@ -57,7 +57,7 @@ public void Init(Address address, TransactionSettings transactionSettings, Timeout = transactionSettings.TransactionTimeout }; - tableName = address.Queue; + tableName = TableNameUtils.GetTableName(address); sql = string.Format(SqlReceive, tableName); @@ -254,7 +254,7 @@ ReceiveResult TryReceiveWithNativeTransaction() try { - UnitOfWork.SetTransaction(transaction); + UnitOfWork.SetTransaction(transaction, connection.ConnectionString); if (tryProcessMessage(message)) { @@ -272,7 +272,7 @@ ReceiveResult TryReceiveWithNativeTransaction() } finally { - UnitOfWork.ClearTransaction(); + UnitOfWork.ClearTransaction(connection.ConnectionString); } return result; diff --git a/src/NServiceBus.SqlServer/SqlServerQueueCreator.cs b/src/NServiceBus.SqlServer/SqlServerQueueCreator.cs index efc489c2a..4ab180460 100644 --- a/src/NServiceBus.SqlServer/SqlServerQueueCreator.cs +++ b/src/NServiceBus.SqlServer/SqlServerQueueCreator.cs @@ -30,7 +30,7 @@ public void CreateQueueIfNecessary(Address address, string account) { using (var connection = new SqlConnection(ConnectionString)) { - var sql = string.Format(Ddl, address.Queue); + var sql = string.Format(Ddl, TableNameUtils.GetTableName(address)); connection.Open(); using (var command = new SqlCommand(sql, connection) {CommandType = CommandType.Text}) diff --git a/src/NServiceBus.SqlServer/SqlServerTransport.cs b/src/NServiceBus.SqlServer/SqlServerTransport.cs index 681885d62..4d5fd9fa7 100644 --- a/src/NServiceBus.SqlServer/SqlServerTransport.cs +++ b/src/NServiceBus.SqlServer/SqlServerTransport.cs @@ -1,9 +1,11 @@ namespace NServiceBus.Features { using System; + using System.Linq; using Settings; using Transports; using Transports.SQLServer; + using System.Configuration; /// /// Configures NServiceBus to use SqlServer as the default transport @@ -27,9 +29,17 @@ public override void Initialize() //Until we refactor the whole address system CustomizeAddress(); - var connectionString = SettingsHolder.Get("NServiceBus.Transport.ConnectionString"); + var defaultConnectionString = SettingsHolder.Get("NServiceBus.Transport.ConnectionString"); - if (String.IsNullOrEmpty(connectionString)) + //Load all connectionstrings + var collection = + ConfigurationManager + .ConnectionStrings + .Cast() + .Where(x => x.Name.StartsWith("NServiceBus/Transport/")) + .ToDictionary(x => x.Name.Replace("NServiceBus/Transport/", String.Empty), y => y.ConnectionString); + + if (String.IsNullOrEmpty(defaultConnectionString)) { throw new ArgumentException("Sql Transport connection string cannot be empty or null."); } @@ -37,13 +47,14 @@ public override void Initialize() NServiceBus.Configure.Component(DependencyLifecycle.SingleInstance); NServiceBus.Configure.Component(DependencyLifecycle.InstancePerCall) - .ConfigureProperty(p => p.ConnectionString, connectionString); + .ConfigureProperty(p => p.ConnectionString, defaultConnectionString); NServiceBus.Configure.Component(DependencyLifecycle.InstancePerCall) - .ConfigureProperty(p => p.ConnectionString, connectionString); + .ConfigureProperty(p => p.DefaultConnectionString, defaultConnectionString) + .ConfigureProperty(p => p.ConnectionStringCollection, collection); NServiceBus.Configure.Component(DependencyLifecycle.InstancePerCall) - .ConfigureProperty(p => p.ConnectionString, connectionString) + .ConfigureProperty(p => p.ConnectionString, defaultConnectionString) .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested); } diff --git a/src/NServiceBus.SqlServer/TableNameUtils.cs b/src/NServiceBus.SqlServer/TableNameUtils.cs new file mode 100644 index 000000000..d37430a31 --- /dev/null +++ b/src/NServiceBus.SqlServer/TableNameUtils.cs @@ -0,0 +1,31 @@ +namespace NServiceBus.Transports.SQLServer +{ + using System; + using System.Security.Cryptography; + using System.Text; + + public static class TableNameUtils + { + public static string GetTableName(Address address) + { + if (address.Queue.Length > 128) + { + return DeterministicGuidBuilder(address.Queue).ToString(); + } + + return address.Queue; + } + + private static Guid DeterministicGuidBuilder(string input) + { + // use MD5 hash to get a 16-byte hash of the string + using (var provider = new MD5CryptoServiceProvider()) + { + var inputBytes = Encoding.Default.GetBytes(input); + var hashBytes = provider.ComputeHash(inputBytes); + // generate a guid from the hash: + return new Guid(hashBytes); + } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/UnitOfWork.cs b/src/NServiceBus.SqlServer/UnitOfWork.cs index 9b54aedc1..6e25add04 100644 --- a/src/NServiceBus.SqlServer/UnitOfWork.cs +++ b/src/NServiceBus.SqlServer/UnitOfWork.cs @@ -1,14 +1,21 @@ namespace NServiceBus.Transports.SQLServer { using System; + using System.Collections.Generic; using System.Data.SqlClient; using System.Threading; + using Settings; public class UnitOfWork : IDisposable { + public UnitOfWork() + { + defaultConnectionString = SettingsHolder.Get("NServiceBus.Transport.ConnectionString"); + } + public SqlTransaction Transaction { - get { return currentTransaction.Value; } + get { return GetTransaction(defaultConnectionString); } } public void Dispose() @@ -16,21 +23,49 @@ public void Dispose() //Injected } + public SqlTransaction GetTransaction(string connectionString) + { + return currentTransactions.Value[connectionString]; + } + public void SetTransaction(SqlTransaction transaction) { - currentTransaction.Value = transaction; + SetTransaction(transaction, defaultConnectionString); + } + + public void SetTransaction(SqlTransaction transaction, string connectionString) + { + if (currentTransactions.Value.ContainsKey(connectionString)) + { + throw new InvalidOperationException("Transaction already exists for connection"); + } + + currentTransactions.Value.Add(connectionString, transaction); } public bool HasActiveTransaction() { - return currentTransaction.IsValueCreated; + return HasActiveTransaction(defaultConnectionString); + } + + public bool HasActiveTransaction(string connectionString) + { + return currentTransactions.Value.ContainsKey(connectionString); } public void ClearTransaction() { - currentTransaction.Value = null; + ClearTransaction(defaultConnectionString); } - readonly ThreadLocal currentTransaction = new ThreadLocal(); + public void ClearTransaction(string connectionString) + { + currentTransactions.Value.Remove(connectionString); + } + + readonly ThreadLocal> currentTransactions + = new ThreadLocal>(() => new Dictionary(StringComparer.InvariantCultureIgnoreCase)); + + string defaultConnectionString; } } \ No newline at end of file