protected IRingMasterRequestHandler ConnectToRingMaster() { SimpleTransport clientTransport = null; IRingMasterRequestHandler ringMaster = null; bool mustDispose = true; try { var configuration = new RingMasterClient.Configuration(); IRingMasterClientInstrumentation instrumentation = new RingMasterClientInstrumentation(); clientTransport = new SimpleTransport(); ringMaster = new RingMasterClient(configuration, instrumentation, this.protocol, clientTransport, CancellationToken.None); clientTransport.Connect(this.serverTransport); mustDispose = false; return(ringMaster); } finally { if (mustDispose) { ringMaster.Dispose(); clientTransport.Dispose(); } } }
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) { } }
public void TestNullConfiguration() { var instrumentation = new RingMasterClientInstrumentation(); try { var serverSpec = new RingMasterClient.ServerSpec(); using (var ringMaster = new RingMasterClient(serverSpec, null, instrumentation, CancellationToken.None)) { Assert.Fail("ArgumentNullException should have been thrown"); } } catch (ArgumentNullException) { } var protocol = new RingMasterCommunicationProtocol(); try { using (var clientTransport = new SimpleTransport()) using (var ringMaster = new RingMasterClient(null, instrumentation, protocol, clientTransport, CancellationToken.None)) { Assert.Fail("ArgumentNullException should have been thrown"); } } catch (ArgumentNullException) { } }
public void TestConstructorWithConnectionStringNoCancellationToken() { 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(); using (var client = new RingMasterClient("127.0.0.1:0", configuration, instrumentation)) { } }
public void TestNullServerSpec() { var configuration = new RingMasterClient.Configuration(); var instrumentation = new RingMasterClientInstrumentation(); try { using (var clientTransport = new SimpleTransport()) using (var ringMaster = new RingMasterClient((RingMasterClient.ServerSpec)null, configuration, instrumentation, CancellationToken.None)) { Assert.Fail("ArgumentNullException should have been thrown"); } } catch (ArgumentNullException) { } }
public void TestEmptyEndpoints() { var serverSpec = new RingMasterClient.ServerSpec(); var configuration = new RingMasterClient.Configuration(); var instrumentation = new RingMasterClientInstrumentation(); try { serverSpec.Endpoints = new IPEndPoint[0]; serverSpec.UseSecureConnection = false; using (var clientTransport = new SimpleTransport()) using (var ringMaster = new RingMasterClient(serverSpec, configuration, instrumentation, CancellationToken.None)) { Assert.Fail("ArgumentException should have been thrown"); } } catch (ArgumentException) { } }