public void ReceiveWithNonPollableDefaultFails() { DirectChannel channel = new DirectChannel(); MessageChannelTemplate template = new MessageChannelTemplate(channel); template.Receive(); }
public void testDefaultResequencerProperties() { EventDrivenConsumer endpoint = (EventDrivenConsumer)context.GetObject("defaultResequencer"); Resequencer resequencer = (Resequencer)TestUtils.GetFieldValue(endpoint, "_handler"); Assert.IsNull(TestUtils.GetFieldValue(resequencer, "_outputChannel")); Assert.IsNull(TestUtils.GetFieldValue(resequencer, "_discardChannel")); MessageChannelTemplate channelTemplate = (MessageChannelTemplate)TestUtils.GetFieldValue(resequencer, "_channelTemplate"); Assert.That(TestUtils.GetFieldValue(channelTemplate, "_sendTimeout"), Is.EqualTo(TimeSpan.FromMilliseconds(1000l)), "The ResequencerEndpoint is not set with the appropriate timeout value"); Assert.That(TestUtils.GetFieldValue(resequencer, "_sendPartialResultOnTimeout"), Is.EqualTo(false), "The ResequencerEndpoint is not configured with the appropriate 'send partial results on timeout' flag"); Assert.That(TestUtils.GetFieldValue(resequencer, "_reaperInterval"), Is.EqualTo(TimeSpan.FromMilliseconds(1000l)), "The ResequencerEndpoint is not configured with the appropriate reaper interval"); Assert.That(TestUtils.GetFieldValue(resequencer, "_trackedCorrelationIdCapacity"), Is.EqualTo(1000), "The ResequencerEndpoint is not configured with the appropriate tracked correlationId capacity"); Assert.That(TestUtils.GetFieldValue(resequencer, "_timeout"), Is.EqualTo(TimeSpan.FromMilliseconds(60000l)), "The ResequencerEndpoint is not configured with the appropriate timeout"); Assert.That(TestUtils.GetFieldValue(resequencer, "_releasePartialSequences"), Is.EqualTo(true), "The ResequencerEndpoint is not configured with the appropriate 'release partial sequences' flag"); }
public void SendAndReceive() { MessageChannelTemplate template = new MessageChannelTemplate(); IMessage reply = template.SendAndReceive(new StringMessage("test"), requestChannel); Assert.That(reply.Payload, Is.EqualTo("TEST")); }
public void testPropertyAssignment() { EventDrivenConsumer endpoint = (EventDrivenConsumer)context.GetObject("completelyDefinedResequencer"); IMessageChannel outputChannel = (IMessageChannel)context.GetObject("outputChannel"); IMessageChannel discardChannel = (IMessageChannel)context.GetObject("discardChannel"); Resequencer resequencer = (Resequencer)TestUtils.GetFieldValue(endpoint, "_handler"); Assert.That(TestUtils.GetFieldValue(resequencer, "_outputChannel"), Is.EqualTo(outputChannel), "The ResequencerEndpoint is not injected with the appropriate output channel"); Assert.That(TestUtils.GetFieldValue(resequencer, "_discardChannel"), Is.EqualTo(discardChannel), "The ResequencerEndpoint is not injected with the appropriate discard channel"); MessageChannelTemplate channelTemplate = (MessageChannelTemplate)TestUtils.GetFieldValue(resequencer, "_channelTemplate"); Assert.That(TestUtils.GetFieldValue(channelTemplate, "_sendTimeout"), Is.EqualTo(TimeSpan.FromMilliseconds(86420000l)), "The ResequencerEndpoint is not set with the appropriate timeout value"); Assert.That(TestUtils.GetFieldValue(resequencer, "_sendPartialResultOnTimeout"), Is.EqualTo(true), "The ResequencerEndpoint is not configured with the appropriate 'send partial results on timeout' flag"); Assert.That(TestUtils.GetFieldValue(resequencer, "_reaperInterval"), Is.EqualTo(TimeSpan.FromMilliseconds(135l)), "The ResequencerEndpoint is not configured with the appropriate reaper interval"); Assert.That(TestUtils.GetFieldValue(resequencer, "_trackedCorrelationIdCapacity"), Is.EqualTo(99), "The ResequencerEndpoint is not configured with the appropriate tracked correlationId capacity"); Assert.That(TestUtils.GetFieldValue(resequencer, "_timeout"), Is.EqualTo(TimeSpan.FromMilliseconds(42l)), "The ResequencerEndpoint is not configured with the appropriate timeout"); Assert.That(TestUtils.GetFieldValue(resequencer, "_releasePartialSequences"), Is.EqualTo(false), "The ResequencerEndpoint is not configured with the appropriate 'release partial sequences' flag"); }
public void ReceiveWithDefaultChannelProvidedByConstructor() { QueueChannel channel = new QueueChannel(); channel.Send(new StringMessage("test")); MessageChannelTemplate template = new MessageChannelTemplate(channel); IMessage reply = template.Receive(); Assert.That(reply.Payload, Is.EqualTo("test")); }
public GenericMessagingTemplateTest() { MessageChannel = new StubMessageChannel(); Template = new MessageChannelTemplate { DefaultSendDestination = MessageChannel, DestinationResolver = new TestDestinationResolver(this) }; }
public void SendAndReceiveWithExplicitChannelTakesPrecedenceOverDefault() { QueueChannel defaultChannel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel); IMessage message = new StringMessage("test"); IMessage reply = template.SendAndReceive(message, requestChannel); Assert.That(reply.Payload, Is.EqualTo("TEST")); Assert.IsNull(defaultChannel.Receive(TimeSpan.Zero)); }
public void Send() { MessageChannelTemplate template = new MessageChannelTemplate(); QueueChannel channel = new QueueChannel(); template.Send(new StringMessage("test"), channel); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
public void SendWithDefaultChannelProvidedBySetter() { QueueChannel channel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(); template.DefaultChannel = channel; template.Send(new StringMessage("test")); IMessage reply = channel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); }
public void SendWithExplicitChannelTakesPrecedenceOverDefault() { QueueChannel explicitChannel = new QueueChannel(); QueueChannel defaultChannel = new QueueChannel(); MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel); template.Send(new StringMessage("test"), explicitChannel); IMessage reply = explicitChannel.Receive(); Assert.IsNotNull(reply); Assert.That(reply.Payload, Is.EqualTo("test")); Assert.IsNull(defaultChannel.Receive(TimeSpan.Zero)); }
public void sendWithReturnAddress() { IList <string> replies = new List <string>(3); CountDownLatch latch = new CountDownLatch(3); IMessageChannel replyChannel = new SendWithReturnAddressChannel(replies, latch); MessageChannelTemplate template = new MessageChannelTemplate(); IMessage message1 = MessageBuilder.WithPayload("test1").SetReplyChannel(replyChannel).Build(); IMessage message2 = MessageBuilder.WithPayload("test2").SetReplyChannel(replyChannel).Build(); IMessage message3 = MessageBuilder.WithPayload("test3").SetReplyChannel(replyChannel).Build(); template.Send(message1, requestChannel); template.Send(message2, requestChannel); template.Send(message3, requestChannel); latch.Await(TimeSpan.FromMilliseconds(2000)); Assert.That(latch.Count, Is.EqualTo(0)); Assert.IsTrue(replies.Contains("TEST1")); Assert.IsTrue(replies.Contains("TEST2")); Assert.IsTrue(replies.Contains("TEST3")); }
public void ReceiveWithExplicitChannelTakesPrecedenceOverDefault() { QueueChannel explicitChannel = new QueueChannel(); QueueChannel defaultChannel = new QueueChannel(); explicitChannel.Send(new StringMessage("test")); MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel); template.ReceiveTimeout = TimeSpan.Zero; IMessage reply = template.Receive(explicitChannel); Assert.That(reply.Payload, Is.EqualTo("test")); Assert.IsNull(defaultChannel.Receive(TimeSpan.Zero)); }
public void sendWithReturnAddress() { IList<string> replies = new List<string>(3); CountDownLatch latch = new CountDownLatch(3); IMessageChannel replyChannel = new SendWithReturnAddressChannel(replies, latch); MessageChannelTemplate template = new MessageChannelTemplate(); IMessage message1 = MessageBuilder.WithPayload("test1").SetReplyChannel(replyChannel).Build(); IMessage message2 = MessageBuilder.WithPayload("test2").SetReplyChannel(replyChannel).Build(); IMessage message3 = MessageBuilder.WithPayload("test3").SetReplyChannel(replyChannel).Build(); template.Send(message1, requestChannel); template.Send(message2, requestChannel); template.Send(message3, requestChannel); latch.Await(TimeSpan.FromMilliseconds(2000)); Assert.That(latch.Count, Is.EqualTo(0)); Assert.IsTrue(replies.Contains("TEST1")); Assert.IsTrue(replies.Contains("TEST2")); Assert.IsTrue(replies.Contains("TEST3")); }
public void SendWithoutChannelArgFailsIfNoDefaultAvailable() { MessageChannelTemplate template = new MessageChannelTemplate(); template.Send(new StringMessage("test")); }
public void SendAndReceiveWithDefaultChannel() { MessageChannelTemplate template = new MessageChannelTemplate(); template.DefaultChannel = requestChannel; IMessage reply = template.SendAndReceive(new StringMessage("test")); Assert.That(reply.Payload, Is.EqualTo("TEST")); }
public void ReceiveWithoutChannelArgFailsIfNoDefaultAvailable() { MessageChannelTemplate template = new MessageChannelTemplate(); template.Receive(); }
public void SendAndReceiveWithoutChannelArgFailsIfNoDefaultAvailable() { MessageChannelTemplate template = new MessageChannelTemplate(); template.SendAndReceive(new StringMessage("test")); }
/// <summary> /// create a new <see cref="AbstractReplyProducingMessageHandler"/> with a <see cref="MessageChannelTemplate"/> and /// s <see cref="SendTimeout"/> of 1000 milli seconds /// </summary> protected AbstractReplyProducingMessageHandler() { _channelTemplate = new MessageChannelTemplate(); _channelTemplate.SendTimeout = DEFAULT_SEND_TIMEOUT; }