public void TestPriorityChannelWithIntegerDatatypeEnforced()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\PriorityChannelParserTests.xml");
            IPollableChannel    channel = (IPollableChannel)ctx.GetObject("integerOnlyPriorityChannel");

            channel.Send(new Message <int>(3));
            channel.Send(new Message <int>(2));
            channel.Send(new Message <int>(1));
            Assert.That(channel.Receive(TimeSpan.Zero).Payload, Is.EqualTo(1));
            Assert.That(channel.Receive(TimeSpan.Zero).Payload, Is.EqualTo(2));
            Assert.That(channel.Receive(TimeSpan.Zero).Payload, Is.EqualTo(3));
        }
        public void TestPriorityChannelWithIntegerDatatypeEnforced2()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\PriorityChannelParserTests.xml");
            IPollableChannel    channel = (IPollableChannel)ctx.GetObject("integerOnlyPriorityChannel");

            channel.Send(new StringMessage("wrong type"));
        }
        public void TestPriorityChannelWithCustomComparator()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\PriorityChannelParserTests.xml");
            IPollableChannel    channel = (IPollableChannel)ctx.GetObject("priorityChannelWithCustomComparator");

            channel.Send(new StringMessage("C"));
            channel.Send(new StringMessage("A"));
            channel.Send(new StringMessage("D"));
            channel.Send(new StringMessage("B"));
            IMessage reply1 = channel.Receive(TimeSpan.Zero);
            IMessage reply2 = channel.Receive(TimeSpan.Zero);
            IMessage reply3 = channel.Receive(TimeSpan.Zero);
            IMessage reply4 = channel.Receive(TimeSpan.Zero);

            Assert.That(reply1.Payload, Is.EqualTo("A"));
            Assert.That(reply2.Payload, Is.EqualTo("B"));
            Assert.That(reply3.Payload, Is.EqualTo("C"));
            Assert.That(reply4.Payload, Is.EqualTo("D"));
        }
        public void TestPriorityChannelWithDefaultComparator()
        {
            IApplicationContext ctx                 = TestUtils.GetContext(@"Channel\Config\PriorityChannelParserTests.xml");
            IPollableChannel    channel             = (IPollableChannel)ctx.GetObject("priorityChannelWithDefaultComparator");
            IMessage            lowPriorityMessage  = MessageBuilder.WithPayload("low").SetPriority(MessagePriority.LOW).Build();
            IMessage            midPriorityMessage  = MessageBuilder.WithPayload("mid").SetPriority(MessagePriority.NORMAL).Build();
            IMessage            highPriorityMessage = MessageBuilder.WithPayload("high").SetPriority(MessagePriority.HIGH).Build();

            channel.Send(lowPriorityMessage);
            channel.Send(highPriorityMessage);
            channel.Send(midPriorityMessage);
            IMessage reply1 = channel.Receive(TimeSpan.Zero);
            IMessage reply2 = channel.Receive(TimeSpan.Zero);
            IMessage reply3 = channel.Receive(TimeSpan.Zero);

            Assert.That(reply1.Payload, Is.EqualTo("high"));
            Assert.That(reply2.Payload, Is.EqualTo("mid"));
            Assert.That(reply3.Payload, Is.EqualTo("low"));
        }
        public void TestChannelInteceptorInnerBean()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelInterceptorParserTests.xml");
            IPollableChannel    channel = (IPollableChannel)ctx.GetObject("channelWithInterceptorInnerBean");

            channel.Send(new StringMessage("test"));
            IMessage transformed = channel.Receive(TimeSpan.FromMilliseconds(1000));

            Assert.That(transformed.Payload, Is.EqualTo("TEST"));
        }
예제 #6
0
        public void TestSolicitResponse()
        {
            IApplicationContext context = TestUtils.GetContext(@"Config\Xml\gatewayParserTests.xml");
            IPollableChannel    channel = (IPollableChannel)context.GetObject("replyChannel");

            channel.Send(new StringMessage("foo"));
            ITestService service = (ITestService)context.GetObject("solicitResponse");
            string       result  = service.SolicitResponse();

            Assert.That(result, Is.EqualTo("foo"));
        }
        public void PollableChannel()
        {
            IApplicationContext context         = TestUtils.GetContext(@"Config\Xml\BridgeParserTests-context.xml");
            IMessage            message         = new StringMessage("test1");
            IPollableChannel    pollableChannel = (IPollableChannel)context.GetObject("pollableChannel");

            pollableChannel.Send(message);
            IPollableChannel output1 = (IPollableChannel)context.GetObject("output1");
            IMessage         reply   = output1.Receive(TimeSpan.FromMilliseconds(1000));

            Assert.That(reply, Is.EqualTo(message));
        }
        public void TestChannelInteceptorRef()
        {
            IApplicationContext    ctx         = TestUtils.GetContext(@"Channel\Config\ChannelInterceptorParserTests.xml");
            IPollableChannel       channel     = (IPollableChannel)ctx.GetObject("channelWithInterceptorRef");
            TestChannelInterceptor interceptor = (TestChannelInterceptor)ctx.GetObject("interceptor");

            Assert.That(interceptor.SendCount, Is.EqualTo(0));
            channel.Send(new StringMessage("test"));
            Assert.That(interceptor.SendCount, Is.EqualTo(1));
            Assert.That(interceptor.ReceiveCount, Is.EqualTo(0));
            channel.Receive();
            Assert.That(interceptor.ReceiveCount, Is.EqualTo(1));
        }