From 1f10801bfbb1547df691e7c3841972fec85d4d5c Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 1 Oct 2015 12:11:39 -0500 Subject: [PATCH 1/5] Add EndpointName to stored MessageId, use straightforward delete for cleanup --- .../Outbox/InMemoryDBFixture.cs | 3 +- .../Outbox/When_adding_outbox_messages.cs | 4 +-- .../Outbox/NHibernateOutboxStorage.cs | 3 +- .../Outbox/OutboxPersister.cs | 30 +++++++++++++------ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/NServiceBus.NHibernate.Tests/Outbox/InMemoryDBFixture.cs b/src/NServiceBus.NHibernate.Tests/Outbox/InMemoryDBFixture.cs index 145f59ba4..c820a2d0d 100644 --- a/src/NServiceBus.NHibernate.Tests/Outbox/InMemoryDBFixture.cs +++ b/src/NServiceBus.NHibernate.Tests/Outbox/InMemoryDBFixture.cs @@ -49,7 +49,8 @@ public void Setup() persister = new OutboxPersister { - StorageSessionProvider = new FakeSessionProvider(SessionFactory, Session) + StorageSessionProvider = new FakeSessionProvider(SessionFactory, Session), + EndpointName = "TestEndpoint" }; } diff --git a/src/NServiceBus.NHibernate.Tests/Outbox/When_adding_outbox_messages.cs b/src/NServiceBus.NHibernate.Tests/Outbox/When_adding_outbox_messages.cs index fae07b8bc..c34b0ae0c 100644 --- a/src/NServiceBus.NHibernate.Tests/Outbox/When_adding_outbox_messages.cs +++ b/src/NServiceBus.NHibernate.Tests/Outbox/When_adding_outbox_messages.cs @@ -73,7 +73,7 @@ public void Should_update_dispatched_flag() using (var session = SessionFactory.OpenSession()) { - var result = session.QueryOver().Where(o => o.MessageId == id) + var result = session.QueryOver().Where(o => o.MessageId == "TestEndpoint/" + id) .SingleOrDefault(); Assert.True(result.Dispatched); @@ -108,7 +108,7 @@ public void Should_delete_all_OutboxRecords_that_have_been_dispatched() var result = session.QueryOver().List(); Assert.AreEqual(1, result.Count); - Assert.AreEqual("NotDispatched", result[0].MessageId); + Assert.AreEqual("TestEndpoint/NotDispatched", result[0].MessageId); } } } diff --git a/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs b/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs index 3bf21e5eb..b01062226 100644 --- a/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs +++ b/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs @@ -30,7 +30,8 @@ protected override void Setup(FeatureConfigurationContext context) context.Settings.Get() .AddMapping(ApplyMappings); - context.Container.ConfigureComponent(DependencyLifecycle.SingleInstance); + context.Container.ConfigureComponent(DependencyLifecycle.SingleInstance) + .ConfigureProperty(op => op.EndpointName, context.Settings.EndpointName()); } void ApplyMappings(Configuration config) diff --git a/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs b/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs index 6dd683887..9494c4989 100644 --- a/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs +++ b/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs @@ -14,9 +14,16 @@ class OutboxPersister : IOutboxStorage { public IStorageSessionProvider StorageSessionProvider { get; set; } public SessionFactoryProvider SessionFactoryProvider { get; set; } + public string EndpointName { get; set; } public bool TryGet(string messageId, out OutboxMessage message) { + object[] possibleIds = new[] + { + EndpointQualifiedMessageId(messageId), + messageId, + }; + using (new TransactionScope(TransactionScopeOption.Suppress)) { OutboxRecord result; @@ -27,7 +34,8 @@ public bool TryGet(string messageId, out OutboxMessage message) { //Explicitly using ICriteria instead of QueryOver for performance reasons. //It seems QueryOver uses quite a bit reflection and that takes longer. - result = session.CreateCriteria().Add(Expression.Eq("MessageId", messageId)) + result = session.CreateCriteria() + .Add(Expression.In("MessageId", possibleIds)) .UniqueResult(); tx.Commit(); @@ -61,7 +69,7 @@ public void Store(string messageId, IEnumerable transportOpe StorageSessionProvider.ExecuteInTransaction(x => x.Save(new OutboxRecord { - MessageId = messageId, + MessageId = EndpointQualifiedMessageId(messageId), Dispatched = false, TransportOperations = ConvertObjectToString(operations) })); @@ -75,10 +83,11 @@ public void SetAsDispatched(string messageId) { using (var tx = session.BeginTransaction(IsolationLevel.ReadCommitted)) { - var queryString = string.Format("update {0} set Dispatched = true, DispatchedAt = :date where MessageId = :messageid And Dispatched = false", + var queryString = string.Format("update {0} set Dispatched = true, DispatchedAt = :date where MessageId IN ( :messageid, :qualifiedMsgId ) And Dispatched = false", typeof(OutboxRecord)); session.CreateQuery(queryString) .SetString("messageid", messageId) + .SetString("qualifiedMsgId", EndpointQualifiedMessageId(messageId)) .SetDateTime("date", DateTime.UtcNow) .ExecuteUpdate(); @@ -96,13 +105,11 @@ public void RemoveEntriesOlderThan(DateTime dateTime) { using (var tx = session.BeginTransaction(IsolationLevel.ReadCommitted)) { - var result = session.QueryOver().Where(o => o.Dispatched && o.DispatchedAt < dateTime) - .List(); + var queryString = string.Format("delete from {0} where Dispatched = true And DispatchedAt < :date", typeof(OutboxRecord)); - foreach (var record in result) - { - session.Delete(record); - } + session.CreateQuery(queryString) + .SetDateTime("date", dateTime) + .ExecuteUpdate(); tx.Commit(); } @@ -130,6 +137,11 @@ static string ConvertObjectToString(IEnumerable operations) return serializer.SerializeObject(operations); } + string EndpointQualifiedMessageId(string messageId) + { + return this.EndpointName + "/" + messageId; + } + static readonly JsonMessageSerializer serializer = new JsonMessageSerializer(null); } } From 48dfcb0cc20a302d05c938254dc34de10017c584 Mon Sep 17 00:00:00 2001 From: David Boike Date: Tue, 20 Oct 2015 15:42:22 -0500 Subject: [PATCH 2/5] Implement circuit breaker for outbox cleanup --- .../Outbox/NHibernateOutboxStorage.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs b/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs index b01062226..2aba2299e 100644 --- a/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs +++ b/src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs @@ -44,7 +44,11 @@ void ApplyMappings(Configuration config) class OutboxCleaner:FeatureStartupTask { - public OutboxPersister OutboxPersister { get; set; } + public OutboxCleaner(OutboxPersister outboxPersister, CriticalError criticalError) + { + this.outboxPersister = outboxPersister; + this.criticalError = criticalError; + } protected override void OnStart() { @@ -91,12 +95,28 @@ protected override void OnStop() void PerformCleanup(object state) { - OutboxPersister.RemoveEntriesOlderThan(DateTime.UtcNow - timeToKeepDeduplicationData); + try + { + outboxPersister.RemoveEntriesOlderThan(DateTime.UtcNow - timeToKeepDeduplicationData); + cleanupFailures = 0; + } + catch (Exception ex) + { + cleanupFailures++; + if (cleanupFailures >= 10) + { + criticalError.Raise("Failed to clean expired Outbox records after 10 consecutive unsuccessful attempts. The most likely cause of this is connectivity issues with your database.", ex); + throw; + } + } } // ReSharper disable NotAccessedField.Local Timer cleanupTimer; // ReSharper restore NotAccessedField.Local + OutboxPersister outboxPersister; + CriticalError criticalError; + int cleanupFailures; TimeSpan timeToKeepDeduplicationData; TimeSpan frequencyToRunDeduplicationDataCleanup; } From 8a8c0fb7162fc6238d9267b3713ad7a47055cb54 Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 22 Oct 2015 13:01:28 -0500 Subject: [PATCH 3/5] Better name matching, to satisfy Simon's OCD --- src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs b/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs index 9494c4989..062e2807a 100644 --- a/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs +++ b/src/NServiceBus.NHibernate/Outbox/OutboxPersister.cs @@ -83,11 +83,11 @@ public void SetAsDispatched(string messageId) { using (var tx = session.BeginTransaction(IsolationLevel.ReadCommitted)) { - var queryString = string.Format("update {0} set Dispatched = true, DispatchedAt = :date where MessageId IN ( :messageid, :qualifiedMsgId ) And Dispatched = false", + var queryString = string.Format("update {0} set Dispatched = true, DispatchedAt = :date where MessageId IN ( :messageid, :qualifiedMessageId ) And Dispatched = false", typeof(OutboxRecord)); session.CreateQuery(queryString) .SetString("messageid", messageId) - .SetString("qualifiedMsgId", EndpointQualifiedMessageId(messageId)) + .SetString("qualifiedMessageId", EndpointQualifiedMessageId(messageId)) .SetDateTime("date", DateTime.UtcNow) .ExecuteUpdate(); From af7ba142892f8a21b86ff32f76ad34c58eb53b0b Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 22 Oct 2015 14:28:04 -0500 Subject: [PATCH 4/5] Removing exceptions directory in integration tests --- .../SerializerCorrupter.cs | 17 -- .../When_cant_convert_to_TransportMessage.cs | 60 ----- ...vert_to_TransportMessage_NoTransactions.cs | 60 ----- ...nvert_to_TransportMessage_SuppressedDTC.cs | 59 ----- .../Exceptions/Message_without_an_id.cs | 94 -------- .../Exceptions/StackTraceAssert.cs | 77 ------- ...When_Uow_Begin_and_different_End_throws.cs | 191 ---------------- .../Exceptions/When_Uow_Begin_throws.cs | 121 ---------- .../Exceptions/When_Uow_End_throws.cs | 120 ---------- .../When_handler_and_Uow_End_throws.cs | 206 ------------------ .../Exceptions/When_handler_throws.cs | 111 ---------- .../When_handler_throws_AggregateException.cs | 137 ------------ ..._handler_throws_serialization_exception.cs | 84 ------- .../Exceptions/When_serialization_throws.cs | 112 ---------- ...s.NHibernate.AcceptanceTests-Oracle.csproj | 14 -- .../SerializerCorrupter.cs | 17 -- .../When_cant_convert_to_TransportMessage.cs | 60 ----- ...vert_to_TransportMessage_NoTransactions.cs | 60 ----- ...nvert_to_TransportMessage_SuppressedDTC.cs | 59 ----- .../Exceptions/Message_without_an_id.cs | 94 -------- .../Exceptions/StackTraceAssert.cs | 77 ------- ...When_Uow_Begin_and_different_End_throws.cs | 191 ---------------- .../Exceptions/When_Uow_Begin_throws.cs | 121 ---------- .../Exceptions/When_Uow_End_throws.cs | 120 ---------- ..._handler_throws_serialization_exception.cs | 84 ------- .../Exceptions/When_serialization_throws.cs | 112 ---------- ...rviceBus.NHibernate.AcceptanceTests.csproj | 11 - 27 files changed, 2469 deletions(-) delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_and_Uow_End_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_AggregateException.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs delete mode 100644 src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs deleted file mode 100644 index 16bcf302d..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Reflection; - - static class SerializerCorrupter - { - - public static void Corrupt() - { - var msmqUtilitiesType = Type.GetType("NServiceBus.MsmqUtilities, NServiceBus.Core"); - var headerSerializerField = msmqUtilitiesType.GetField("headerSerializer", BindingFlags.Static | BindingFlags.NonPublic); - headerSerializerField.SetValue(null, null); - } - - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs deleted file mode 100644 index 0389c48d6..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - - public class When_cant_convert_to_TransportMessage : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup() - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(); - } - - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs deleted file mode 100644 index 7799b1be6..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - using IMessage = NServiceBus.IMessage; - - public class When_cant_convert_to_TransportMessage_NoTransactions : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(b => b.Transactions().Disable()) - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(b => b.Transactions().Disable()); - } - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs deleted file mode 100644 index 7361022d1..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - - public class When_cant_convert_to_TransportMessage_SuppressedDTC : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(b => b.Transactions().DisableDistributedTransactions()) - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(b => b.Transactions().DisableDistributedTransactions()); - } - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs deleted file mode 100644 index 56ea06560..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.MessageMutator; - using NServiceBus.Unicast; - using NServiceBus.Unicast.Messages; - using NServiceBus.Unicast.Transport; - using NUnit.Framework; - - public class Message_without_an_id : NServiceBusAcceptanceTest - { - [Test] - public void Should_invoke_start_message_processing_listeners() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint() - .Done(c => c.StartMessageProcessingCalled) - .Run(); - - Assert.IsTrue(context.StartMessageProcessingCalled); - } - - public class Context : ScenarioContext - { - public bool StartMessageProcessingCalled { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup() - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class StartProcessingListener : IWantToRunWhenBusStartsAndStops - { - readonly UnicastBus bus; - Context context; - - public StartProcessingListener(UnicastBus bus, Context context) - { - this.bus = bus; - this.context = context; - bus.Transport.StartedMessageProcessing += transport_StartedMessageProcessing; - } - - void transport_StartedMessageProcessing(object sender, StartedMessageProcessingEventArgs e) - { - context.StartMessageProcessingCalled = true; - } - - public void Start() - { - bus.SendLocal(new Message()); - } - - public void Stop() - { - bus.Transport.StartedMessageProcessing -= transport_StartedMessageProcessing; - } - } - - class CorruptionMutator : IMutateOutgoingTransportMessages - { - public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage) - { - transportMessage.Headers[Headers.MessageId] = ""; - } - } - - class Handler : IHandleMessages - { - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs deleted file mode 100644 index d3f49c759..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace NServiceBus.AcceptanceTests.Exceptions -{ - static class StackTraceAssert - { - public static void StartsWith(string expected, string actual) - { - if (actual == null) - { - Assert.Fail(); - } - else - { - var cleanStackTrace = CleanStackTrace(actual); - - var reader = new StringReader(cleanStackTrace); - - var stringBuilder = new StringBuilder(); - while (true) - { - var actualLine = reader.ReadLine(); - if (actualLine == null) - { - break; - } - if (expected.Contains(actualLine)) - { - stringBuilder.AppendLine(actualLine); - } - } - - try - { - actual = stringBuilder.ToString().TrimEnd(); - Assert.AreEqual(actual, expected); - } - catch (Exception) - { - Trace.WriteLine(cleanStackTrace); - throw; - } - } - } - static string CleanStackTrace(string stackTrace) - { - if (stackTrace== null) - { - return string.Empty; - } - using (var stringReader = new StringReader(stackTrace)) - { - var stringBuilder = new StringBuilder(); - while (true) - { - var line = stringReader.ReadLine(); - if (line == null) - { - break; - } - - stringBuilder.AppendLine(line.Split(new[] - { - " in " - }, StringSplitOptions.RemoveEmptyEntries).First().Trim()); - } - return stringBuilder.ToString().Trim(); - } - } - } -} - diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs deleted file mode 100644 index b581de12d..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs +++ /dev/null @@ -1,191 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_Begin_and_different_End_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_AggregateException_with_both_exceptions() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(BeginException), context.InnerExceptionOneType); - Assert.AreEqual(typeof(EndException), context.InnerExceptionTwoType); - - StackTraceAssert.StartsWith( -@"at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - - StackTraceAssert.StartsWith( -string.Format(@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_Begin_and_different_End_throws.Endpoint.{0}.End(Exception ex) -at NServiceBus.UnitOfWorkBehavior.AppendEndExceptionsAndRethrow(Exception initialException)", context.TypeName), context.InnerExceptionTwoStackTrace); - - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - public string InnerExceptionOneStackTrace { get; set; } - public string InnerExceptionTwoStackTrace { get; set; } - public Type InnerExceptionOneType { get; set; } - public Type InnerExceptionTwoType { get; set; } - public bool FirstOneExecuted { get; set; } - public string TypeName { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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) - { - var aggregateException = (AggregateException)e; - Context.StackTrace = aggregateException.StackTrace; - var innerExceptions = aggregateException.InnerExceptions; - Context.InnerExceptionOneStackTrace = innerExceptions[0].StackTrace; - Context.InnerExceptionTwoStackTrace = innerExceptions[1].StackTrace; - Context.InnerExceptionOneType = innerExceptions[0].GetType(); - Context.InnerExceptionTwoType = innerExceptions[1].GetType(); - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - public class UnitOfWorkThatThrows1 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool throwAtEnd; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - throw new BeginException(); - } - - Context.FirstOneExecuted = throwAtEnd = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (throwAtEnd) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - public class UnitOfWorkThatThrows2 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool throwAtEnd; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - throw new BeginException(); - } - - Context.FirstOneExecuted = throwAtEnd = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (throwAtEnd) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - - } - - [Serializable] - public class Message : IMessage - { - } - public class BeginException : Exception - { - public BeginException() - : base("BeginException") - { - - } - } - public class EndException : Exception - { - public EndException() - : base("EndException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs deleted file mode 100644 index aae2d7d73..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_Begin_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exception_thrown_from_begin() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(BeginException), context.ExceptionType); - StackTraceAssert.StartsWith( -@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_Begin_throws.Endpoint.UnitOfWorkThatThrowsInBegin.Begin() -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - public class UnitOfWorkThatThrowsInBegin : IManageUnitsOfWork - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - throw new BeginException(); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - public class BeginException : Exception - { - public BeginException() - : base("BeginException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs deleted file mode 100644 index 941aedffc..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs +++ /dev/null @@ -1,120 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_End_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exception_thrown_from_end() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(EndException), context.ExceptionType); - StackTraceAssert.StartsWith( -@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_End_throws.Endpoint.UnitOfWorkThatThrowsInEnd.End(Exception ex) -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - class UnitOfWorkThatThrowsInEnd : IManageUnitsOfWork - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - throw new EndException(); - } - } - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - public class EndException : Exception - { - public EndException() - : base("EndException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_and_Uow_End_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_and_Uow_End_throws.cs deleted file mode 100644 index ce2fba603..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_and_Uow_End_throws.cs +++ /dev/null @@ -1,206 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_handler_and_Uow_End_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_AggregateException_with_both_exceptions() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(HandlerException), context.InnerExceptionOneType); - Assert.AreEqual(typeof(EndException), context.InnerExceptionTwoType); - - StackTraceAssert.StartsWith( -@"at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - - StackTraceAssert.StartsWith( -@"at NServiceBus.AcceptanceTests.Exceptions.When_handler_and_Uow_End_throws.Endpoint.Handler.Handle(Message message) -at NServiceBus.Unicast.MessageHandlerRegistry.Invoke(Object handler, Object message, Dictionary`2 dictionary) -at NServiceBus.InvokeHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SetCurrentMessageBeingHandledBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.LoadHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ExecuteLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.CallbackInvocationBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.DeserializeLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SubscriptionReceiverBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next)", context.InnerExceptionOneStackTrace); - - StackTraceAssert.StartsWith( -string.Format(@"at NServiceBus.AcceptanceTests.Exceptions.When_handler_and_Uow_End_throws.Endpoint.{0}.End(Exception ex) -at NServiceBus.UnitOfWorkBehavior.AppendEndExceptionsAndRethrow(Exception initialException)", context.TypeName), context.InnerExceptionTwoStackTrace); - - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public string InnerExceptionOneStackTrace { get; set; } - public string InnerExceptionTwoStackTrace { get; set; } - public Type InnerExceptionOneType { get; set; } - public Type InnerExceptionTwoType { get; set; } - public bool FirstOneExecuted { get; set; } - public string TypeName { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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) - { - var aggregateException = (AggregateException)e; - Context.StackTrace = aggregateException.StackTrace; - var exceptions = aggregateException.InnerExceptions; - Context.InnerExceptionOneStackTrace = exceptions[0].StackTrace; - Context.InnerExceptionTwoStackTrace = exceptions[1].StackTrace; - Context.InnerExceptionOneType = exceptions[0].GetType(); - Context.InnerExceptionTwoType = exceptions[1].GetType(); - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - public class UnitOfWorkThatThrows1 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool executedInSecondPlace; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - executedInSecondPlace = true; - } - - Context.FirstOneExecuted = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (executedInSecondPlace) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - - public class UnitOfWorkThatThrows2 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool executedInSecondPlace; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - executedInSecondPlace = true; - } - - Context.FirstOneExecuted = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (executedInSecondPlace) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - throw new HandlerException(); - } - } - - } - - [Serializable] - public class Message : IMessage - { - } - public class HandlerException : Exception - { - public HandlerException() - : base("HandlerException") - { - - } - } - public class EndException : Exception - { - public EndException() - : base("EndException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws.cs deleted file mode 100644 index 34e64bd1f..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NUnit.Framework; - - public class When_handler_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exception_from_handler() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - Assert.AreEqual(typeof(HandlerException), context.ExceptionType); - StackTraceAssert.StartsWith( - @"at NServiceBus.AcceptanceTests.Exceptions.When_handler_throws.Endpoint.Handler.Handle(Message message) -at NServiceBus.Unicast.MessageHandlerRegistry.Invoke(Object handler, Object message, Dictionary`2 dictionary) -at NServiceBus.InvokeHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SetCurrentMessageBeingHandledBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.LoadHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ExecuteLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.CallbackInvocationBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.DeserializeLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SubscriptionReceiverBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => c.ConfigureComponent(DependencyLifecycle.SingleInstance)); - b.DisableFeature(); - }) - .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.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - throw new HandlerException(); - } - } - } - - [Serializable] - public class Message : IMessage - { - } - public class HandlerException : Exception - { - public HandlerException() - : base("HandlerException") - { - - } - } - } - -} diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_AggregateException.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_AggregateException.cs deleted file mode 100644 index 3a9a3cf21..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_AggregateException.cs +++ /dev/null @@ -1,137 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NUnit.Framework; - - public class When_handler_throws_AggregateException : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exact_AggregateException_exception_from_handler() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - Assert.AreEqual(typeof(AggregateException), context.ExceptionType); - Assert.AreEqual(typeof(Exception), context.InnerExceptionType); - Assert.AreEqual("My Exception", context.ExceptionMessage); - Assert.AreEqual("My Inner Exception", context.InnerExceptionMessage); - - StackTraceAssert.StartsWith( - @"at NServiceBus.AcceptanceTests.Exceptions.When_handler_throws_AggregateException.Endpoint.Handler.Handle(Message message) -at NServiceBus.Unicast.MessageHandlerRegistry.Invoke(Object handler, Object message, Dictionary`2 dictionary) -at NServiceBus.InvokeHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SetCurrentMessageBeingHandledBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.LoadHandlersBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ExecuteLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.CallbackInvocationBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.DeserializeLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.SubscriptionReceiverBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - - StackTraceAssert.StartsWith( - @"at NServiceBus.AcceptanceTests.Exceptions.When_handler_throws_AggregateException.Endpoint.Handler.MethodThatThrows() -at NServiceBus.AcceptanceTests.Exceptions.When_handler_throws_AggregateException.Endpoint.Handler.Handle(Message message)", context.InnerStackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public string InnerStackTrace { get; set; } - public Type InnerExceptionType { get; set; } - public string ExceptionMessage { get; set; } - public string InnerExceptionMessage { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - }); - b.DisableFeature(); - }) - .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.ExceptionMessage = e.Message; - Context.StackTrace = e.StackTrace; - Context.ExceptionType = e.GetType(); - if (e.InnerException != null) - { - Context.InnerExceptionMessage = e.InnerException.Message; - Context.InnerExceptionType = e.InnerException.GetType(); - Context.InnerStackTrace = e.InnerException.StackTrace; - } - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - try - { - MethodThatThrows(); - } - catch (Exception exception) - { - throw new AggregateException("My Exception", exception); - } - } - - [MethodImpl(MethodImplOptions.NoInlining)] - void MethodThatThrows() - { - throw new Exception("My Inner Exception"); - } - } - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs deleted file mode 100644 index d586e90ca..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; - using Faults; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_handler_throws_serialization_exception : NServiceBusAcceptanceTest - { - [Test] - public void Should_retry_the_message_using_flr() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .AllowExceptions() - .Done(c => c.HandedOverToSlr) - .Run(); - - Assert.AreEqual(5, context.NumberOfTimesInvoked); - Assert.IsFalse(context.SerializationFailedCalled); - } - - public class Context : ScenarioContext - { - public int NumberOfTimesInvoked { get; set; } - public bool HandedOverToSlr { get; set; } - public Dictionary HeadersOfTheFailedMessage { get; set; } - public bool SerializationFailedCalled { get; set; } - } - - public class RetryEndpoint : EndpointConfigurationBuilder - { - public RetryEndpoint() - { - EndpointSetup( - b => b.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance))); - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - Context.SerializationFailedCalled = true; - } - - 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 SerializationException(); - } - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs deleted file mode 100644 index c80d5e1ef..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs +++ /dev/null @@ -1,112 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.MessageMutator; - using NServiceBus.Unicast.Messages; - using NUnit.Framework; - - public class When_serialization_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_MessageDeserializationException() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(MessageDeserializationException), context.ExceptionType); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - public string InnerExceptionStackTrace { get; set; } - public Type InnerExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerCall); - }); - b.DisableFeature(); - }) - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - Context.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - if (e.InnerException != null) - { - Context.InnerExceptionType = e.InnerException.GetType(); - Context.InnerExceptionStackTrace = e.InnerException.StackTrace; - } - Context.ExceptionReceived = true; - } - - public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e) - { - } - - public void Init(Address address) - { - } - } - - class CorruptionMutator : IMutateTransportMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void MutateIncoming(TransportMessage transportMessage) - { - transportMessage.Body[1]++; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/NServiceBus.NHibernate.AcceptanceTests-Oracle.csproj b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/NServiceBus.NHibernate.AcceptanceTests-Oracle.csproj index 55a00abf5..ebbe0add8 100644 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/NServiceBus.NHibernate.AcceptanceTests-Oracle.csproj +++ b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/NServiceBus.NHibernate.AcceptanceTests-Oracle.csproj @@ -137,20 +137,6 @@ - - - - - - - - - - - - - - diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs deleted file mode 100644 index 16bcf302d..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/SerializerCorrupter.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Reflection; - - static class SerializerCorrupter - { - - public static void Corrupt() - { - var msmqUtilitiesType = Type.GetType("NServiceBus.MsmqUtilities, NServiceBus.Core"); - var headerSerializerField = msmqUtilitiesType.GetField("headerSerializer", BindingFlags.Static | BindingFlags.NonPublic); - headerSerializerField.SetValue(null, null); - } - - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs deleted file mode 100644 index 0389c48d6..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - - public class When_cant_convert_to_TransportMessage : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup() - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(); - } - - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs deleted file mode 100644 index 7799b1be6..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_NoTransactions.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - using IMessage = NServiceBus.IMessage; - - public class When_cant_convert_to_TransportMessage_NoTransactions : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(b => b.Transactions().Disable()) - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(b => b.Transactions().Disable()); - } - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs deleted file mode 100644 index 7361022d1..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Cant_convert_to_TransportMessage/When_cant_convert_to_TransportMessage_SuppressedDTC.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Linq; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTesting.Support; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NUnit.Framework; - - public class When_cant_convert_to_TransportMessage_SuppressedDTC : NServiceBusAcceptanceTest - { - [Test] - public void Should_send_message_to_error_queue() - { - Scenario.Define() - .WithEndpoint(b => b.Given(bus => bus.Send(new Message()))) - .WithEndpoint() - .AllowExceptions() - .Done(c => c.GetAllLogs().Any(l=>l.Level == "error")) - .Repeat(r=>r.For(ScenarioDescriptors.Transports.Msmq)) - .Should(c => - { - var logs = c.GetAllLogs(); - Assert.True(logs.Any(l => l.Message.Contains("is corrupt and will be moved to"))); - }) - .Run(new RunSettings - { - UseSeparateAppDomains = true - }); - } - - public class Context : ScenarioContext - { - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(b => b.Transactions().DisableDistributedTransactions()) - .AddMapping(typeof(Receiver)); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - SerializerCorrupter.Corrupt(); - EndpointSetup(b => b.Transactions().DisableDistributedTransactions()); - } - } - - [Serializable] - public class Message : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs deleted file mode 100644 index 56ea06560..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/Message_without_an_id.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.MessageMutator; - using NServiceBus.Unicast; - using NServiceBus.Unicast.Messages; - using NServiceBus.Unicast.Transport; - using NUnit.Framework; - - public class Message_without_an_id : NServiceBusAcceptanceTest - { - [Test] - public void Should_invoke_start_message_processing_listeners() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint() - .Done(c => c.StartMessageProcessingCalled) - .Run(); - - Assert.IsTrue(context.StartMessageProcessingCalled); - } - - public class Context : ScenarioContext - { - public bool StartMessageProcessingCalled { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup() - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class StartProcessingListener : IWantToRunWhenBusStartsAndStops - { - readonly UnicastBus bus; - Context context; - - public StartProcessingListener(UnicastBus bus, Context context) - { - this.bus = bus; - this.context = context; - bus.Transport.StartedMessageProcessing += transport_StartedMessageProcessing; - } - - void transport_StartedMessageProcessing(object sender, StartedMessageProcessingEventArgs e) - { - context.StartMessageProcessingCalled = true; - } - - public void Start() - { - bus.SendLocal(new Message()); - } - - public void Stop() - { - bus.Transport.StartedMessageProcessing -= transport_StartedMessageProcessing; - } - } - - class CorruptionMutator : IMutateOutgoingTransportMessages - { - public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage) - { - transportMessage.Headers[Headers.MessageId] = ""; - } - } - - class Handler : IHandleMessages - { - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs deleted file mode 100644 index d3f49c759..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/StackTraceAssert.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace NServiceBus.AcceptanceTests.Exceptions -{ - static class StackTraceAssert - { - public static void StartsWith(string expected, string actual) - { - if (actual == null) - { - Assert.Fail(); - } - else - { - var cleanStackTrace = CleanStackTrace(actual); - - var reader = new StringReader(cleanStackTrace); - - var stringBuilder = new StringBuilder(); - while (true) - { - var actualLine = reader.ReadLine(); - if (actualLine == null) - { - break; - } - if (expected.Contains(actualLine)) - { - stringBuilder.AppendLine(actualLine); - } - } - - try - { - actual = stringBuilder.ToString().TrimEnd(); - Assert.AreEqual(actual, expected); - } - catch (Exception) - { - Trace.WriteLine(cleanStackTrace); - throw; - } - } - } - static string CleanStackTrace(string stackTrace) - { - if (stackTrace== null) - { - return string.Empty; - } - using (var stringReader = new StringReader(stackTrace)) - { - var stringBuilder = new StringBuilder(); - while (true) - { - var line = stringReader.ReadLine(); - if (line == null) - { - break; - } - - stringBuilder.AppendLine(line.Split(new[] - { - " in " - }, StringSplitOptions.RemoveEmptyEntries).First().Trim()); - } - return stringBuilder.ToString().Trim(); - } - } - } -} - diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs deleted file mode 100644 index b581de12d..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_and_different_End_throws.cs +++ /dev/null @@ -1,191 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_Begin_and_different_End_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_AggregateException_with_both_exceptions() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(BeginException), context.InnerExceptionOneType); - Assert.AreEqual(typeof(EndException), context.InnerExceptionTwoType); - - StackTraceAssert.StartsWith( -@"at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - - StackTraceAssert.StartsWith( -string.Format(@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_Begin_and_different_End_throws.Endpoint.{0}.End(Exception ex) -at NServiceBus.UnitOfWorkBehavior.AppendEndExceptionsAndRethrow(Exception initialException)", context.TypeName), context.InnerExceptionTwoStackTrace); - - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - public string InnerExceptionOneStackTrace { get; set; } - public string InnerExceptionTwoStackTrace { get; set; } - public Type InnerExceptionOneType { get; set; } - public Type InnerExceptionTwoType { get; set; } - public bool FirstOneExecuted { get; set; } - public string TypeName { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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) - { - var aggregateException = (AggregateException)e; - Context.StackTrace = aggregateException.StackTrace; - var innerExceptions = aggregateException.InnerExceptions; - Context.InnerExceptionOneStackTrace = innerExceptions[0].StackTrace; - Context.InnerExceptionTwoStackTrace = innerExceptions[1].StackTrace; - Context.InnerExceptionOneType = innerExceptions[0].GetType(); - Context.InnerExceptionTwoType = innerExceptions[1].GetType(); - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - public class UnitOfWorkThatThrows1 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool throwAtEnd; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - throw new BeginException(); - } - - Context.FirstOneExecuted = throwAtEnd = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (throwAtEnd) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - public class UnitOfWorkThatThrows2 : IManageUnitsOfWork - { - public Context Context { get; set; } - - bool throwAtEnd; - - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - if (Context.FirstOneExecuted) - { - throw new BeginException(); - } - - Context.FirstOneExecuted = throwAtEnd = true; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - if (throwAtEnd) - { - Context.TypeName = GetType().Name; - - throw new EndException(); - } - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - - } - - [Serializable] - public class Message : IMessage - { - } - public class BeginException : Exception - { - public BeginException() - : base("BeginException") - { - - } - } - public class EndException : Exception - { - public EndException() - : base("EndException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs deleted file mode 100644 index aae2d7d73..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_Begin_throws.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_Begin_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exception_thrown_from_begin() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(BeginException), context.ExceptionType); - StackTraceAssert.StartsWith( -@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_Begin_throws.Endpoint.UnitOfWorkThatThrowsInBegin.Begin() -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - public class UnitOfWorkThatThrowsInBegin : IManageUnitsOfWork - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - throw new BeginException(); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - public class BeginException : Exception - { - public BeginException() - : base("BeginException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs deleted file mode 100644 index 941aedffc..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_Uow_End_throws.cs +++ /dev/null @@ -1,120 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.UnitOfWork; - using NUnit.Framework; - - public class When_Uow_End_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_exception_thrown_from_end() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(EndException), context.ExceptionType); - StackTraceAssert.StartsWith( -@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_End_throws.Endpoint.UnitOfWorkThatThrowsInEnd.End(Exception ex) -at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) -at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain`1 pipelineAction, T context) -at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) -at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork); - }); - b.DisableFeature(); - }) - .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.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - Context.ExceptionReceived = true; - } - - public void Init(Address address) - { - - } - } - - class UnitOfWorkThatThrowsInEnd : IManageUnitsOfWork - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Begin() - { - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void End(Exception ex = null) - { - throw new EndException(); - } - } - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - public class EndException : Exception - { - public EndException() - : base("EndException") - { - - } - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs deleted file mode 100644 index d586e90ca..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_handler_throws_serialization_exception.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Retries -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; - using Faults; - using EndpointTemplates; - using AcceptanceTesting; - using NUnit.Framework; - - public class When_handler_throws_serialization_exception : NServiceBusAcceptanceTest - { - [Test] - public void Should_retry_the_message_using_flr() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) - .AllowExceptions() - .Done(c => c.HandedOverToSlr) - .Run(); - - Assert.AreEqual(5, context.NumberOfTimesInvoked); - Assert.IsFalse(context.SerializationFailedCalled); - } - - public class Context : ScenarioContext - { - public int NumberOfTimesInvoked { get; set; } - public bool HandedOverToSlr { get; set; } - public Dictionary HeadersOfTheFailedMessage { get; set; } - public bool SerializationFailedCalled { get; set; } - } - - public class RetryEndpoint : EndpointConfigurationBuilder - { - public RetryEndpoint() - { - EndpointSetup( - b => b.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance))); - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - Context.SerializationFailedCalled = true; - } - - 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 SerializationException(); - } - } - } - - [Serializable] - public class MessageToBeRetried : IMessage - { - } - } - - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs deleted file mode 100644 index c80d5e1ef..000000000 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Exceptions/When_serialization_throws.cs +++ /dev/null @@ -1,112 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Exceptions -{ - using System; - using System.Runtime.CompilerServices; - using NServiceBus.AcceptanceTesting; - using NServiceBus.AcceptanceTests.EndpointTemplates; - using NServiceBus.Config; - using NServiceBus.Faults; - using NServiceBus.Features; - using NServiceBus.MessageMutator; - using NServiceBus.Unicast.Messages; - using NUnit.Framework; - - public class When_serialization_throws : NServiceBusAcceptanceTest - { - [Test] - public void Should_receive_MessageDeserializationException() - { - var context = new Context(); - - Scenario.Define(context) - .WithEndpoint(b => b.Given(bus => bus.SendLocal(new Message()))) - .AllowExceptions() - .Done(c => c.ExceptionReceived) - .Run(); - - Assert.AreEqual(typeof(MessageDeserializationException), context.ExceptionType); - } - - public class Context : ScenarioContext - { - public bool ExceptionReceived { get; set; } - public string StackTrace { get; set; } - public Type ExceptionType { get; set; } - public string InnerExceptionStackTrace { get; set; } - public Type InnerExceptionType { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(b => - { - b.RegisterComponents(c => - { - c.ConfigureComponent(DependencyLifecycle.SingleInstance); - c.ConfigureComponent(DependencyLifecycle.InstancePerCall); - }); - b.DisableFeature(); - }) - .WithConfig(c => - { - c.MaxRetries = 0; - }); - } - - class CustomFaultManager : IManageMessageFailures - { - public Context Context { get; set; } - - public void SerializationFailedForMessage(TransportMessage message, Exception e) - { - Context.ExceptionType = e.GetType(); - Context.StackTrace = e.StackTrace; - if (e.InnerException != null) - { - Context.InnerExceptionType = e.InnerException.GetType(); - Context.InnerExceptionStackTrace = e.InnerException.StackTrace; - } - Context.ExceptionReceived = true; - } - - public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e) - { - } - - public void Init(Address address) - { - } - } - - class CorruptionMutator : IMutateTransportMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void MutateIncoming(TransportMessage transportMessage) - { - transportMessage.Body[1]++; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage) - { - } - } - - class Handler : IHandleMessages - { - [MethodImpl(MethodImplOptions.NoInlining)] - public void Handle(Message message) - { - } - } - } - - [Serializable] - public class Message : IMessage - { - } - } - -} \ No newline at end of file diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/NServiceBus.NHibernate.AcceptanceTests.csproj b/src/NServiceBus.NHibernate.AcceptanceTests/NServiceBus.NHibernate.AcceptanceTests.csproj index 3c1da73fb..4f7b1d735 100644 --- a/src/NServiceBus.NHibernate.AcceptanceTests/NServiceBus.NHibernate.AcceptanceTests.csproj +++ b/src/NServiceBus.NHibernate.AcceptanceTests/NServiceBus.NHibernate.AcceptanceTests.csproj @@ -119,17 +119,6 @@ - - - - - - - - - - - From b18bc860f5a6d387b3e0f2876575865f3a2fae72 Mon Sep 17 00:00:00 2001 From: David Boike Date: Fri, 23 Oct 2015 13:39:10 -0500 Subject: [PATCH 5/5] Testing retries needs to allow exceptions --- .../NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs | 1 + .../NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs index 538c03475..861721e64 100644 --- a/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs +++ b/src/NServiceBus.NHibernate.AcceptanceTests-Oracle/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs @@ -36,6 +36,7 @@ public void Should_raise_FinishedMessageProcessing_event() Scenario.Define(context) .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) + .AllowExceptions() .Done(c => c.FinishedMessageProcessingCalledAfterFaultManagerInvoked) .Run(); diff --git a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs index 538c03475..861721e64 100644 --- a/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs +++ b/src/NServiceBus.NHibernate.AcceptanceTests/App_Packages/NSB.AcceptanceTests.5.1.3/Retries/When_sending_to_slr.cs @@ -36,6 +36,7 @@ public void Should_raise_FinishedMessageProcessing_event() Scenario.Define(context) .WithEndpoint(b => b.Given(bus => bus.SendLocal(new MessageToBeRetried()))) + .AllowExceptions() .Done(c => c.FinishedMessageProcessingCalledAfterFaultManagerInvoked) .Run();