コード例 #1
0
        public static IApplicationContext GetContext(params string[] files)
        {
            NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));
            NamespaceParserRegistry.RegisterParser(typeof(NmsNamespaceParser));

            return(new XmlApplicationContext(files));
        }
コード例 #2
0
 public void InitContext()
 {
     // Configure Spring programmatically
     NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));
     ctx = new XmlApplicationContext(
         "assembly://Spring.DataQuickStart.Tests/Spring.DataQuickStart.GenericTemplate/ExampleTests.xml");
 }
コード例 #3
0
        //[Test]
        public void BasicConfig()
        {
            NamespaceParserRegistry.RegisterParser(typeof(WcfNamespaceParser));
            IApplicationContext ctx = new XmlApplicationContext(
                ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.BasicConfig.xml", this.GetType()));

            Assert.IsTrue(ctx.ContainsObjectDefinition("channel"));

            RootObjectDefinition rod = ((IObjectDefinitionRegistry)ctx).GetObjectDefinition("channel") as RootObjectDefinition;

            Assert.IsNotNull(rod);

            Assert.IsTrue(rod.HasObjectType);
            Assert.AreEqual(typeof(ChannelFactoryObject <IContract>), rod.ObjectType);
            Assert.AreEqual(1, rod.ConstructorArgumentValues.NamedArgumentValues.Count);
            Assert.AreEqual("ecn", rod.ConstructorArgumentValues.GetNamedArgumentValue("endpointConfigurationName").Value);

            ChannelFactoryObject <IContract> cfo = ctx.GetObject("&channel") as ChannelFactoryObject <IContract>;

            Assert.IsNotNull(cfo);
            Assert.AreEqual(typeof(IContract), cfo.ObjectType);

            IContract contract = ctx.GetObject("channel") as IContract;

            Assert.IsNotNull(contract);
        }
コード例 #4
0
        //[Test]
        public void CustomProperties()
        {
            NamespaceParserRegistry.RegisterParser(typeof(WcfNamespaceParser));
            IApplicationContext ctx = new XmlApplicationContext(
                ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.CustomProperties.xml", this.GetType()));

            Assert.IsTrue(ctx.ContainsObjectDefinition("channel"));

            RootObjectDefinition rod = ((IObjectDefinitionRegistry)ctx).GetObjectDefinition("channel") as RootObjectDefinition;

            Assert.IsNotNull(rod);

            Assert.IsTrue(rod.HasObjectType);
            Assert.AreEqual(typeof(ChannelFactoryObject <IContract>), rod.ObjectType);
            Assert.AreEqual(1, rod.ConstructorArgumentValues.NamedArgumentValues.Count);
            Assert.AreEqual("ecn", rod.ConstructorArgumentValues.GetNamedArgumentValue("endpointConfigurationName").Value);
            Assert.IsTrue(rod.PropertyValues.Contains("Credentials.Windows.ClientCredential"));
            Assert.AreEqual("Spring\\Bruno:gnirpS", rod.PropertyValues.GetPropertyValue("Credentials.Windows.ClientCredential").Value);

            ChannelFactoryObject <IContract> cfo = ctx.GetObject("&channel") as ChannelFactoryObject <IContract>;

            Assert.IsNotNull(cfo);
            Assert.AreEqual(typeof(IContract), cfo.ObjectType);
            Assert.AreEqual("Spring", cfo.Credentials.Windows.ClientCredential.Domain);
            Assert.AreEqual("Bruno", cfo.Credentials.Windows.ClientCredential.UserName);
            Assert.AreEqual("gnirpS", cfo.Credentials.Windows.ClientCredential.Password);

            IContract contract = ctx.GetObject("channel") as IContract;

            Assert.IsNotNull(contract);
        }
コード例 #5
0
        public void Registered()
        {
            NamespaceParserRegistry.RegisterParser(typeof(WcfNamespaceParser));
            INamespaceParser namespaceParser = NamespaceParserRegistry.GetParser("http://www.springframework.net/wcf");

            Assert.IsNotNull(namespaceParser);
            Assert.IsTrue(namespaceParser is WcfNamespaceParser);
        }
コード例 #6
0
        private XmlApplicationContext GetXmlApplicationContext()
        {
            NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));
            XmlApplicationContext ctx = new XmlApplicationContext(
                "assembly://VisualSmart.Dao.DataQuickStart/VisualSmart.Dao.DataQuickStart.Config/Dao.xml");

            return(ctx);
        }
コード例 #7
0
        public void Setup()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            var resourceName = @"assembly://Spring.Messaging.Amqp.Rabbit.Tests/Spring.Messaging.Amqp.Rabbit.Tests.Config/" + typeof(RabbitNamespaceHandlerTests).Name + "-context.xml";
            var resource     = new AssemblyResource(resourceName);

            this.objectFactory = new XmlObjectFactory(resource);
        }
        public virtual void Setup()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            var resourceName =
                @"assembly://Spring.Messaging.Amqp.Rabbit.Tests/Spring.Messaging.Amqp.Rabbit.Tests.Config/"
                + typeof(ListenerContainerPlaceholderParserTests).Name + "-context.xml";

            this.objectFactory = new XmlApplicationContext(resourceName);
        }
コード例 #9
0
        public void TestReceivesMessageFromChannelWithSource()
        {
            NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));

            IApplicationContext ctx = new XmlApplicationContext(@"Channel\Config\DirectChannelParserTests.xml");

            object channel = ctx.GetObject("channel");

            Assert.That(channel.GetType(), Is.EqualTo(typeof(DirectChannel)));
        }
コード例 #10
0
        public static XmlObjectFactory LoadMessagingConfig()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RedisNamespaceHandler));

            const string resourceName = "assembly://RedisMessaging.Tests/RedisMessaging.Tests.Configs/Messaging.config";

            var resource = new AssemblyResource(resourceName);

            return(new XmlObjectFactory(resource));
        }
コード例 #11
0
        public void Setup()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            var resourceName = @"assembly://Spring.Messaging.Amqp.Rabbit.Tests/Spring.Messaging.Amqp.Rabbit.Tests.Config/" + typeof(ListenerContainerParserTests).Name + "-context.xml";
            var resource     = new AssemblyResource(resourceName);

            this.objectFactory = new XmlObjectFactory(resource);

            // ((IConfigurableObjectFactory)objectFactory).setObjectExpressionResolver(new StandardObjectExpressionResolver());
        }
コード例 #12
0
        public static XmlObjectFactory LoadConfig(string configConventionPrefix, int configId)
        {
            NamespaceParserRegistry.RegisterParser(typeof(RedisNamespaceHandler));

            var resourceName = $"assembly://RedisMessaging.Tests/RedisMessaging.Tests.Configs.{configConventionPrefix}/{configConventionPrefix}-{configId}.config";

            var resource = new AssemblyResource(resourceName);

            return(new XmlObjectFactory(resource));
        }
コード例 #13
0
        //[Test]
        public void WithoutId()
        {
            NamespaceParserRegistry.RegisterParser(typeof(WcfNamespaceParser));
            IApplicationContext ctx = new XmlApplicationContext(
                ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.WithoutId.xml", this.GetType()));

            IDictionary <string, IContract> channels = ctx.GetObjects <IContract>();

            Assert.AreEqual(1, channels.Count);
        }
        public void testRendezvous()
        {
            NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));

            IApplicationContext ctx = new XmlApplicationContext(@"Channel\Config\RendezvousChannelParserTests.xml");

            object channel = ctx.GetObject("channel");

            Assert.That(channel.GetType(), Is.EqualTo(typeof(RendezvousChannel)));
        }
コード例 #15
0
ファイル: Global.asax.cs プロジェクト: jjoylee/CanYou
        private void LoadSpringConfig()
        {
            NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));
            NamespaceParserRegistry.RegisterParser(typeof(TxNamespaceParser));
            NamespaceParserRegistry.RegisterParser(typeof(AopNamespaceParser));

            string[]            param   = { "~/AppConfig/Config.xml" };
            IApplicationContext context = new XmlApplicationContext(param);

            ContextRegistry.RegisterContext(context);
        }
コード例 #16
0
        public void SetUp()
        {
            // Configure Spring programmatically
            NamespaceParserRegistry.RegisterParser(typeof(DatabaseNamespaceParser));
            NamespaceParserRegistry.RegisterParser(typeof(TxNamespaceParser));
            NamespaceParserRegistry.RegisterParser(typeof(AopNamespaceParser));
            IApplicationContext context = CreateContextFromXml();

            accountManager = context["accountManager"] as IAccountManager;
            CleanDb(context);
        }
コード例 #17
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();
        }
コード例 #18
0
        /// <summary>
        /// Registers parsers specified in the (recommended, Spring.NET standard)
        /// <c>parsers</c> config section with the <see cref="NamespaceParserRegistry"/>.
        /// </summary>
        /// <param name="parent">
        /// The configuration settings in a corresponding parent
        /// configuration section.
        /// </param>
        /// <param name="configContext">
        /// The configuration context when called from the ASP.NET
        /// configuration system. Otherwise, this parameter is reserved and
        /// is <see langword="null"/>.
        /// </param>
        /// <param name="section">
        /// The <see cref="System.Xml.XmlNode"/> for the section.
        /// </param>
        /// <returns>
        /// This method always returns <see langword="null"/>, because parsers
        /// are registered as a side-effect of this object's execution and there
        /// is thus no need to return anything.
        /// </returns>
        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section != null)
            {
                XmlNodeList parsers = ((XmlElement)section).GetElementsByTagName(ParserElementName);
                foreach (XmlElement parserElement in parsers)
                {
                    string parserTypeName = GetRequiredAttributeValue(parserElement, TypeAttributeName, section);
                    string xmlNamespace   = parserElement.GetAttribute(NamespaceAttributeName);
                    string schemaLocation = parserElement.GetAttribute(SchemaLocationAttributeName);

                    Type parserType = TypeResolutionUtils.ResolveType(parserTypeName);
                    NamespaceParserRegistry.RegisterParser(parserType, xmlNamespace, schemaLocation);
                }
            }
            return(null);
        }
        public void FixtureSetUp()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            try
            {
                if (Environment.IsActive())
                {
                    // Set up broker admin for non-root user
                    this.brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(); // "rabbit@LOCALHOST", 5672);
                    this.brokerAdmin.StartNode();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error occurred during SetUp", ex);
                Assert.Fail("An error occurred during SetUp.");
            }

            if (!this.brokerFederated.Apply())
            {
                Assert.Ignore("Rabbit broker is not running. Ignoring integration test fixture.");
            }
        }
コード例 #20
0
        static void Main()
        {
            try
            {
                log.Info("Running....");
                NamespaceParserRegistry.RegisterParser(typeof(GemfireNamespaceParser));
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                BrokerConfiguration.Configure();

                using (IApplicationContext ctx = ContextRegistry.GetContext())
                {
                    StockForm stockForm = new StockForm();
                    Application.ThreadException += ThreadException;
                    Application.Run(stockForm);
                }
            }
            catch (Exception e)
            {
                log.Error("Spring.Interop.StockTraderSample.Client is broken.", e);
                throw;
            }
        }
コード例 #21
0
        static void Main(string[] args)
        {
            NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));

            new XmlApplicationContext("IntervalOddEvenDemo.xml");
        }
コード例 #22
0
 public void Setup()
 {
     NamespaceParserRegistry.RegisterParser(typeof(ContextNamespaceParser));
     _applicationContext = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("SimpleScanTest.xml", GetType()));
 }
 public void Setup()
 {
     NamespaceParserRegistry.RegisterParser(typeof(ContextNamespaceParser));
 }
コード例 #24
0
 public void SetUp()
 {
     NamespaceParserRegistry.RegisterParser(typeof(GemfireNamespaceParser));
     NamespaceParserRegistry.RegisterParser(typeof(AopNamespaceParser));
     context = new XmlApplicationContext(@"Caching\XmlBasedGemfireCacheTests.xml");
 }
コード例 #25
0
 public void Setup()
 {
     NamespaceParserRegistry.RegisterParser(typeof(GemfireNamespaceParser));
     ctx = new XmlApplicationContext(@"Config\PoolNamespaceTests.xml");
 }
 protected override IConfigurableApplicationContext LoadContextLocations(string[] locations)
 {
     NamespaceParserRegistry.RegisterParser(typeof(IntegrationNamespaceParser));
     NamespaceParserRegistry.RegisterParser(typeof(NmsNamespaceParser));
     return(base.LoadContextLocations(locations));
 }
コード例 #27
0
 public void SetUp()
 {
     NamespaceParserRegistry.RegisterParser(typeof(MongoNamespaceParser));
 }
コード例 #28
0
 public void FixtureSetUp()
 {
     NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
 }
コード例 #29
0
 public void Setup()
 {
     NamespaceParserRegistry.RegisterParser(typeof(EmsNamespaceParser));
     ctx = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("EmsNamespaceHandlerTests.xml", GetType()));
 }
コード例 #30
0
 public void SetUp()
 {
     NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
     this.brokerIsRunning.Apply();
 }