Skip to content

Commit

Permalink
Merge branch 'release-5.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasohlund committed Sep 17, 2014
2 parents e7d3265 + 835cb54 commit d42d160
Show file tree
Hide file tree
Showing 27 changed files with 563 additions and 516 deletions.
2 changes: 1 addition & 1 deletion packaging/nuget/nservicebus.acceptancetests.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</dependencies>
</metadata>
<files>
<file src="..\..\src\NServiceBus.AcceptanceTests\**\*.cs" target="content\App_Packages\NSB.AcceptanceTests.$version$" />
<file src="..\..\src\NServiceBus.AcceptanceTests\**\*.cs" target="content\App_Packages\NSB.AcceptanceTests.$version$" exclude="**\bin\**\*.*;**\obj\**\*.*" />
</files>
</package>
25 changes: 25 additions & 0 deletions packaging/nuget/nservicebus.containertests.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>NServiceBus.ContainerTests.Sources</id>
<title>Source only package containing the NServiceBus container test suite</title>
<version>$version$</version>
<authors>NServiceBus Ltd</authors>
<owners>NServiceBus Ltd</owners>
<licenseUrl>http://particular.net/LicenseAgreement</licenseUrl>
<projectUrl>http://particular.net/</projectUrl>
<iconUrl>http://s3.amazonaws.com/nuget.images/NServiceBus_32.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Container tests for nservicebus core functionality</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2010-2014 NServiceBus. All rights reserved</copyright>
<tags>nservicebus servicebus msmq cqrs publish subscribe</tags>
<dependencies>
<dependency id="NServiceBus" version="$version$" />
<dependency id="NUnit" version="[2.0.0, 3.0.0)" />
</dependencies>
</metadata>
<files>
<file src="..\..\src\NServiceBus.ContainerTests\**\*.cs" target="content\App_Packages\NSB.ContainerTests.$version$" exclude="**\bin\**\*.*;**\obj\**\*.*"/>
</files>
</package>
13 changes: 7 additions & 6 deletions src/NServiceBus.AcceptanceTests/Exceptions/StackTraceAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ namespace NServiceBus.AcceptanceTests.Exceptions
{
static class StackTraceAssert
{
public static void AreEqual(string expected, string actual)
// ReSharper disable once UnusedParameter.Global
public static void StartsWith(string expected, string actual)
{
if (actual == null || expected == null)
if (actual == null)
{
Assert.AreEqual(expected, actual);
Assert.Fail();
}
else
{
var cleanStackTrace = actual.CleanStackTrace();
var cleanStackTrace = CleanStackTrace(actual);
try
{
Assert.AreEqual(expected.Replace("\r\n", "\n"), cleanStackTrace.Replace("\r\n", "\n"));
Assert.IsTrue(cleanStackTrace.Replace("\r\n", "\n").StartsWith(expected.Replace("\r\n", "\n")));
}
catch (Exception)
{
Expand All @@ -29,7 +30,7 @@ public static void AreEqual(string expected, string actual)
}
}
}
public static string CleanStackTrace(this string stackTrace)
static string CleanStackTrace(string stackTrace)
{
if (stackTrace== null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ public void Should_receive_AggregateException_with_both_exceptions()

#if (!DEBUG)

StackTraceAssert.AreEqual(
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)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action()", context.StackTrace);
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace);

StackTraceAssert.AreEqual(
@"at NServiceBus.AcceptanceTests.Exceptions.When_Uow_Begin_and_different_End_throws.Endpoint.UnitOfWorkThatThrowsInEnd.End(Exception ex)
at NServiceBus.UnitOfWorkBehavior.AppendEndExceptionsAndRethrow(Exception initialException)", context.InnerExceptionTwoStackTrace);
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);

#endif

Expand All @@ -55,6 +54,8 @@ public class Context : ScenarioContext
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
Expand All @@ -66,8 +67,8 @@ public Endpoint()
b.RegisterComponents(c =>
{
c.ConfigureComponent<CustomFaultManager>(DependencyLifecycle.SingleInstance);
c.ConfigureComponent<UnitOfWorkThatThrowsInBegin>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrowsInEnd>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrows1>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrows2>(DependencyLifecycle.InstancePerUnitOfWork);
});
b.DisableFeature<TimeoutManager>();
})
Expand Down Expand Up @@ -103,30 +104,63 @@ public void Init(Address address)
}
}

public class UnitOfWorkThatThrowsInBegin : IManageUnitsOfWork
public class UnitOfWorkThatThrows1 : IManageUnitsOfWork
{
public Context Context { get; set; }

bool throwAtEnd;

[MethodImpl(MethodImplOptions.NoInlining)]
public void Begin()
{
throw new BeginException();
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 UnitOfWorkThatThrowsInEnd : IManageUnitsOfWork
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)
{
throw new EndException();
if (throwAtEnd)
{
Context.TypeName = GetType().Name;

throw new EndException();
}
}
}

class Handler : IHandleMessages<Message>
{
[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ public void Should_receive_exception_thrown_from_begin()

Assert.AreEqual(typeof(BeginException), context.ExceptionType);
#if (!DEBUG)
StackTraceAssert.AreEqual(
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)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action()", context.StackTrace);
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace);
#endif
}

Expand Down Expand Up @@ -97,14 +96,14 @@ public void End(Exception ex = null)
{
}
}

class Handler : IHandleMessages<Message>
{
[MethodImpl(MethodImplOptions.NoInlining)]
public void Handle(Message message)
{
}
}

}

[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ public void Should_receive_exception_thrown_from_end()

Assert.AreEqual(typeof(EndException), context.ExceptionType);
#if(!DEBUG)
StackTraceAssert.AreEqual(
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)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action()", context.StackTrace);
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace);
#endif
}

Expand Down Expand Up @@ -104,7 +103,6 @@ public void Handle(Message message)
{
}
}

}

[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public void Should_receive_AggregateException_with_both_exceptions()
.AllowExceptions()
.Done(c => c.ExceptionReceived)
.Run();

Assert.AreEqual(typeof(HandlerException), context.InnerExceptionOneType);
Assert.AreEqual(typeof(EndException), context.InnerExceptionTwoType);

#if (!DEBUG)
StackTraceAssert.AreEqual(
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)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action()", context.StackTrace);
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace);

StackTraceAssert.AreEqual(
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)
Expand All @@ -49,9 +49,9 @@ at NServiceBus.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingCont
at NServiceBus.SubscriptionReceiverBehavior.Invoke(IncomingContext context, Action next)
at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next)", context.InnerExceptionOneStackTrace);

StackTraceAssert.AreEqual(
@"at NServiceBus.AcceptanceTests.Exceptions.When_handler_and_Uow_End_throws.Endpoint.UnitOfWorkThatThrowsInEnd.End(Exception ex)
at NServiceBus.UnitOfWorkBehavior.AppendEndExceptionsAndRethrow(Exception initialException)", context.InnerExceptionTwoStackTrace);
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);

#endif
}
Expand All @@ -64,6 +64,8 @@ public class Context : ScenarioContext
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
Expand All @@ -75,8 +77,8 @@ public Endpoint()
b.RegisterComponents(c =>
{
c.ConfigureComponent<CustomFaultManager>(DependencyLifecycle.SingleInstance);
c.ConfigureComponent<UnitOfWorkThatThrowsInEnd>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrowsInBegin>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrows2>(DependencyLifecycle.InstancePerUnitOfWork);
c.ConfigureComponent<UnitOfWorkThatThrows1>(DependencyLifecycle.InstancePerUnitOfWork);
});
b.DisableFeature<TimeoutManager>();
})
Expand Down Expand Up @@ -112,31 +114,64 @@ public void Init(Address address)
}
}

public class UnitOfWorkThatThrowsInBegin : IManageUnitsOfWork
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 UnitOfWorkThatThrowsInEnd : IManageUnitsOfWork

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)
{
throw new EndException();
if (executedInSecondPlace)
{
Context.TypeName = GetType().Name;

throw new EndException();
}
}
}

class Handler : IHandleMessages<Message>
{
[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Should_receive_exception_from_handler()
.Run();
Assert.AreEqual(typeof(HandlerException), context.ExceptionType);
#if (!DEBUG)
StackTraceAssert.AreEqual(
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)
Expand All @@ -40,8 +40,7 @@ at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action nex
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)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action()", context.StackTrace);
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessage message)", context.StackTrace);
#endif
}

Expand Down
Loading

0 comments on commit d42d160

Please sign in to comment.