Пример #1
0
        static void Main(string[] args)
        {
            NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));

            IApplicationContext ctx = new XmlApplicationContext("HelloWorld.xml");

            IChannelResolver channelResolver = new ObjectFactoryChannelResolver(ctx);
            IMessageChannel inputChannel = channelResolver.ResolveChannelName("inputChannel");
            IPollableChannel outputChannel = (IPollableChannel) channelResolver.ResolveChannelName("outputChannel");
            inputChannel.Send(new StringMessage("World"));
            Console.WriteLine(outputChannel.Receive(TimeSpan.Zero).Payload);
            Console.ReadKey();
        }
        public void LookupRegisteredChannel()
        {
            GenericApplicationContext context = new GenericApplicationContext();
            QueueChannel testChannel = new QueueChannel();
            testChannel.ObjectName = "testChannel";
            context.ObjectFactory.RegisterSingleton("testChannel", testChannel);

            ObjectFactoryChannelResolver resolver = new ObjectFactoryChannelResolver(context);
            IMessageChannel lookedUpChannel = resolver.ResolveChannelName("testChannel");
            Assert.IsNotNull(testChannel);
            Assert.That(lookedUpChannel, Is.SameAs(testChannel));
        }
 public void MethodInvokingConsumer()
 {
     const string objectName = "methodInvokingConsumer";
     object channel = _ctx.GetObject(objectName);
     Assert.IsTrue(channel is DirectChannel);
     ObjectFactoryChannelResolver channelResolver = new ObjectFactoryChannelResolver(_ctx);
     Assert.IsNotNull(channelResolver.ResolveChannelName(objectName));
     object adapter = _ctx.GetObject(objectName + ".adapter");
     Assert.IsNotNull(adapter);
     Assert.IsTrue(adapter is EventDrivenConsumer);
     TestObject testBean = (TestObject) _ctx.GetObject("testObject");
     Assert.IsNull(testBean.GetMessage());
     IMessage message = new StringMessage("consumer test");
     Assert.IsTrue(((IMessageChannel) channel).Send(message));
     Assert.IsNotNull(testBean.GetMessage());
     Assert.That(testBean.GetMessage(), Is.EqualTo("consumer test"));
 }
 public void lookupNonRegisteredChannel()
 {
     GenericApplicationContext context = new GenericApplicationContext();
     ObjectFactoryChannelResolver resolver = new ObjectFactoryChannelResolver(context);
     resolver.ResolveChannelName("noSuchChannel");
 }
 public void MethodInvokingSourceAdapterIsNotChannel()
 {
     ObjectFactoryChannelResolver channelResolver = new ObjectFactoryChannelResolver(_ctx);
     channelResolver.ResolveChannelName("methodInvokingSource");
 }
 public void TargetOnly()
 {
     //TODO investigate TimeSpan issue when using BCL syntax.
     const string objectName = "outboundWithImplicitChannel";
     object channel = _ctx.GetObject(objectName);
     Assert.IsTrue(channel is DirectChannel);
     ObjectFactoryChannelResolver channelResolver = new ObjectFactoryChannelResolver(_ctx);
     Assert.IsNotNull(channelResolver.ResolveChannelName(objectName));
     object adapter = _ctx.GetObject(objectName + ".adapter");
     Assert.IsNotNull(adapter);
     Assert.IsTrue(adapter is EventDrivenConsumer);
     TestConsumer consumer = (TestConsumer) _ctx.GetObject("consumer");
     Assert.IsNull(consumer.LastMessage);
     IMessage message = new StringMessage("test");
     Assert.IsTrue(((IMessageChannel) channel).Send(message));
     Assert.IsNotNull(consumer.LastMessage);
     Assert.That(consumer.LastMessage, Is.EqualTo(message));
 }