Skip to content

Commit

Permalink
Merge branch 'hotfix-6.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonPobiega committed May 8, 2015
2 parents 57c1b3b + 07ce20d commit 655825c
Show file tree
Hide file tree
Showing 37 changed files with 443 additions and 597 deletions.
88 changes: 0 additions & 88 deletions Octopus/DeploymentProcess.json

This file was deleted.

19 changes: 0 additions & 19 deletions Octopus/Project.json

This file was deleted.

2 changes: 0 additions & 2 deletions src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GitHubReleaseNotes" version="0.1.1" />
<package id="ConsoleTweet" version="0.1.0" />
<package id="NuGet.CommandLine" version="2.8.2" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public void Should_receive_exception_from_handler()
.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)
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)
Expand All @@ -39,8 +39,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);
}

public class Context : ScenarioContext
Expand Down Expand Up @@ -108,5 +107,5 @@ public HandlerException()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Should_receive_exact_AggregateException_exception_from_handler()
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)
Expand All @@ -43,8 +43,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);

StackTraceAssert.StartsWith(
@"at NServiceBus.AcceptanceTests.Exceptions.When_handler_throws_AggregateException.Endpoint.Handler.MethodThatThrows()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected override void ConfigureHowToFindSaga(SagaPropertyMapper<SagaData> mapp
public class SagaData : ContainSagaData
{
[Unique]
public Guid SomeId { get; set; }
public virtual Guid SomeId { get; set; }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
namespace NServiceBus.AcceptanceTests.Sagas
{
using System;
using EndpointTemplates;
using AcceptanceTesting;
using NUnit.Framework;
using Saga;
using ScenarioDescriptors;

public class When_a_destination_saga_has_been_completed
{
[Test]
public void Should_ignore_messages_afterwards()
{
var context = new Context
{
Id = Guid.NewGuid()
};

Scenario.Define(context)
.WithEndpoint<SagaEndpoint>(b =>
{
b.Given((bus, c) => bus.SendLocal(new StartSagaMessage
{
SomeId = c.Id
}));
b.When(c => c.StartSagaMessageReceived, (bus, c) =>
{
c.AddTrace("CompleteSagaMessage sent");
bus.SendLocal(new CompleteSagaMessage
{
SomeId = c.Id
});
});
b.When(c => c.SagaCompleted, (bus, c) => bus.SendLocal(new AnotherMessage
{
SomeId = c.Id
}));
})
.Done(c => c.AnotherMessageReceived)
.Repeat(r => r.For(Transports.Default))
.Run();

Assert.True(context.AnotherMessageReceived, "AnotherMessage should have been delivered to the handler outside the saga");
Assert.False(context.SagaReceivedAnotherMessage, "AnotherMessage should not be delivered to the saga after completion");
}

public class Context : ScenarioContext
{
public Guid Id { get; set; }
public bool StartSagaMessageReceived { get; set; }
public bool SagaCompleted { get; set; }
public bool AnotherMessageReceived { get; set; }
public bool SagaReceivedAnotherMessage { get; set; }
}

public class SagaEndpoint : EndpointConfigurationBuilder
{
public SagaEndpoint()
{
EndpointSetup<DefaultServer>(b => b.LoadMessageHandlers<First<TestSaga>>());
}

public class TestSaga : Saga<TestSagaData>,
IAmStartedByMessages<StartSagaMessage>,
IHandleMessages<CompleteSagaMessage>,
IHandleMessages<AnotherMessage>,
IHandleSagaNotFound
{
public Context Context { get; set; }

public void Handle(StartSagaMessage message)
{
Context.AddTrace("Saga started");

Data.SomeId = message.SomeId;

Context.StartSagaMessageReceived = true;
}

public void Handle(CompleteSagaMessage message)
{
Context.AddTrace("CompleteSagaMessage received");
MarkAsComplete();
Context.SagaCompleted = true;
}

public void Handle(AnotherMessage message)
{
Context.AddTrace("AnotherMessage received");
Context.SagaReceivedAnotherMessage = true;
}

protected override void ConfigureHowToFindSaga(SagaPropertyMapper<TestSagaData> mapper)
{
mapper.ConfigureMapping<StartSagaMessage>(m => m.SomeId)
.ToSaga(s => s.SomeId);
mapper.ConfigureMapping<CompleteSagaMessage>(m => m.SomeId)
.ToSaga(s => s.SomeId);
mapper.ConfigureMapping<AnotherMessage>(m => m.SomeId)
.ToSaga(s => s.SomeId);
}

public void Handle(object message)
{
if (message is AnotherMessage)
{
return;
}

throw new Exception("Unexpected 'saga not found' for message: " + message.GetType().Name);
}
}

public class TestSagaData : IContainSagaData
{
public virtual Guid Id { get; set; }
public virtual string Originator { get; set; }
public virtual string OriginalMessageId { get; set; }
[Unique]
public virtual Guid SomeId { get; set; }
}
}

public class CompletionHandler : IHandleMessages<AnotherMessage>
{
public Context Context { get; set; }
public void Handle(AnotherMessage message)
{
Context.AnotherMessageReceived = true;
}
}

[Serializable]
public class StartSagaMessage : ICommand
{
public Guid SomeId { get; set; }
}

[Serializable]
public class CompleteSagaMessage : ICommand
{
public Guid SomeId { get; set; }
}

[Serializable]
public class AnotherMessage : ICommand
{
public Guid SomeId { get; set; }
}
}
}
Loading

0 comments on commit 655825c

Please sign in to comment.