예제 #1
0
        public void TestConstructorWithServerSpec()
        {
            var serverSpec = new RingMasterClient.ServerSpec();

            serverSpec.Endpoints                  = new IPEndPoint[] { new IPEndPoint(IPAddress.Loopback, 0) };
            serverSpec.UseSecureConnection        = true;
            serverSpec.ClientCertificate          = GetLocalCertificates(1)[0];
            serverSpec.AcceptedServerCertificates = GetLocalCertificates(1);

            var configuration = new RingMasterClient.Configuration();

            configuration.DefaultTimeout     = Timeout.InfiniteTimeSpan;
            configuration.HeartBeatInterval  = Timeout.InfiniteTimeSpan;
            configuration.RequestQueueLength = int.MaxValue;
            configuration.BufferSize         = int.MaxValue;

            var instrumentation = new RingMasterClientInstrumentation();

            try
            {
                using (var client = new RingMasterClient(serverSpec, configuration, instrumentation, new CancellationToken(true)))
                {
                    client.Sync("/").Wait();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        public void TestConstructorWithConnectionStringAndThumbprints()
        {
            var clientCertificateThumbprints = GetLocalCertificates(1).Select(c => c.GetCertHashString()).ToArray();
            var serverCertificateThumbprints = GetLocalCertificates(1).Select(c => c.GetCertHashString()).ToArray();

            try
            {
                var watcher = new TestWatcher(0);
                using (var client = new RingMasterClient("127.0.0.1:0", clientCertificateThumbprints, serverCertificateThumbprints, 0, watcher))
                {
                    client.Sync("/").Wait();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #3
0
        public void TestConstructorWithConnectionStringAndCertificates()
        {
            var clientCertificates = GetLocalCertificates(1);
            var serverCertificates = GetLocalCertificates(1);

            try
            {
                var watcher = new TestWatcher(0);
                using (var client = new RingMasterClient("127.0.0.1:0", clientCertificates, serverCertificates, 0, watcher))
                {
                    client.Sync("/").Wait();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #4
0
        public void TestSync()
        {
            using (var requestHandler = new TestRequestHandler())
                using (var client = new RingMasterClient(requestHandler))
                {
                    string path = this.GetRandomString();

                    requestHandler.Implementation = request =>
                    {
                        Assert.IsTrue(request is RequestSync);
                        var syncRequest = (RequestSync)request;
                        Assert.AreEqual(path, syncRequest.Path);

                        return(new RequestResponse()
                        {
                            ResultCode = (int)RingMasterException.Code.Ok
                        });
                    };

                    client.Sync(path).Wait();
                }
        }
예제 #5
0
        public void TestConstructorWithConnectionString()
        {
            var configuration = new RingMasterClient.Configuration();

            configuration.DefaultTimeout     = Timeout.InfiniteTimeSpan;
            configuration.HeartBeatInterval  = Timeout.InfiniteTimeSpan;
            configuration.RequestQueueLength = int.MaxValue;
            configuration.BufferSize         = int.MaxValue;

            var instrumentation = new RingMasterClientInstrumentation();

            try
            {
                using (var client = new RingMasterClient("127.0.0.1:0", configuration, instrumentation, new CancellationToken(true)))
                {
                    client.Sync("/").Wait();
                }
            }
            catch (Exception)
            {
            }
        }