Skip to content

Commit

Permalink
Merge pull request #289 from Particular/update-to-nsb-beta7
Browse files Browse the repository at this point in the history
Update NServiceBus to 6.0.0-Beta7
  • Loading branch information
Marcin Hoppe authored Aug 12, 2016
2 parents f019c11 + 489fa6b commit 79f4745
Show file tree
Hide file tree
Showing 256 changed files with 1,758 additions and 587 deletions.
2 changes: 1 addition & 1 deletion packaging/nuget/NServiceBus.SqlServer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<releaseNotes></releaseNotes>
<tags>$tags$</tags>
<dependencies>
<dependency id="NServiceBus" version="[6.0.0-beta0006, 7.0.0)" />
<dependency id="NServiceBus" version="[6.0.0-beta0007, 7.0.0)" />
</dependencies>
</metadata>
<files>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SendOptionsExtensions : EndpointConfigurationBuilder
{
public SendOptionsExtensions()
{
EndpointSetup<DefaultServer>(c => c.Pipeline.Register("TestingSendOptionsExtension", typeof(TestingSendOptionsExtensionBehavior), "Testing send options extensions"));
EndpointSetup<DefaultServer>(c => c.Pipeline.Register("TestingSendOptionsExtension", new TestingSendOptionsExtensionBehavior(), "Testing send options extensions"));
}

class SendMessageHandler : IHandleMessages<SendMessage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Publisher()
{
b.OnEndpointSubscribed<Context>((s, context) => { context.Subscriber1Subscribed = true; });

b.Pipeline.Register("PublishExtensionBehavior", typeof(PublishExtensionBehavior), "Testing publish extensions");
b.Pipeline.Register("PublishExtensionBehavior", new PublishExtensionBehavior(), "Testing publish extensions");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ContextExtendingEndpoint()
{
EndpointSetup<DefaultServer>(c => c.Pipeline.Register(
"CustomContextExtensionBehavior",
typeof(CustomContextExtensionBehavior),
new CustomContextExtensionBehavior(),
"Puts customized data on the message context"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using Features;
using NServiceBus.Config;
using NServiceBus;
using NUnit.Framework;
using UnitOfWork;

Expand Down Expand Up @@ -44,10 +41,8 @@ public MyEndpoint()
EndpointSetup<DefaultServer>(b =>
{
b.RegisterComponents(r => r.ConfigureComponent<CheckUnitOfWorkOutcome>(DependencyLifecycle.InstancePerCall));
b.DisableFeature<TimeoutManager>();
b.ExecuteTheseHandlersFirst(typeof(FirstHandler), typeof(SecondHandler));
})
.WithConfig<TransportConfig>(c => { c.MaxRetries = 0; });
});
}

class CheckUnitOfWorkOutcome : IManageUnitsOfWork
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace NServiceBus.AcceptanceTests.Basic
{
using System.Linq;
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using Logging;
using NUnit.Framework;

public class When_receiving_unobtrusive_message_without_handler : NServiceBusAcceptanceTest
{
[Test]
public async Task Message_should_be_moved_to_error_cause_handler_not_found()
{
var context = await Scenario.Define<Context>()
.WithEndpoint<Sender>(c => c.When(s => s.Send(new MyCommand())))
.WithEndpoint<Receiver>(c => c.DoNotFailOnErrorMessages())
.Done(c => c.FailedMessages.Any())
.Run();

Assert.True(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains($"No handlers could be found for message type: { typeof(MyCommand).FullName}")), "No handlers could be found was not logged.");
Assert.False(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Message header '{ typeof(MyCommand).FullName }' was mapped to type '{ typeof(MyCommand).FullName }' but that type was not found in the message registry, ensure the same message registration conventions are used in all endpoints, especially if using unobtrusive mode.")), "Message type could not be mapped.");
Assert.False(context.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains($"Could not determine message type from message header '{ typeof(MyCommand).FullName}'")), "Message type could not be mapped.");
}

public class Context : ScenarioContext
{
public bool WasCalled { get; set; }
}

public class Sender : EndpointConfigurationBuilder
{
public Sender()
{
EndpointSetup<DefaultServer>(c =>
{
c.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyCommand).FullName);

c.UseSerialization<JsonSerializer>();
}).AddMapping<MyCommand>(typeof(Receiver))
.ExcludeType<MyCommand>(); // remove that type from assembly scanning to simulate what would happen with true unobtrusive mode
}
}


public class Receiver : EndpointConfigurationBuilder
{
public Receiver()
{
EndpointSetup<DefaultServer>(c =>
{
c.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyCommand).FullName);

c.UseSerialization<JsonSerializer>();
})
.ExcludeType<MyCommand>(); // remove that type from assembly scanning to simulate what would happen with true unobtrusive mode
}
}

public class MyCommand
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
namespace NServiceBus.AcceptanceTests.Basic
{
using System;
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using NUnit.Framework;

public class When_sending_interface_message_with_conventions : NServiceBusAcceptanceTest
{
[Test]
public async Task Should_receive_the_message()
{
var context = await Scenario.Define<Context>(c => { c.Id = Guid.NewGuid(); })
.WithEndpoint<Sender>(b => b.When(async (session, c) =>
{
await session.Send<IMyInterfaceMessage>(m => m.Id = c.Id);
}))
.WithEndpoint<Receiver>()
.Done(c => c.MessageInterfaceReceived)
.Run();

Assert.True(context.MessageInterfaceReceived);
}

public class Context : ScenarioContext
{
public bool MessageInterfaceReceived { get; set; }
public Guid Id { get; set; }
}

public class Sender : EndpointConfigurationBuilder
{
public Sender()
{
EndpointSetup<DefaultServer>(b => b.Conventions().DefiningMessagesAs(type => type.Name.EndsWith("Message")))
.AddMapping<IMyInterfaceMessage>(typeof(Receiver))
.ExcludeType<IMyInterfaceMessage>(); // remove that type from assembly scanning to simulate what would happen with true unobtrusive mode
}
}

public class Receiver : EndpointConfigurationBuilder
{
public Receiver()
{
EndpointSetup<DefaultServer>(builder =>
{
builder.Conventions()
.DefiningMessagesAs(type => type.Name.EndsWith("Message"));
});
}

public class MyMessageInterfaceHandler : IHandleMessages<IMyInterfaceMessage>
{
public Context Context { get; set; }

public Task Handle(IMyInterfaceMessage interfaceMessage, IMessageHandlerContext context)
{
if (Context.Id != interfaceMessage.Id)
{
return Task.FromResult(0);
}

Context.MessageInterfaceReceived = true;

return Task.FromResult(0);
}
}
}

public interface IMyInterfaceMessage
{
Guid Id { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
namespace NServiceBus.AcceptanceTests.DataBus
{
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using NUnit.Framework;

public class When_sending_databus_properties_with_unobtrusive : NServiceBusAcceptanceTest
{
[Test]
public async Task Should_receive_messages_with_largepayload_correctly()
{
var payloadToSend = new byte[PayloadSize];

var context = await Scenario.Define<Context>()
.WithEndpoint<Sender>(b => b.When(session => session.Send(new MyMessageWithLargePayload
{
Payload = payloadToSend
})))
.WithEndpoint<Receiver>()
.Done(c => c.ReceivedPayload != null)
.Run();

Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be marshalled correctly using the databus");
}

const int PayloadSize = 100;

public class Context : ScenarioContext
{
public byte[] ReceivedPayload { get; set; }
}

public class Sender : EndpointConfigurationBuilder
{
public Sender()
{
EndpointSetup<DefaultServer>(builder =>
{
builder.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyMessageWithLargePayload).FullName)
.DefiningDataBusPropertiesAs(t => t.Name.Contains("Payload"));
builder.UseDataBus<FileShareDataBus>().BasePath(@".\databus\sender");
builder.UseSerialization<JsonSerializer>();
})
.AddMapping<MyMessageWithLargePayload>(typeof(Receiver))
.ExcludeType<MyMessageWithLargePayload>(); // remove that type from assembly scanning to simulate what would happen with true unobtrusive mode
}
}

public class Receiver : EndpointConfigurationBuilder
{
public Receiver()
{
EndpointSetup<DefaultServer>(builder =>
{
builder.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.FullName == typeof(MyMessageWithLargePayload).FullName)
.DefiningDataBusPropertiesAs(t => t.Name.Contains("Payload"));

builder.UseDataBus<FileShareDataBus>().BasePath(@".\databus\sender");
builder.UseSerialization<JsonSerializer>();
});
}

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

public Task Handle(MyMessageWithLargePayload messageWithLargePayload, IMessageHandlerContext context)
{
Context.ReceivedPayload = messageWithLargePayload.Payload;

return Task.FromResult(0);
}
}
}

public class MyMessageWithLargePayload
{
public byte[] Payload { get; set; }
}
}
}
Loading

0 comments on commit 79f4745

Please sign in to comment.