Skip to content

Commit

Permalink
Merge branch 'hotfix-4.2.7' into support-4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
John Simons committed May 1, 2015
2 parents fcf0959 + ae5fa98 commit 42c3ff2
Show file tree
Hide file tree
Showing 47 changed files with 960 additions and 317 deletions.
2 changes: 1 addition & 1 deletion src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NuGet.CommandLine" version="2.8.2" />
<package id="GitHubReleaseNotes" 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 @@ -68,9 +68,9 @@
<Project>{dd48b2d0-e996-412d-9157-821ed8b17a9d}</Project>
<Name>NServiceBus.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\NServiceBus\NServiceBus.csproj">
<ProjectReference Include="..\NServiceBus\NServiceBus.csproj">
<Project>{73867d40-8cbb-48e9-bffa-12bbdd48a341}</Project>
<Name>NServiceBus %28NServiceBus\NServiceBus%29</Name>
<Name>NServiceBus</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
Expand All @@ -81,11 +81,9 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>

<Error Condition="!Exists('..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets'))" />
<Error Condition="!Exists('..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets'))" />
</Target>

<Import Project="..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets" Condition="Exists('..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" />
<Import Project="..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets" Condition="Exists('..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets')" />
</Project>
55 changes: 36 additions & 19 deletions src/NServiceBus.AcceptanceTests/Audit/When_a_message_is_audited.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ public class When_a_message_is_audited : NServiceBusAcceptanceTest
[Test]
public void Should_preserve_the_original_body()
{
var context = new Context();
var context = new Context
{
RunId = Guid.NewGuid()
};

Scenario.Define(context)
.WithEndpoint<EndpointWithAuditOn>(b => b.Given(bus => bus.SendLocal(new MessageToBeAudited())))
.WithEndpoint<EndpointWithAuditOn>(b => b.Given((bus, c) => bus.SendLocal(new MessageToBeAudited{RunId = c.RunId})))
.WithEndpoint<AuditSpyEndpoint>()
.Done(c => c.AuditChecksum != default(byte))
.Done(c => c.Done)
.Run();

Assert.AreEqual(context.OriginalBodyChecksum, context.AuditChecksum, "The body of the message sent to audit should be the same as the original message coming off the queue");
Expand All @@ -31,6 +34,8 @@ public class Context : ScenarioContext
public byte OriginalBodyChecksum { get; set; }

public byte AuditChecksum { get; set; }
public bool Done { get; set; }
public Guid RunId { get; set; }
}

public class EndpointWithAuditOn : EndpointConfigurationBuilder
Expand All @@ -41,32 +46,24 @@ public EndpointWithAuditOn()
.AuditTo<AuditSpyEndpoint>();
}

class BodyMutator : IMutateTransportMessages, NServiceBus.INeedInitialization
class BodyMutator : IMutateIncomingTransportMessages, INeedInitialization
{
public Context Context { get; set; }

public void MutateIncoming(TransportMessage transportMessage)
{

var originalBody = transportMessage.Body;

Context.OriginalBodyChecksum = Checksum(originalBody);

var decryptedBody = new byte[originalBody.Length];
// modifying the body by adding a line break
var modifiedBody = new byte[originalBody.Length + 1];

Buffer.BlockCopy(originalBody,0,decryptedBody,0,originalBody.Length);

//decrypt
decryptedBody[0]++;

transportMessage.Body = decryptedBody;
}
Buffer.BlockCopy(originalBody, 0, modifiedBody, 0, originalBody.Length);

modifiedBody[modifiedBody.Length - 1] = 13;

public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
{
//not the way to do it for real but good enough for this test
transportMessage.Body[0]--;
transportMessage.Body = modifiedBody;
}

public void Init()
Expand All @@ -76,7 +73,12 @@ public void Init()
}


class MessageToBeAuditedHandler : IHandleMessages<MessageToBeAudited>{ public void Handle(MessageToBeAudited message) {}}
class MessageToBeAuditedHandler : IHandleMessages<MessageToBeAudited>
{
public void Handle(MessageToBeAudited message)
{
}
}
}

class AuditSpyEndpoint : EndpointConfigurationBuilder
Expand All @@ -86,7 +88,7 @@ public AuditSpyEndpoint()
EndpointSetup<DefaultServer>();
}

class BodySpy : IMutateIncomingTransportMessages, NServiceBus.INeedInitialization
class BodySpy : IMutateIncomingTransportMessages, INeedInitialization
{
public Context Context { get; set; }

Expand All @@ -100,6 +102,20 @@ public void Init()
Configure.Component<BodySpy>(DependencyLifecycle.InstancePerCall);
}
}

public class MessageToBeAuditedHandler : IHandleMessages<MessageToBeAudited>
{
public Context Context { get; set; }

public void Handle(MessageToBeAudited message)
{
if (message.RunId != Context.RunId)
{
return;
}
Context.Done = true;
}
}
}

public static byte Checksum(byte[] data)
Expand All @@ -111,6 +127,7 @@ public static byte Checksum(byte[] data)
[Serializable]
public class MessageToBeAudited : IMessage
{
public Guid RunId { get; set; }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
namespace NServiceBus.AcceptanceTests.BasicMessaging
{
using System;
using System.Threading;
using EndpointTemplates;
using AcceptanceTesting;
using NUnit.Framework;

public class When_sending_a_message_that_is_registered_multiple_times_to_another_endpoint : NServiceBusAcceptanceTest
{
[Test]
public void First_registration_should_be_the_final_destination()
{
var context = new Context();

Scenario.Define(context)
.WithEndpoint<Sender>(b => b.Given((bus, c) => bus.Send(new MyCommand1())))
.WithEndpoint<Receiver1>()
.WithEndpoint<Receiver2>()
.Done(c => c.WasCalled1 || c.WasCalled2)
.Run();

Assert.IsTrue(context.WasCalled1);
Assert.IsFalse(context.WasCalled2);
}

public class Context : ScenarioContext
{
public bool WasCalled1 { get; set; }
public bool WasCalled2 { get; set; }
}

public class Sender : EndpointConfigurationBuilder
{
public Sender()
{
EndpointSetup<DefaultServer>()
.AddMapping<MyCommand1>(typeof(Receiver1))
.AddMapping<MyCommand2>(typeof(Receiver2));
}
}

public class Receiver1 : EndpointConfigurationBuilder
{
public Receiver1()
{
EndpointSetup<DefaultServer>();
}

public class MyMessageHandler : IHandleMessages<MyBaseCommand>
{
public Context Context { get; set; }

public IBus Bus { get; set; }

public void Handle(MyBaseCommand message)
{
Context.WasCalled1 = true;
Thread.Sleep(2000); // Just to be sure the other receiver is finished
}
}
}

public class Receiver2 : EndpointConfigurationBuilder
{
public Receiver2()
{
EndpointSetup<DefaultServer>();
}

public class MyMessageHandler : IHandleMessages<MyBaseCommand>
{
public Context Context { get; set; }

public IBus Bus { get; set; }

public void Handle(MyBaseCommand message)
{
Context.WasCalled2 = true;
Thread.Sleep(2000); // Just to be sure the other receiver is finished
}
}
}

[Serializable]
public abstract class MyBaseCommand : ICommand
{
}

[Serializable]
public class MyCommand1 : MyBaseCommand
{
}

[Serializable]
public class MyCommand2 : MyBaseCommand
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<Compile Include="BasicMessaging\When_aborting_the_behavior_chain.cs" />
<Compile Include="BasicMessaging\When_handling_current_message_later.cs" />
<Compile Include="BasicMessaging\When_registering_a_callback_for_a_local_message.cs" />
<Compile Include="BasicMessaging\When_sending_a_message_that_is_registered_multiple_times_to_another_endpoint.cs" />
<Compile Include="BasicMessaging\When_using_a_custom_correlation_id.cs" />
<Compile Include="BasicMessaging\When_using_callbacks_in_a_scaleout_scenario.cs" />
<Compile Include="BusStartStop\When_bus_start_and_stops_with_a_pending_message.cs" />
Expand All @@ -138,9 +139,11 @@
<Compile Include="Performance\NServiceBusPerformanceTest.cs" />
<Compile Include="Performance\Receive\Receive_performance.cs" />
<Compile Include="Performance\Sagas\Saga_performance.cs" />
<Compile Include="PubSub\When_multi_subscribing_to_a_polymorphic_event.cs" />
<Compile Include="PubSub\When_publishing_an_event_with_only_local_messagehandlers.cs" />
<Compile Include="PubSub\When_publishing_an_event_with_the_subscriber_scaled_out.cs" />
<Compile Include="PubSub\PubSubAcceptanceTest.cs" />
<Compile Include="PubSub\When_subscribing_to_a_base_event_from_different_publishers.cs" />
<Compile Include="PubSub\When_subscribing_to_a_polymorphic_event.cs" />
<Compile Include="PubSub\When_publishing_an_event_using_a_broker_transport_with_centralized_routing.cs" />
<Compile Include="PubSub\When_publishing_an_event.cs" />
Expand Down Expand Up @@ -223,9 +226,9 @@
<Project>{dd48b2d0-e996-412d-9157-821ed8b17a9d}</Project>
<Name>NServiceBus.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\NServiceBus\NServiceBus.csproj">
<ProjectReference Include="..\NServiceBus\NServiceBus.csproj">
<Project>{73867d40-8cbb-48e9-bffa-12bbdd48a341}</Project>
<Name>NServiceBus %28NServiceBus\NServiceBus%29</Name>
<Name>NServiceBus</Name>
</ProjectReference>
<ProjectReference Include="..\NServiceBus.AcceptanceTesting\NServiceBus.AcceptanceTesting.csproj">
<Project>{758357f6-cd31-4337-80c4-ba377fc257af}</Project>
Expand All @@ -237,11 +240,9 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>

<Error Condition="!Exists('..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets'))" />
<Error Condition="!Exists('..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets'))" />
</Target>

<Import Project="..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets" Condition="Exists('..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" />
<Import Project="..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets" Condition="Exists('..\packages\NuGetPackager.0.5.4\build\NuGetPackager.targets')" />
</Project>
Loading

0 comments on commit 42c3ff2

Please sign in to comment.