示例#1
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());
        }
示例#2
0
        public void TestCustomConfig()
        {
            var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                ClientConnectorConfiguration = new ClientConnectorConfiguration
                {
                    Host                    = "localhost",
                    Port                    = 2000,
                    PortRange               = 1,
                    SocketSendBufferSize    = 100,
                    SocketReceiveBufferSize = 50
                }
            };

            var clientCfg = new IgniteClientConfiguration
            {
                Endpoints = new[] { "localhost:2000" },
                Logger    = new ConsoleLogger()
            };

            using (Ignition.Start(servCfg))
                using (var client = Ignition.StartClient(clientCfg))
                {
                    Assert.AreNotEqual(clientCfg, client.GetConfiguration());
                    Assert.AreNotEqual(client.GetConfiguration(), client.GetConfiguration());
                    Assert.AreEqual(clientCfg.ToXml(), client.GetConfiguration().ToXml());

                    var conn = client.GetConnections().Single();
                    Assert.AreEqual(servCfg.ClientConnectorConfiguration.Port, ((IPEndPoint)conn.RemoteEndPoint).Port);
                }
        }
示例#3
0
        public void TestCustomConfig()
        {
            var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                ClientConnectorConfiguration = new ClientConnectorConfiguration
                {
                    Host                    = "localhost",
                    Port                    = 2000,
                    PortRange               = 1,
                    SocketSendBufferSize    = 100,
                    SocketReceiveBufferSize = 50
                }
            };

            var clientCfg = new IgniteClientConfiguration
            {
                Endpoints = new[] { "localhost:2000" }
            };

            using (Ignition.Start(servCfg))
                using (var client = Ignition.StartClient(clientCfg))
                {
                    Assert.AreNotEqual(clientCfg, client.GetConfiguration());
                    Assert.AreNotEqual(client.GetConfiguration(), client.GetConfiguration());
                    Assert.AreEqual(clientCfg.ToXml(), client.GetConfiguration().ToXml());
                }
        }
        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());
            }
        }
示例#5
0
        public void TestToXml()
        {
            // Empty config.
            var emptyConfig = new IgniteClientConfiguration {
                Logger = null
            };

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<igniteClientConfiguration " +
                            "xmlns=\"http://ignite.apache.org/schema/dotnet/IgniteClientConfigurationSection\">" +
                            Environment.NewLine + "  <logger type=\"null\" />" + Environment.NewLine +
                            "</igniteClientConfiguration>",
                            emptyConfig.ToXml());

            // Some properties.
            var cfg = new IgniteClientConfiguration
            {
                Host   = "myHost",
                Port   = 123,
                Logger = null
            };

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<igniteClientConfiguration host=\"myHost\" port=\"123\" " +
                            "xmlns=\"http://ignite.apache.org/schema/dotnet/IgniteClientConfigurationSection\">" +
                            Environment.NewLine + "  <logger type=\"null\" />" + Environment.NewLine +
                            "</igniteClientConfiguration>",
                            cfg.ToXml());

            // Nested objects.
            cfg = new IgniteClientConfiguration
            {
                SocketSendBufferSize = 2,
                BinaryConfiguration  = new BinaryConfiguration {
                    CompactFooter = false
                },
                Logger = null
            };

            Assert.IsTrue(cfg.ToXml().Contains("<binaryConfiguration compactFooter=\"false\" />"), cfg.ToXml());

            // Custom element name.
            var sb = new StringBuilder();

            using (var xmlWriter = XmlWriter.Create(sb))
            {
                new IgniteClientConfiguration {
                    Logger = null
                }.ToXml(xmlWriter, "fooBar");
            }

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?><fooBar " +
                            "xmlns=\"http://ignite.apache.org/schema/dotnet/IgniteClientConfigurationSection\">" +
                            "<logger type=\"null\" /></fooBar>",
                            sb.ToString());
        }
        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());
            }
        }