コード例 #1
0
        public void TestFromXml()
        {
            // Empty (root element name does not matter).
            var cfg = IgniteClientConfiguration.FromXml("<foo />");

            Assert.AreEqual(new IgniteClientConfiguration().ToXml(), cfg.ToXml());
            Assert.IsInstanceOf <ConsoleLogger>(cfg.Logger);

            // Properties.
            cfg = IgniteClientConfiguration.FromXml("<a host='h' port='123'><logger type='null' /></a>");
            Assert.AreEqual("h", cfg.Host);
            Assert.AreEqual(123, cfg.Port);
            Assert.IsNull(cfg.Logger);

            // Full config.
            var fullCfg = new IgniteClientConfiguration
            {
                Host = "test1",
                Port = 345,
                SocketReceiveBufferSize = 222,
                SocketSendBufferSize    = 333,
                TcpNoDelay          = false,
                SocketTimeout       = TimeSpan.FromSeconds(15),
                BinaryConfiguration = new BinaryConfiguration
                {
                    CompactFooter    = false,
                    KeepDeserialized = false,
                    Types            = new[] { "foo", "bar" }
                },
                SslStreamFactory = new SslStreamFactory
                {
                    CertificatePath                 = "abc.pfx",
                    CertificatePassword             = "******",
                    CheckCertificateRevocation      = true,
                    SkipServerCertificateValidation = true,
                    SslProtocols = SslProtocols.None
                },
                Endpoints = new []
                {
                    "foo",
                    "bar:123",
                    "baz:100..103"
                },
                EnablePartitionAwareness = true,
                Logger = new ConsoleLogger
                {
                    MinLevel = LogLevel.Debug
                }
            };

            using (var xmlReader = XmlReader.Create(Path.Combine("Config", "Client", "IgniteClientConfiguration.xml")))
            {
                xmlReader.MoveToContent();

                cfg = IgniteClientConfiguration.FromXml(xmlReader);

                Assert.AreEqual(cfg.ToXml(), fullCfg.ToXml());
                Assert.AreEqual(cfg.ToXml(), IgniteClientConfiguration.FromXml(cfg.ToXml()).ToXml());
            }
        }
コード例 #2
0
        public void TestFromXmlRoundtrip()
        {
            var cfg = new IgniteClientConfiguration();

            Assert.AreEqual(cfg.ToXml(), IgniteClientConfiguration.FromXml(cfg.ToXml()).ToXml());

            cfg.Logger = null;
            Assert.AreEqual(cfg.ToXml(), IgniteClientConfiguration.FromXml(cfg.ToXml()).ToXml());
        }
コード例 #3
0
        public void TestFromXml()
        {
            // Empty (root element name does not matter).
            var cfg = IgniteClientConfiguration.FromXml("<foo />");

            Assert.AreEqual(new IgniteClientConfiguration().ToXml(), cfg.ToXml());

            // Properties.
            cfg = IgniteClientConfiguration.FromXml("<a host='h' port='123' />");
            Assert.AreEqual("h", cfg.Host);
            Assert.AreEqual(123, cfg.Port);

            // Full config.
            var fullCfg = new IgniteClientConfiguration
            {
                Host = "test1",
                Port = 345,
                SocketReceiveBufferSize = 222,
                SocketSendBufferSize    = 333,
                TcpNoDelay          = false,
                SocketTimeout       = TimeSpan.FromSeconds(15),
                BinaryConfiguration = new BinaryConfiguration
                {
                    CompactFooter    = false,
                    KeepDeserialized = false,
                    Types            = new[] { "foo", "bar" }
                }
            };

            using (var xmlReader = XmlReader.Create(Path.Combine("Config", "Client", "IgniteClientConfiguration.xml")))
            {
                xmlReader.MoveToContent();

                cfg = IgniteClientConfiguration.FromXml(xmlReader);

                Assert.AreEqual(cfg.ToXml(), fullCfg.ToXml());
            }
        }