Ejemplo n.º 1
0
        public void testSingleSelectorRejects()
        {
            AtomicInteger               counter     = new AtomicInteger();
            IMessageSelector            selector    = new TestMessageSelector(false, counter);
            MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector);
            QueueChannel channel = new QueueChannel();

            channel.AddInterceptor(interceptor);
            channel.Send(new StringMessage("test1"));
        }
Ejemplo n.º 2
0
        public void testSingleSelectorAccepts()
        {
            AtomicInteger               counter     = new AtomicInteger();
            IMessageSelector            selector    = new TestMessageSelector(true, counter);
            MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector);
            QueueChannel channel = new QueueChannel();

            channel.AddInterceptor(interceptor);
            Assert.That(channel.Send(new StringMessage("test1")), Is.True);
        }
Ejemplo n.º 3
0
        public void testMultipleSelectorsAccept()
        {
            AtomicInteger               counter     = new AtomicInteger();
            IMessageSelector            selector1   = new TestMessageSelector(true, counter);
            IMessageSelector            selector2   = new TestMessageSelector(true, counter);
            MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector1, selector2);
            QueueChannel channel = new QueueChannel();

            channel.AddInterceptor(interceptor);
            Assert.That(channel.Send(new StringMessage("test1")), Is.True);
            Assert.That(counter.Value, Is.EqualTo(2));
        }
Ejemplo n.º 4
0
        public void testMultipleSelectorsReject()
        {
            bool                        exceptionThrown = false;
            AtomicInteger               counter         = new AtomicInteger();
            IMessageSelector            selector1       = new TestMessageSelector(true, counter);
            IMessageSelector            selector2       = new TestMessageSelector(false, counter);
            IMessageSelector            selector3       = new TestMessageSelector(false, counter);
            IMessageSelector            selector4       = new TestMessageSelector(true, counter);
            MessageSelectingInterceptor interceptor     = new MessageSelectingInterceptor(selector1, selector2, selector3,
                                                                                          selector4);
            QueueChannel channel = new QueueChannel();

            channel.AddInterceptor(interceptor);
            try
            {
                channel.Send(new StringMessage("test1"));
            }
            catch (MessageDeliveryException)
            {
                exceptionThrown = true;
            }
            Assert.That(exceptionThrown, Is.True);
            Assert.That(counter.Value, Is.EqualTo(2));
        }