//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSuccessfullyHandshakeKnownProtocolOnClientNoModifiers() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSuccessfullyHandshakeKnownProtocolOnClientNoModifiers() { // when CompletableFuture <ProtocolStack> clientHandshakeFuture = _handshakeClient.initiate(new SimpleNettyChannel(_client.channel, NullLog.Instance), _raftApplicationProtocolRepository, _unsupportingModifierProtocolRepository); // then ProtocolStack clientProtocolStack = clientHandshakeFuture.get(1, TimeUnit.MINUTES); assertThat(clientProtocolStack.ApplicationProtocol(), equalTo(TestProtocols_TestApplicationProtocols.latest(RAFT))); assertThat(clientProtocolStack.ModifierProtocols(), empty()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSuccessfullyHandshakeKnownProtocolOnServerWithCompression() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSuccessfullyHandshakeKnownProtocolOnServerWithCompression() { // when CompletableFuture <ProtocolStack> clientFuture = _handshakeClient.initiate(new SimpleNettyChannel(_client.channel, NullLog.Instance), _raftApplicationProtocolRepository, _compressionModifierProtocolRepository); CompletableFuture <ProtocolStack> serverHandshakeFuture = GetServerHandshakeFuture(clientFuture); // then ProtocolStack serverProtocolStack = serverHandshakeFuture.get(1, TimeUnit.MINUTES); assertThat(serverProtocolStack.ApplicationProtocol(), equalTo(TestProtocols_TestApplicationProtocols.latest(RAFT))); assertThat(serverProtocolStack.ModifierProtocols(), contains(TestProtocols_TestModifierProtocols.latest(COMPRESSION))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandshakeApplicationProtocolOnClient() public virtual void ShouldHandshakeApplicationProtocolOnClient() { // given Fixture fixture = new Fixture(Parameters); // when CompletableFuture <ProtocolStack> clientHandshakeFuture = fixture.Initiate(); // then assertFalse(fixture.ClientChannel.Closed); ProtocolStack clientProtocolStack = clientHandshakeFuture.getNow(null); assertThat(clientProtocolStack.ApplicationProtocol(), equalTo(Parameters.expectedApplicationProtocol)); }
public override void Handle(SwitchOverRequest switchOverRequest) { EnsureMagic(); ProtocolStack protocolStack = _protocolStackBuilder.build(); Optional <Protocol_ApplicationProtocol> switchOverProtocol = _applicationProtocolRepository.select(switchOverRequest.ProtocolName(), switchOverRequest.Version()); IList <Protocol_ModifierProtocol> switchOverModifiers = switchOverRequest.ModifierProtocols().Select(pair => _modifierProtocolRepository.select(pair.first(), pair.other())).flatMap(Streams.ofOptional).ToList(); if (!switchOverProtocol.Present) { _channel.writeAndFlush(SwitchOverResponse.Failure); Decline(string.Format("Cannot switch to protocol {0} version {1:D}", switchOverRequest.ProtocolName(), switchOverRequest.Version())); } else if (protocolStack.ApplicationProtocol() == null) { _channel.writeAndFlush(SwitchOverResponse.Failure); Decline(string.Format("Attempted to switch to protocol {0} version {1:D} before negotiation complete", switchOverRequest.ProtocolName(), switchOverRequest.Version())); } else if (!switchOverProtocol.get().Equals(protocolStack.ApplicationProtocol())) { _channel.writeAndFlush(SwitchOverResponse.Failure); Decline(string.Format("Switch over mismatch: requested {0} version {1} but negotiated {2} version {3}", switchOverRequest.ProtocolName(), switchOverRequest.Version(), protocolStack.ApplicationProtocol().category(), protocolStack.ApplicationProtocol().implementation())); } //JAVA TO C# CONVERTER WARNING: LINQ 'SequenceEqual' is not always identical to Java AbstractList 'equals': //ORIGINAL LINE: else if (!switchOverModifiers.equals(protocolStack.modifierProtocols())) else if (!switchOverModifiers.SequenceEqual(protocolStack.ModifierProtocols())) { _channel.writeAndFlush(SwitchOverResponse.Failure); Decline(string.Format("Switch over mismatch: requested modifiers {0} but negotiated {1}", switchOverRequest.ModifierProtocols(), protocolStack.ModifierProtocols())); } else { SwitchOverResponse response = new SwitchOverResponse(SUCCESS); _channel.writeAndFlush(response); _protocolStackFuture.complete(protocolStack); } }